From: Amos Jeffries Date: Thu, 20 May 2010 12:05:46 +0000 (+1200) Subject: Handle forwarding timeout better. X-Git-Tag: take08~55^2~124^2~145 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f538b781bbb4ac5cbb376ee8699b408e5f5da7f;p=thirdparty%2Fsquid.git Handle forwarding timeout better. --- diff --git a/src/forward.cc b/src/forward.cc index 4a45a39f7b..8da4a2ea65 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -667,60 +667,42 @@ FwdState::connectDone(Comm::Connection *conn, Vector *result_ { assert(result_paths == &paths); - if (Config.onoff.log_ip_on_direct && /* status != COMM_ERR_DNS &&*/ (paths[0])->peer_type == HIER_DIRECT) - updateHierarchyInfo(); - -#if 0 // we no longer are limited to handling this here. - // the selectForwardingPaths shoudl handle things like this now. - if (status == COMM_ERR_DNS) { - /* - * Only set the dont_retry flag if the DNS lookup fails on - * a direct connection. If DNS lookup fails when trying - * a neighbor cache, we may want to retry another option. - */ - - if (NULL == fs->_peer) - flags.dont_retry = 1; - - debugs(17, 4, "Unknown host: " << request->GetHost()); - - ErrorState *anErr = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, request); - - anErr->dnsError = dns.error; - - fail(anErr); - - comm_close(server_fd); - } else -#endif - if (status != COMM_OK) { + if (status != COMM_OK) { ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request); anErr->xerrno = xerrno; fail(anErr); - if (paths[0]->_peer) - peerConnectFailed(paths[0]->_peer); + /* it might have been a timeout with a partially open link */ + if (paths.size() > 0) { + if (paths[0]->_peer) + peerConnectFailed(paths[0]->_peer); - comm_close(paths[0]); - } else { - debugs(17, 3, "FD " << paths[0]->fd << ": '" << entry->url() << "'" ); + comm_close(paths[0]); + } - comm_add_close_handler(conn->fd, fwdServerClosedWrapper, this); + return; + } - if (paths[0]->_peer) - peerConnectSucceded(paths[0]->_peer); + if (Config.onoff.log_ip_on_direct && paths[0]->peer_type == HIER_DIRECT) + updateHierarchyInfo(); -#if USE_SSL + debugs(17, 3, "FD " << paths[0]->fd << ": '" << entry->url() << "'" ); - if ((paths[0]->_peer && paths[0]->_peer->use_ssl) || - (!paths[0]->_peer && request->protocol == PROTO_HTTPS)) { - initiateSSL(); - return; - } -#endif - dispatch(); + comm_add_close_handler(conn->fd, fwdServerClosedWrapper, this); + + if (paths[0]->_peer) + peerConnectSucceded(paths[0]->_peer); + +#if USE_SSL + if ((paths[0]->_peer && paths[0]->_peer->use_ssl) || + (!paths[0]->_peer && request->protocol == PROTO_HTTPS)) { + initiateSSL(); + return; } +#endif + + dispatch(); } void