From: Amos Jeffries Date: Sat, 22 May 2010 06:34:14 +0000 (+1200) Subject: make Comm::Connection ref-counted and fix pconn handling. X-Git-Tag: take08~55^2~124^2~143 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93ad6f77a13ddade63012b5db285e4066a4049dc;p=thirdparty%2Fsquid.git make Comm::Connection ref-counted and fix pconn handling. --- diff --git a/include/RefCount.h b/include/RefCount.h index f648fe48cf..110ca456cd 100644 --- a/include/RefCount.h +++ b/include/RefCount.h @@ -114,7 +114,7 @@ private: struct RefCountable_ { RefCountable_():count_(0) {} - virtual ~RefCountable_() {} + virtual ~RefCountable_() { assert(RefCountCount() == 0); } /* Not private, to allow class hierarchies */ void RefCountReference() const { diff --git a/src/CommCalls.cc b/src/CommCalls.cc index d4b10a652b..ce5b8028ef 100644 --- a/src/CommCalls.cc +++ b/src/CommCalls.cc @@ -45,6 +45,7 @@ CommAcceptCbParams::print(std::ostream &os) const CommCommonCbParams::print(os); if (nfd >= 0) os << ", newFD " << nfd; + os << ", " << details; } @@ -71,6 +72,11 @@ void CommConnectCbParams::print(std::ostream &os) const { CommCommonCbParams::print(os); + if (conn != NULL) + os << ", from my " << conn->local << " to " << conn->remote; + else if (paths && paths->size() > 0) { + // TODO: for each path. print the to => from path being attempted. + } } /* CommIoCbParams */ diff --git a/src/CommCalls.h b/src/CommCalls.h index d732a7f153..9dc02f0f03 100644 --- a/src/CommCalls.h +++ b/src/CommCalls.h @@ -68,7 +68,7 @@ public: void print(std::ostream &os) const; public: - Comm::Connection *details; + Comm::Connection::Pointer details; int nfd; // TODO: rename to fdNew or somesuch }; @@ -83,8 +83,8 @@ public: void print(std::ostream &os) const; public: - Comm::Connection *conn; - Vector *paths; + Comm::Connection::Pointer conn; + Vector *paths; }; // read/write (I/O) parameters diff --git a/src/PeerSelectState.h b/src/PeerSelectState.h index 6896a15825..e4fb65755f 100644 --- a/src/PeerSelectState.h +++ b/src/PeerSelectState.h @@ -42,9 +42,9 @@ class HttpRequest; class StoreEntry; -typedef void PSC(Vector *, void *); +typedef void PSC(Vector *, void *); -SQUIDCEXTERN void peerSelect(Vector *, HttpRequest *, StoreEntry *, PSC *, void *data); +SQUIDCEXTERN void peerSelect(Vector *, HttpRequest *, StoreEntry *, PSC *, void *data); SQUIDCEXTERN void peerSelectInit(void); /** @@ -78,7 +78,7 @@ public: PSC *callback; void *callback_data; - Vector *paths; ///< the callers paths array. to be filled with our final results. + Vector *paths; ///< the callers paths array. to be filled with our final results. FwdServer *servers; ///< temporary linked list of peers we will pass back. /* diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index 6356d052f2..e08d181180 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -116,7 +116,7 @@ void Adaptation::Icap::Xaction::openConnection() disableRetries(); // we only retry pconn failures - Comm::Connection *conn = new Comm::Connection; + Comm::Connection::Pointer conn = new Comm::Connection; // TODO: where do we get the DNS info for the ICAP server host ?? // Ip::Address will do a BLOCKING lookup if s.cfg().host is a hostname diff --git a/src/client_side.cc b/src/client_side.cc index 7a53da8454..053caf50ba 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -3057,7 +3057,7 @@ connStateCreate(const Ip::Address &peer, const Ip::Address &me, int fd, http_por /** Handle a new connection on HTTP socket. */ void -httpAccept(int sock, int newfd, Comm::Connection *details, +httpAccept(int sock, int newfd, Comm::Connection::Pointer details, comm_err_t flag, int xerrno, void *data) { http_port_list *s = (http_port_list *)data; @@ -3120,7 +3120,7 @@ httpAccept(int sock, int newfd, Comm::Connection *details, /** Create SSL connection structure and update fd_table */ static SSL * -httpsCreate(int newfd, Comm::Connection *details, SSL_CTX *sslContext) +httpsCreate(int newfd, Comm::Connection::Pointer details, SSL_CTX *sslContext) { SSL *ssl = SSL_new(sslContext); @@ -3263,7 +3263,7 @@ clientNegotiateSSL(int fd, void *data) /** handle a new HTTPS connection */ static void -httpsAccept(int sock, int newfd, Comm::Connection *details, +httpsAccept(int sock, int newfd, Comm::Connection::Pointer details, comm_err_t flag, int xerrno, void *data) { https_port_list *s = (https_port_list *)data; diff --git a/src/comm.cc b/src/comm.cc index b34e36c579..2e9ebebce7 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -793,43 +793,6 @@ comm_openex(int sock_type, return new_socket; } -#if 0 -// AYJ: this API is dead. alter the caller which is using this to do its own DNS lookups -// and generate a Vector of possible destinations. -// do the rest of this itself... -void -commConnectStart(int fd, const char *host, u_short port, AsyncCall::Pointer &cb) -{ - debugs(cb->debugSection, cb->debugLevel, "commConnectStart: FD " << fd << - ", cb " << cb << ", " << host << ":" << port); // TODO: just print *cb - - ConnectStateData *cs; - cs = new ConnectStateData; - cs->fd = fd; - cs->host = xstrdup(host); - cs->default_port = port; - cs->callback = cb; - - comm_add_close_handler(fd, ConnectStateData::Free, cs); - ipcache_nbgethostbyname(host, commConnectDnsHandle, cs); -} -#endif - -#if 0 -// TODO: Remove this and similar callback registration functions by replacing -// (callback,data) parameters with an AsyncCall so that we do not have to use -// a generic call name and debug level when creating an AsyncCall. This will -// also cut the number of callback registration routines in half. -void -commConnectStart(int fd, const char *host, u_short port, CNCB * callback, void *data) -{ - debugs(5, 5, "commConnectStart: FD " << fd << ", data " << data << ", " << host << ":" << port); - AsyncCall::Pointer call = commCbCall(5,3, - "SomeCommConnectHandler", CommConnectCbPtrFun(callback, data)); - commConnectStart(fd, host, port, call); -} -#endif - static void copyFDFlags(int to, fde *F) { @@ -1188,7 +1151,7 @@ comm_close_complete(int fd, void *data) * Close the socket fd in use by a connection. */ void -_comm_close(Comm::Connection *conn, char const *file, int line) +_comm_close(Comm::Connection::Pointer conn, char const *file, int line) { _comm_close(conn->fd, file, line); conn->fd = -1; diff --git a/src/comm.h b/src/comm.h index ac63caf6e6..2c452d55d3 100644 --- a/src/comm.h +++ b/src/comm.h @@ -13,7 +13,7 @@ #define COMMIO_FD_READCB(fd) (&commfd_table[(fd)].readcb) #define COMMIO_FD_WRITECB(fd) (&commfd_table[(fd)].writecb) -typedef void CNCB(Comm::Connection *conn, Vector *paths, comm_err_t status, int xerrno, void *data); +typedef void CNCB(Comm::Connection::Pointer conn, Vector *paths, comm_err_t status, int xerrno, void *data); typedef void IOCB(int fd, char *, size_t size, comm_err_t flag, int xerrno, void *data); @@ -25,7 +25,7 @@ SQUIDCEXTERN int commUnsetNonBlocking(int fd); SQUIDCEXTERN void commSetCloseOnExec(int fd); SQUIDCEXTERN void commSetTcpKeepalive(int fd, int idle, int interval, int timeout); extern void _comm_close(int fd, char const *file, int line); -extern void _comm_close(Comm::Connection *conn, char const *file, int line); +extern void _comm_close(Comm::Connection::Pointer conn, char const *file, int line); #define comm_close(x) (_comm_close((x), __FILE__, __LINE__)) SQUIDCEXTERN void comm_reset_close(int fd); #if LINGERING_CLOSE @@ -85,7 +85,7 @@ SQUIDCEXTERN comm_err_t comm_select(int); SQUIDCEXTERN void comm_quick_poll_required(void); #include "comm/Connection.h" -typedef void IOACB(int fd, int nfd, Comm::Connection *details, comm_err_t flag, int xerrno, void *data); +typedef void IOACB(int fd, int nfd, Comm::Connection::Pointer details, comm_err_t flag, int xerrno, void *data); extern void comm_add_close_handler(int fd, PF *, void *); extern void comm_add_close_handler(int fd, AsyncCall::Pointer &); extern void comm_remove_close_handler(int fd, PF *, void *); diff --git a/src/comm/ConnectStateData.cc b/src/comm/ConnectStateData.cc index 983f0f8493..51c4248c0a 100644 --- a/src/comm/ConnectStateData.cc +++ b/src/comm/ConnectStateData.cc @@ -2,12 +2,13 @@ #include "comm/ConnectStateData.h" #include "comm.h" #include "CommCalls.h" +#include "fde.h" #include "icmp/net_db.h" #include "SquidTime.h" CBDATA_CLASS_INIT(ConnectStateData); -ConnectStateData::ConnectStateData(Vector *paths, AsyncCall::Pointer handler) : +ConnectStateData::ConnectStateData(Vector *paths, AsyncCall::Pointer handler) : host(NULL), connect_timeout(Config.Timeout.connect), paths(paths), @@ -18,7 +19,7 @@ ConnectStateData::ConnectStateData(Vector *paths, AsyncCall:: connstart(0) {} -ConnectStateData::ConnectStateData(Comm::Connection *c, AsyncCall::Pointer handler) : +ConnectStateData::ConnectStateData(Comm::Connection::Pointer c, AsyncCall::Pointer handler) : host(NULL), connect_timeout(Config.Timeout.connect), paths(paths), @@ -76,7 +77,7 @@ ConnectStateData::callCallback(comm_err_t status, int xerrno) void ConnectStateData::connect() { - Comm::Connection *active; + Comm::Connection::Pointer active; /* handle connecting to one single path */ /* mainly used by components other than forwarding */ @@ -84,10 +85,10 @@ ConnectStateData::connect() /* handle connecting to one of multiple paths */ /* mainly used by forwarding */ - if (solo) { + if (solo != NULL) { active = solo; } else if (paths) { - Vector::iterator i = paths->begin(); + Vector::iterator i = paths->begin(); if (connstart == 0) { connstart = squid_curtime; @@ -131,15 +132,20 @@ ConnectStateData::connect() case COMM_OK: debugs(5, 5, HERE << "FD " << active->fd << ": COMM_OK - connected"); - /* - * stats.conn_open is used to account for the number of - * connections that we have open to the peer, so we can limit - * based on the max-conn option. We need to increment here, - * even if the connection may fail. - */ + /* + * stats.conn_open is used to account for the number of + * connections that we have open to the peer, so we can limit + * based on the max-conn option. We need to increment here, + * even if the connection may fail. + */ if (active->_peer) active->_peer->stats.conn_open++; + /* TODO: remove this fd_table access. But old code still depends on fd_table flags to + * indicate the state of a raw fd object being passed around. + */ + fd_table[active->fd].flags.open = 1; + ipcacheMarkGoodAddr(host, active->remote); callCallback(COMM_OK, 0); break; diff --git a/src/comm/ConnectStateData.h b/src/comm/ConnectStateData.h index eece8d15f0..60585effb8 100644 --- a/src/comm/ConnectStateData.h +++ b/src/comm/ConnectStateData.h @@ -17,9 +17,9 @@ class ConnectStateData { public: /** open first working of a set of connections */ - ConnectStateData(Vector *paths, AsyncCall::Pointer handler); + ConnectStateData(Vector *paths, AsyncCall::Pointer handler); /** attempt to open one connection. */ - ConnectStateData(Comm::Connection *, AsyncCall::Pointer handler); + ConnectStateData(Comm::Connection::Pointer, AsyncCall::Pointer handler); void *operator new(size_t); void operator delete(void *); @@ -62,9 +62,9 @@ public: time_t connect_timeout; private: - Vector *paths; ///< forwarding paths to be tried. front of the list is the current being opened. - Comm::Connection *solo; ///< single connection currently being opened. - AsyncCall::Pointer callback; ///< handler to be called on connection completion. + Vector *paths; ///< forwarding paths to be tried. front of the list is the current being opened. + Comm::Connection::Pointer solo; ///< single connection currently being opened. + AsyncCall::Pointer callback; ///< handler to be called on connection completion. int total_tries; ///< total number of connection attempts over all destinations so far. int fail_retries; ///< number of retries current destination has been tried. diff --git a/src/comm/Connection.h b/src/comm/Connection.h index 4b9600c761..e35cbbe7db 100644 --- a/src/comm/Connection.h +++ b/src/comm/Connection.h @@ -1,5 +1,6 @@ /* * DEBUG: section 5 Socket Functions + * AUTHOR: Amos Jeffries * AUTHOR: Robert Collins * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -30,6 +31,7 @@ * * * Copyright (c) 2003, Robert Collins + * Copyright (c) 2010, Amos Jeffries */ #ifndef _SQUIDCONNECTIONDETAIL_H_ @@ -37,6 +39,7 @@ #include "hier_code.h" #include "ip/Address.h" +#include "RefCount.h" class peer; @@ -51,9 +54,11 @@ namespace Comm { #define COMM_TRANSPARENT 0x08 #define COMM_DOBIND 0x10 -class Connection +class Connection : public RefCountable { public: + typedef RefCount Pointer; + Connection(); Connection(Connection &c); ~Connection(); diff --git a/src/comm/ListenStateData.cc b/src/comm/ListenStateData.cc index 75222b60c9..04a99cf474 100644 --- a/src/comm/ListenStateData.cc +++ b/src/comm/ListenStateData.cc @@ -186,7 +186,7 @@ Comm::ListenStateData::acceptNext() } void -Comm::ListenStateData::notify(int newfd, comm_err_t errcode, int xerrno, Comm::Connection *connDetails) +Comm::ListenStateData::notify(int newfd, comm_err_t errcode, int xerrno, Comm::Connection::Pointer connDetails) { // listener socket handlers just abandon the port with COMM_ERR_CLOSING // it should only happen when this object is deleted... diff --git a/src/comm/ListenStateData.h b/src/comm/ListenStateData.h index d436adfc7d..a83f8e2ece 100644 --- a/src/comm/ListenStateData.h +++ b/src/comm/ListenStateData.h @@ -23,7 +23,7 @@ public: void subscribe(AsyncCall::Pointer &call); void acceptNext(); - void notify(int newfd, comm_err_t, int xerrno, Comm::Connection *); + void notify(int newfd, comm_err_t, int xerrno, Comm::Connection::Pointer); int fd; diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 8ac8cdd9d1..c963c88fa5 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -699,14 +699,14 @@ idnsDoSendQueryVC(nsvc *vc) } static void -idnsInitVCConnected(Comm::Connection *conn, Vector *unused, comm_err_t status, int xerrno, void *data) +idnsInitVCConnected(Comm::Connection::Pointer conn, Vector *unused, comm_err_t status, int xerrno, void *data) { nsvc * vc = (nsvc *)data; if (status != COMM_OK || !conn) { char buf[MAX_IPSTRLEN]; debugs(78, DBG_IMPORTANT, "Failed to connect to nameserver " << nameservers[vc->ns].S.NtoA(buf,MAX_IPSTRLEN) << " using TCP!"); - delete conn; + conn = NULL; return; } @@ -731,8 +731,6 @@ idnsVCClosed(int fd, void *data) static void idnsInitVC(int ns) { - char buf[MAX_IPSTRLEN]; - nsvc *vc = cbdataAlloc(nsvc); nameservers[ns].vc = vc; vc->ns = ns; @@ -740,7 +738,7 @@ idnsInitVC(int ns) vc->msg = new MemBuf; vc->busy = 1; - Comm::Connection *conn = new Comm::Connection; + Comm::Connection::Pointer conn = new Comm::Connection; if (!Config.Addrs.udp_outgoing.IsNoAddr()) conn->local = Config.Addrs.udp_outgoing; diff --git a/src/forward.cc b/src/forward.cc index ffa621c9ba..3ddd618ba3 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -360,7 +360,7 @@ FwdState::complete() /**** CALLBACK WRAPPERS ************************************************************/ static void -fwdStartCompleteWrapper(Vector *unused, void *data) +fwdStartCompleteWrapper(Vector *unused, void *data) { FwdState *fwd = (FwdState *) data; fwd->startComplete(); @@ -390,7 +390,7 @@ fwdNegotiateSSLWrapper(int fd, void *data) #endif void -fwdConnectDoneWrapper(Comm::Connection *conn, Vector *paths, comm_err_t status, int xerrno, void *data) +fwdConnectDoneWrapper(Comm::Connection::Pointer conn, Vector *paths, comm_err_t status, int xerrno, void *data) { FwdState *fwd = (FwdState *) data; fwd->connectDone(conn, paths, status, xerrno); @@ -663,7 +663,7 @@ FwdState::initiateSSL() #endif void -FwdState::connectDone(Comm::Connection *conn, Vector *result_paths, comm_err_t status, int xerrno) +FwdState::connectDone(Comm::Connection::Pointer conn, Vector *result_paths, comm_err_t status, int xerrno) { assert(result_paths == &paths); @@ -740,7 +740,7 @@ FwdState::connectStart() if (n_tries == 0) // first attempt request->hier.first_conn_start = current_time; - Comm::Connection *conn = paths[0]; + Comm::Connection::Pointer conn = paths[0]; /* connection timeout */ int ctimeout; @@ -781,7 +781,7 @@ FwdState::connectStart() debugs(17,2,HERE << " Pinned connection " << pinned_connection << " not valid. Releasing."); request->releasePinnedConnection(); paths.shift(); - delete conn; + conn = NULL; connectStart(); return; } @@ -789,7 +789,8 @@ FwdState::connectStart() // TODO: now that we are dealing with actual IP->IP links. should we still anchor pconn on hostname? // or on the remote IP+port? // that could reduce the pconns per virtual server a fair amount -// and prevent crossover between servers hosting the one domain +// but would prevent crossover between servers hosting the one domain +// this currently opens the possibility that conn will lie about where the FD goes. const char *host; int port; @@ -831,18 +832,6 @@ FwdState::connectStart() cs->connect(); } -#if DEAD -void -FwdState::startFail() -{ - debugs(17, 3, HERE << entry->url() ); - ErrorState *anErr = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request); - anErr->xerrno = errno; - fail(anErr); - self = NULL; // refcounted -} -#endif - void FwdState::dispatch() { @@ -1086,15 +1075,21 @@ FwdState::reforwardableStatus(http_status s) * - address of the client for which we made the connection */ void -FwdState::pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr) +FwdState::pconnPush(Comm::Connection::Pointer conn, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr) { if (_peer) { - fwdPconnPool->push(fd, _peer->name, _peer->http_port, domain, client_addr); + fwdPconnPool->push(conn->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); + fwdPconnPool->push(conn->fd, req->GetHost(), req->port, NULL, client_addr); } + + /* XXX: remove this when Comm::Connection are stored in the pool + * this only prevents the persistent FD being closed when the + * Comm::Connection currently using it is destroyed. + */ + conn->fd = -1; } void @@ -1175,24 +1170,6 @@ FwdState::updateHierarchyInfo() /**** PRIVATE NON-MEMBER FUNCTIONS ********************************************/ -#if DEAD -static Ip::Address -aclMapAddr(acl_address * head, ACLChecklist * ch) -{ - acl_address *l; - - Ip::Address addr; - - for (l = head; l; l = l->next) { - if (!l->aclList || ch->matchAclListFast(l->aclList)) - return l->addr; - } - - addr.SetAnyAddr(); - return addr; -} -#endif - /* * DPW 2007-05-19 * Formerly static, but now used by client_side_request.cc @@ -1211,7 +1188,7 @@ aclMapTOS(acl_tos * head, ACLChecklist * ch) } void -getOutgoingAddress(HttpRequest * request, Comm::Connection *conn) +getOutgoingAddress(HttpRequest * request, Comm::Connection::Pointer conn) { /* skip if an outgoing address is already set. */ if (!conn->local.IsAnyAddr()) return; diff --git a/src/forward.h b/src/forward.h index 804b239e90..a5e30a3a2b 100644 --- a/src/forward.h +++ b/src/forward.h @@ -8,23 +8,9 @@ class HttpRequest; #include "comm.h" #include "comm/Connection.h" -//#include "hier_code.h" #include "ip/Address.h" #include "Array.h" -#if 0 // replaced by vector of extended Comm::Connection objects (paths) -class FwdServer -{ -public: - peer *_peer; /* NULL --> origin server */ - hier_code code; - FwdServer *next; -}; - -typedef void PSC(FwdServer *, void *); - -#endif - class FwdState : public RefCountable { public: @@ -34,7 +20,6 @@ public: static void fwdStart(int fd, StoreEntry *, HttpRequest *); void startComplete(); -// void startFail(); void fail(ErrorState *err); void unregister(int fd); void complete(); @@ -43,14 +28,14 @@ public: bool reforwardableStatus(http_status s); void serverClosed(int fd); void connectStart(); - void connectDone(Comm::Connection *conn, Vector *paths, comm_err_t status, int xerrno); + void connectDone(Comm::Connection::Pointer conn, Vector *paths, comm_err_t status, int xerrno); void connectTimeout(int fd); void initiateSSL(); void negotiateSSL(int fd); bool checkRetry(); bool checkRetriable(); void dispatch(); - void pconnPush(int fd, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr); + void pconnPush(Comm::Connection::Pointer conn, const peer *_peer, const HttpRequest *req, const char *domain, Ip::Address &client_addr); bool dontRetry() { return flags.dont_retry; } @@ -60,7 +45,7 @@ public: void ftpPasvFailed(bool val) { flags.ftp_pasv_failed = val; } - Comm::Connection *conn() const { return paths[0]; }; + Comm::Connection::Pointer conn() const { return paths[0]; }; private: // hidden for safer management of self; use static fwdStart @@ -104,7 +89,7 @@ private: } flags; /** possible paths which may be tried (in sequence stored) */ - Vector paths; + Vector paths; // NP: keep this last. It plays with private/public CBDATA_CLASS2(FwdState); diff --git a/src/ftp.cc b/src/ftp.cc index 1f3dea861d..a6c4a23cb2 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -2406,7 +2406,7 @@ ftpReadEPSV(FtpStateData* ftpState) debugs(9, 3, HERE << "connecting to " << ftpState->data.host << ", port " << ftpState->data.port); - Comm::Connection *conn = new Comm::Connection; + Comm::Connection::Pointer conn = new Comm::Connection; conn->remote = fd_table[ftpState->ctrl.fd].ipaddr; // TODO: do we have a better info source than fd_table? conn->remote.SetPort(port); conn->fd = fd; @@ -2691,7 +2691,7 @@ ftpReadPasv(FtpStateData * ftpState) debugs(9, 3, HERE << "connecting to " << ftpState->data.host << ", port " << ftpState->data.port); - Comm::Connection *conn = new Comm::Connection; + Comm::Connection::Pointer conn = new Comm::Connection; conn->remote = ipaddr; conn->remote.SetPort(port); conn->fd = ftpState->data.fd; @@ -2704,7 +2704,7 @@ ftpReadPasv(FtpStateData * ftpState) } void -FtpStateData::ftpPasvCallback(Comm::Connection *conn, Vector *unused, comm_err_t status, int xerrno, void *data) +FtpStateData::ftpPasvCallback(Comm::Connection::Pointer conn, Vector *unused, comm_err_t status, int xerrno, void *data) { FtpStateData *ftpState = (FtpStateData *)data; debugs(9, 3, HERE); diff --git a/src/http.cc b/src/http.cc index 40123f58aa..8079befae1 100644 --- a/src/http.cc +++ b/src/http.cc @@ -95,7 +95,7 @@ HttpStateData::HttpStateData(FwdState *theFwdState) : AsyncJob("HttpStateData"), orig_request->hier.peer_http_request_sent.tv_sec = 0; orig_request->hier.peer_http_request_sent.tv_usec = 0; - if (fwd->conn()) + if (fwd->conn() != NULL) _peer = fwd->conn()->_peer; /* might be NULL */ if (_peer) { @@ -1368,7 +1368,7 @@ HttpStateData::processReplyBody() orig_request->pinnedConnection()->pinConnection(fd, orig_request, _peer, (request->flags.connection_auth != 0)); } else { - fwd->pconnPush(fd, _peer, request, orig_request->GetHost(), client_addr); + fwd->pconnPush(fwd->conn(), _peer, request, orig_request->GetHost(), client_addr); } fd = -1; diff --git a/src/ident/Ident.cc b/src/ident/Ident.cc index a34990a9a0..7a5e959c05 100644 --- a/src/ident/Ident.cc +++ b/src/ident/Ident.cc @@ -117,7 +117,7 @@ Ident::Timeout(int fd, void *data) } void -Ident::ConnectDone(Comm::Connection *conn, Vector *unused, comm_err_t status, int xerrno, void *data) +Ident::ConnectDone(Comm::Connection::Pointer conn, Vector *unused, comm_err_t status, int xerrno, void *data) { IdentStateData *state = (IdentStateData *)data; @@ -217,7 +217,7 @@ CBDATA_TYPE(IdentStateData); * start a TCP connection to the peer host on port 113 */ void -Ident::Start(Comm::Connection *conn, IDCB * callback, void *data) +Ident::Start(Comm::Connection::Pointer conn, IDCB * callback, void *data) { IdentStateData *state; char key1[IDENT_KEY_SZ]; diff --git a/src/ident/Ident.h b/src/ident/Ident.h index b7cbb9f34b..84124ed2e0 100644 --- a/src/ident/Ident.h +++ b/src/ident/Ident.h @@ -27,7 +27,7 @@ namespace Ident * Self-registers with a global ident lookup manager, * will call Ident::Init() itself if the manager has not been initialized already. */ -void Start(Comm::Connection *conn, IDCB * callback, void *cbdata); +void Start(Comm::Connection::Pointer conn, IDCB * callback, void *cbdata); /** \ingroup IdentAPI diff --git a/src/neighbors.cc b/src/neighbors.cc index b7d9aafb01..532719139f 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1359,9 +1359,9 @@ peerProbeConnect(peer * p) return ret;/* don't probe to often */ /* for each IP address of this peer. find one that we can connect to and probe it. */ - Vector *paths = new Vector; + Vector *paths = new Vector; for (int i = 0; i < p->n_addresses; i++) { - Comm::Connection *conn = new Comm::Connection; + Comm::Connection::Pointer conn = new Comm::Connection; conn->remote = p->addresses[i]; conn->remote.SetPort(p->http_port); getOutgoingAddress(NULL, conn); @@ -1381,7 +1381,7 @@ peerProbeConnect(peer * p) } static void -peerProbeConnectDone(Comm::Connection *conn, Vector *unused, comm_err_t status, int xerrno, void *data) +peerProbeConnectDone(Comm::Connection::Pointer conn, Vector *unused, comm_err_t status, int xerrno, void *data) { peer *p = (peer*)data; diff --git a/src/peer_select.cc b/src/peer_select.cc index f017773222..b51ff16f75 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -124,7 +124,7 @@ peerSelectIcpPing(HttpRequest * request, int direct, StoreEntry * entry) void -peerSelect(Vector *paths, +peerSelect(Vector *paths, HttpRequest * request, StoreEntry * entry, PSC * callback, @@ -253,7 +253,7 @@ peerSelectDnsResults(const ipcache_addrs *ia, const DnsLookupDetails &details, v assert(ia->cur < ia->count); // loop over each result address, adding to the possible destinations. - Comm::Connection *p; + Comm::Connection::Pointer p; int ip = ia->cur; for (int n = 0; n < ia->count; n++, ip++) { if (ip >= ia->count) ip = 0; // looped back to zero. diff --git a/src/protos.h b/src/protos.h index 6975f2cc29..24c24677dd 100644 --- a/src/protos.h +++ b/src/protos.h @@ -406,7 +406,7 @@ SQUIDCEXTERN void peerDigestNotePeerGone(PeerDigest * pd); SQUIDCEXTERN void peerDigestStatsReport(const PeerDigest * pd, StoreEntry * e); #include "comm/Connection.h" -extern void getOutgoingAddress(HttpRequest * request, Comm::Connection *conn); +extern void getOutgoingAddress(HttpRequest * request, Comm::Connection::Pointer conn); unsigned long getOutgoingTOS(HttpRequest * request); SQUIDCEXTERN void urnStart(HttpRequest *, StoreEntry *); diff --git a/src/tunnel.cc b/src/tunnel.cc index e945eb785e..3ac26e6ec9 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -68,7 +68,7 @@ public: char *host; /* either request->host or proxy host */ u_short port; HttpRequest *request; - Vector *paths; + Vector *paths; class Connection { @@ -558,12 +558,12 @@ tunnelErrorComplete(int fdnotused, void *data, size_t sizenotused) static void -tunnelConnectDone(Comm::Connection *unused, Vector *paths, comm_err_t status, int xerrno, void *data) +tunnelConnectDone(Comm::Connection::Pointer unused, Vector *paths, comm_err_t status, int xerrno, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; HttpRequest *request = tunnelState->request; ErrorState *err = NULL; - Comm::Connection *conn = (*paths)[0]; + Comm::Connection::Pointer conn = (*paths)[0]; assert(tunnelState->paths == paths); @@ -713,7 +713,7 @@ tunnelProxyConnected(int fd, void *data) } static void -tunnelPeerSelectComplete(Vector *peer_paths, void *data) +tunnelPeerSelectComplete(Vector *peer_paths, void *data) { TunnelStateData *tunnelState = (TunnelStateData *)data; HttpRequest *request = tunnelState->request;