/* NOTREACHED */
}
+ /**
+ * Decide where details need to be gathered to correctly describe a persistent connection.
+ * What is needed:
+ * \item host name of server at other end of this link (either peer or requested host)
+ * \item port to which we connected the other end of this link (for peer or request)
+ * \item domain for which the connection is supposed to be used
+ * \item address of the client for which we made the connection
+ */
void
-
- FwdState::pconnPush(int fd, const char *host, int port, const char *domain, IpAddress &client_addr)
-FwdState::pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, IPAddress &client_addr)
++FwdState::pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, IpAddress &client_addr)
{
- fwdPconnPool->push(fd, host, port, domain, client_addr);
+ if (_peer) {
+ fwdPconnPool->push(fd, _peer->name, _peer->http_port, domain, client_addr);
+ } else {
+ /* small performance improvement, using NULL for domain instead of listing it twice */
+ /* although this will leave a gap open for url-rewritten domains to share a link */
+ fwdPconnPool->push(fd, req->GetHost(), req->port, NULL, client_addr);
+ }
}
void
/* forward decls */
class ErrorState;
+ class HttpRequest;
#include "comm.h"
-#include "IPAddress.h"
+#include "ip/IpAddress.h"
class FwdServer
{
bool checkRetry();
bool checkRetriable();
void dispatch();
- void pconnPush(int fd, const char *host, int port, const char *domain, IpAddress &client_addr);
- void pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, IPAddress &client_addr);
++ void pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, IpAddress &client_addr);
bool dontRetry() { return flags.dont_retry; }
/* ========== PconnPool PRIVATE FUNCTIONS ============================================ */
const char *
-PconnPool::key(const char *host, u_short port, const char *domain, IPAddress &client_address)
+PconnPool::key(const char *host, u_short port, const char *domain, IpAddress &client_address)
{
- LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN * 2 + 10);
+ LOCAL_ARRAY(char, buf, SQUIDHOSTNAMELEN * 3 + 10);
char ntoabuf[MAX_IPSTRLEN];
if (domain && !client_address.IsAnyAddr())
* transactions create persistent connections but are not retriable.
*/
int
-
-PconnPool::pop(const char *host, u_short port, const char *domain, IPAddress &client_address, bool isRetriable)
+PconnPool::pop(const char *host, u_short port, const char *domain, IpAddress &client_address, bool isRetriable)
{
- IdleConnList *list;
const char * aKey = key(host, port, domain, client_address);
- list = (IdleConnList *)hash_lookup(table, aKey);
- if (list == NULL)
+ IdleConnList *list = (IdleConnList *)hash_lookup(table, aKey);
+ if (list == NULL) {
+ debugs(48, 3, "PconnPool::pop: lookup for key {" << aKey << "} failed.");
return -1;
+ } else {
+ debugs(48, 3, "PconnPool::pop: found " << hashKeyStr(&list->hash) << (isRetriable?"(to use)":"(to kill)") );
+ }
int fd = list->findUseableFD(); // search from the end. skip pending reads.
PconnPool(const char *);
void moduleInit();
- void push(int fd, const char *host, u_short port, const char *domain, IPAddress &client_address);
- int pop(const char *host, u_short port, const char *domain, IPAddress &client_address, bool retriable);
+ void push(int fd, const char *host, u_short port, const char *domain, IpAddress &client_address);
+ int pop(const char *host, u_short port, const char *domain, IpAddress &client_address, bool retriable);
void count(int uses);
void dumpHist(StoreEntry *e);
+ void dumpHash(StoreEntry *e);
void unlinkList(IdleConnList *list) const;
private: