From: Eduard Bagdasaryan Date: Thu, 2 Jun 2022 20:27:48 +0000 (+0000) Subject: Maintenance: Reduce HTTP/FTP code duplication (#1060) X-Git-Tag: SQUID_6_0_1~175 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71ddbf2a11bea10d5ea86b281b6a65b68a70b8e9;p=thirdparty%2Fsquid.git Maintenance: Reduce HTTP/FTP code duplication (#1060) Removed code duplication probably caused bug fixed in commit 049eeeb. --- diff --git a/src/client_side.cc b/src/client_side.cc index 276170c052..e4ba88bc1d 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -3336,38 +3336,13 @@ clientHttpConnectionsOpen(void) continue; } - // Fill out a Comm::Connection which IPC will open as a listener for us - // then pass back when active so we can start a TcpAcceptor subscription. - s->listenConn = new Comm::Connection; - s->listenConn->local = s->s; - - s->listenConn->flags = COMM_NONBLOCKING | (s->flags.tproxyIntercept ? COMM_TRANSPARENT : 0) | - (s->flags.natIntercept ? COMM_INTERCEPTION : 0) | - (s->workerQueues ? COMM_REUSEPORT : 0); - - typedef CommCbFunPtrCallT AcceptCall; - if (s->transport.protocol == AnyP::PROTO_HTTP) { - // setup the subscriptions such that new connections accepted by listenConn are handled by HTTP - RefCount subCall = commCbCall(5, 5, "httpAccept", CommAcceptCbPtrFun(httpAccept, CommAcceptCbParams(NULL))); - Subscription::Pointer sub = new CallSubscription(subCall); - - AsyncCall::Pointer listenCall = asyncCall(33,2, "clientListenerConnectionOpened", - ListeningStartedDialer(&clientListenerConnectionOpened, s, Ipc::fdnHttpSocket, sub)); - Ipc::StartListening(SOCK_STREAM, IPPROTO_TCP, s->listenConn, Ipc::fdnHttpSocket, listenCall); - - } else if (s->transport.protocol == AnyP::PROTO_HTTPS) { - // setup the subscriptions such that new connections accepted by listenConn are handled by HTTPS - RefCount subCall = commCbCall(5, 5, "httpsAccept", CommAcceptCbPtrFun(httpsAccept, CommAcceptCbParams(NULL))); - Subscription::Pointer sub = new CallSubscription(subCall); - - AsyncCall::Pointer listenCall = asyncCall(33, 2, "clientListenerConnectionOpened", - ListeningStartedDialer(&clientListenerConnectionOpened, - s, Ipc::fdnHttpsSocket, sub)); - Ipc::StartListening(SOCK_STREAM, IPPROTO_TCP, s->listenConn, Ipc::fdnHttpsSocket, listenCall); - } - - HttpSockets[NHttpSockets] = -1; // set in clientListenerConnectionOpened - ++NHttpSockets; + const auto protocol = s->transport.protocol; + assert(protocol == AnyP::PROTO_HTTP || protocol == AnyP::PROTO_HTTPS); + const auto isHttps = protocol == AnyP::PROTO_HTTPS; + using AcceptCall = CommCbFunPtrCallT; + RefCount subCall = commCbCall(5, 5, isHttps ? "httpsAccept" : "httpAccept", + CommAcceptCbPtrFun(isHttps ? httpsAccept : httpAccept, CommAcceptCbParams(nullptr))); + clientStartListeningOn(s, subCall, isHttps ? Ipc::fdnHttpsSocket : Ipc::fdnHttpSocket); } }