From: Amos Jeffries Date: Tue, 20 Jul 2010 07:28:33 +0000 (+1200) Subject: Do peer conn accounting in comm layer X-Git-Tag: take08~55^2~124^2~102 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=746beefe7d5d9ed958ba5d526d9532638a1d03ba;p=thirdparty%2Fsquid.git Do peer conn accounting in comm layer --- diff --git a/src/comm/Connection.cc b/src/comm/Connection.cc index 0bcf229084..ffc3371e2e 100644 --- a/src/comm/Connection.cc +++ b/src/comm/Connection.cc @@ -45,6 +45,8 @@ Comm::Connection::close() if (isOpen()) { comm_close(fd); fd = -1; + if (_peer) + _peer->stats.conn_open--; } } @@ -61,8 +63,8 @@ Comm::Connection::setPeer(peer *p) _peer = NULL; } - /* set the new one (unless it is NULL */ - if (p) { + /* set the new one (unless it is NULL */ + if (p) { _peer = cbdataReference(p); - } + } } diff --git a/src/forward.cc b/src/forward.cc index 837d654449..e8b6daa31e 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -487,12 +487,6 @@ void FwdState::serverClosed(int fd) { debugs(17, 2, HERE << "FD " << fd << " " << entry->url()); - assert(serverConnection()->fd == fd); - - if (serverConnection()->getPeer()) { - serverConnection()->getPeer()->stats.conn_open--; - } - retryOrBail(); } @@ -577,7 +571,6 @@ FwdState::negotiateSSL(int fd) if (serverConnection()->getPeer()) { peerConnectFailed(serverConnection()->getPeer()); - serverConnection()->getPeer()->stats.conn_open--; } serverConnection()->close(); @@ -724,7 +717,9 @@ FwdState::connectTimeout(int fd) peerConnectFailed(serverConnection()->getPeer()); } - serverConnection()->close(); + if (isServerConnectionOpen()) { + serverConnection()->close(); + } } /** @@ -953,11 +948,13 @@ FwdState::dispatch() */ request->flags.proxy_keepalive = 0; /* - * Set the dont_retry flag becuase this is not a + * Set the dont_retry flag because this is not a * transient (network) error; its a bug. */ flags.dont_retry = 1; - serverConnection()->close(); + if (isServerConnectionOpen()) { + serverConnection()->close(); + } break; } }