]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
de-dupe httpsAccept and httpAccept. move EUI fields to Comm::Connection
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 5 Feb 2011 13:59:56 +0000 (02:59 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 5 Feb 2011 13:59:56 +0000 (02:59 +1300)
src/client_side.cc
src/client_side.h
src/comm/Connection.h

index 28c3f66f0c5e1a2a41f10ef7a082cf3fb536daf7..a98428121460c8eef669cb1de3339451e21b0624 100644 (file)
@@ -2491,8 +2491,8 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c
     setLogUri (http, urlCanonicalClean(request));
     request->client_addr = conn->clientConnection->remote; // XXX: remove reuest->client_addr member.
 #if USE_SQUID_EUI
-    request->client_eui48 = conn->peer_eui48;
-    request->client_eui64 = conn->peer_eui64;
+    request->client_eui48 = conn->clientConnection->remoteEui48;
+    request->client_eui64 = conn->clientConnection->remoteEui64;
 #endif
 #if FOLLOW_X_FORWARDED_FOR
     request->indirect_client_addr = conn->clientConnection->remote;
@@ -3088,19 +3088,44 @@ connStateCreate(const Comm::ConnectionPointer &client, http_port_list *port)
 #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT)
         int i = IP_PMTUDISC_DONT;
         setsockopt(client->fd, SOL_IP, IP_MTU_DISCOVER, &i, sizeof i);
-
 #else
-
         static int reported = 0;
 
         if (!reported) {
             debugs(33, 1, "Notice: httpd_accel_no_pmtu_disc not supported on your platform");
             reported = 1;
         }
+#endif
+    }
 
+    typedef CommCbMemFunT<ConnStateData, CommCloseCbParams> Dialer;
+    AsyncCall::Pointer call = JobCallback(33, 5, Dialer, result, ConnStateData::connStateClosed);
+    comm_add_close_handler(client->fd, call);
+
+    if (Config.onoff.log_fqdn)
+        fqdncache_gethostbyaddr(client->remote, FQDN_LOOKUP_IF_MISS);
+
+#if USE_IDENT
+    if (Ident::TheConfig.identLookup) {
+        ACLFilledChecklist identChecklist(Ident::TheConfig.identLookup, NULL, NULL);
+        identChecklist.src_addr = client->remote;
+        identChecklist.my_addr = client->local;
+        if (identChecklist.fastCheck())
+            Ident::Start(client, clientIdentDone, result);
+    }
 #endif
 
+#if USE_SQUID_EUI
+    if (Eui::TheConfig.euiLookup) {
+        if (client->remote.IsIPv4()) {
+            result->clientConnection->remoteEui48.lookup(client->remote);
+        } else if (client->remote.IsIPv6()) {
+            result->clientConnection->remoteEui64.lookup(client->remote);
+        }
     }
+#endif
+
+    clientdbEstablished(client->remote, 1);
 
     result->flags.readMoreRequests = true;
     return result;
@@ -3111,7 +3136,6 @@ void
 httpAccept(int, const Comm::ConnectionPointer &details, comm_err_t flag, int xerrno, void *data)
 {
     http_port_list *s = (http_port_list *)data;
-    ConnStateData *connState = NULL;
 
     if (flag != COMM_OK) {
         // Its possible the call was still queued when the client disconnected
@@ -3121,48 +3145,23 @@ httpAccept(int, const Comm::ConnectionPointer &details, comm_err_t flag, int xer
 
     debugs(33, 4, HERE << details << ": accepted");
     fd_note(details->fd, "client http connect");
-    connState = connStateCreate(details, s);
 
-    typedef CommCbMemFunT<ConnStateData, CommCloseCbParams> Dialer;
-    AsyncCall::Pointer call = JobCallback(33, 5, Dialer, connState, ConnStateData::connStateClosed);
-    comm_add_close_handler(details->fd, call);
+    if (s->tcp_keepalive.enabled) {
+        commSetTcpKeepalive(details->fd, s->tcp_keepalive.idle, s->tcp_keepalive.interval, s->tcp_keepalive.timeout);
+    }
 
-    if (Config.onoff.log_fqdn)
-        fqdncache_gethostbyaddr(details->remote, FQDN_LOOKUP_IF_MISS);
+    incoming_sockets_accepted++;
+
+    // Socket is ready, setup the connection manager to start using it
+    ConnStateData *connState = connStateCreate(details, s);
 
     typedef CommCbMemFunT<ConnStateData, CommTimeoutCbParams> TimeoutDialer;
     AsyncCall::Pointer timeoutCall =  JobCallback(33, 5,
                                       TimeoutDialer, connState, ConnStateData::requestTimeout);
     commSetConnTimeout(details, Config.Timeout.read, timeoutCall);
 
-#if USE_IDENT
-    if (Ident::TheConfig.identLookup) {
-        ACLFilledChecklist identChecklist(Ident::TheConfig.identLookup, NULL, NULL);
-        identChecklist.src_addr = details->remote;
-        identChecklist.my_addr = details->local;
-        if (identChecklist.fastCheck())
-            Ident::Start(details, clientIdentDone, connState);
-    }
-#endif
-
-#if USE_SQUID_EUI
-    if (Eui::TheConfig.euiLookup) {
-        if (details->remote.IsIPv4()) {
-            connState->peer_eui48.lookup(details->remote);
-        } else if (details->remote.IsIPv6()) {
-            connState->peer_eui64.lookup(details->remote);
-        }
-    }
-#endif
-
-    if (s->tcp_keepalive.enabled) {
-        commSetTcpKeepalive(details->fd, s->tcp_keepalive.idle, s->tcp_keepalive.interval, s->tcp_keepalive.timeout);
-    }
-
     connState->readSomeData();
 
-    clientdbEstablished(details->remote, 1);
-
 #if USE_DELAY_POOLS
     fd_table[newfd].clientInfo = NULL;
 
@@ -3203,7 +3202,6 @@ httpAccept(int, const Comm::ConnectionPointer &details, comm_err_t flag, int xer
         }
     }
 #endif
-    incoming_sockets_accepted++;
 }
 
 #if USE_SSL
@@ -3356,7 +3354,6 @@ static void
 httpsAccept(int, const Comm::ConnectionPointer& details, comm_err_t flag, int xerrno, void *data)
 {
     https_port_list *s = (https_port_list *)data;
-    SSL_CTX *sslContext = s->staticSslContext.get();
 
     if (flag != COMM_OK) {
         // Its possible the call was still queued when the client disconnected
@@ -3364,44 +3361,29 @@ httpsAccept(int, const Comm::ConnectionPointer& details, comm_err_t flag, int xe
         return;
     }
 
+    SSL_CTX *sslContext = s->staticSslContext.get();
     SSL *ssl = NULL;
     if (!(ssl = httpsCreate(details, sslContext)))
         return;
 
     debugs(33, 5, HERE << details << " accepted, starting SSL negotiation.");
     fd_note(details->fd, "client https connect");
-    ConnStateData *connState = connStateCreate(details, &s->http);
-    typedef CommCbMemFunT<ConnStateData, CommCloseCbParams> Dialer;
-    AsyncCall::Pointer call = JobCallback(33, 5, Dialer, connState, ConnStateData::connStateClosed);
-    comm_add_close_handler(details->fd, call);
 
-    if (Config.onoff.log_fqdn)
-        fqdncache_gethostbyaddr(details->remote, FQDN_LOOKUP_IF_MISS);
+    if (s->http.tcp_keepalive.enabled) {
+        commSetTcpKeepalive(details->fd, s->http.tcp_keepalive.idle, s->http.tcp_keepalive.interval, s->http.tcp_keepalive.timeout);
+    }
+
+    incoming_sockets_accepted++;
+
+    // Socket is ready, setup the connection manager to start using it
+    ConnStateData *connState = connStateCreate(details, &s->http);
 
     typedef CommCbMemFunT<ConnStateData, CommTimeoutCbParams> TimeoutDialer;
     AsyncCall::Pointer timeoutCall =  JobCallback(33, 5,
                                       TimeoutDialer, connState, ConnStateData::requestTimeout);
     commSetConnTimeout(details, Config.Timeout.request, timeoutCall);
 
-#if USE_IDENT
-    if (Ident::TheConfig.identLookup) {
-        ACLFilledChecklist identChecklist(Ident::TheConfig.identLookup, NULL, NULL);
-        identChecklist.src_addr = details->remote;
-        identChecklist.my_addr = details->local;
-        if (identChecklist.fastCheck())
-            Ident::Start(details, clientIdentDone, connState);
-    }
-#endif
-
-    if (s->http.tcp_keepalive.enabled) {
-        commSetTcpKeepalive(details->fd, s->http.tcp_keepalive.idle, s->http.tcp_keepalive.interval, s->http.tcp_keepalive.timeout);
-    }
-
     Comm::SetSelect(details->fd, COMM_SELECT_READ, clientNegotiateSSL, connState, 0);
-
-    clientdbEstablished(details->remote, 1);
-
-    incoming_sockets_accepted++;
 }
 
 void
index e128cb15db6de955c81fe427cb9ceaa93e579b5f..f02441c8db0e4b9c367fca2f8d7eec22331d8cef 100644 (file)
@@ -38,8 +38,6 @@
 #include "BodyPipe.h"
 #include "comm.h"
 #include "CommCalls.h"
-#include "eui/Eui48.h"
-#include "eui/Eui64.h"
 #include "HttpControlMsg.h"
 #include "RefCount.h"
 #include "StoreIOBuffer.h"
@@ -237,11 +235,6 @@ public:
     Ip::Address log_addr;
     int nrequests;
 
-#if USE_SQUID_EUI
-    Eui::Eui48 peer_eui48;
-    Eui::Eui64 peer_eui64;
-#endif
-
     struct {
         bool readMoreRequests;
         bool swanSang; // XXX: temporary flag to check proper cleanup
@@ -341,13 +334,15 @@ private:
 
 private:
     CBDATA_CLASS2(ConnStateData);
+    // XXX: CBDATA macro plays with public/private exposing all of the supposedly below private fields...
+
     bool transparent_; // AYJ: is this a duplicate of the transparent/intercept flags?
     bool closing_;
 
     bool switchedToHttps_;
     String sslHostName; ///< Host name for SSL certificate generation
     AsyncCall::Pointer reader; ///< set when we are reading
-    BodyPipe::Pointer bodyPipe; // set when we are reading request body
+    BodyPipe::Pointer bodyPipe; ///< set when we are reading request body
 };
 
 /* convenience class while splitting up body handling */
index d8a34279e991b2b9ce7c350da3c2255c94e26549..5b062158e9ab75374193f103fbbacbd31b528e2e 100644 (file)
 #include "ip/Address.h"
 #include "RefCount.h"
 #include "typedefs.h"
+#if USE_SQUID_EUI
+#include "eui/Eui48.h"
+#include "eui/Eui64.h"
+#endif
 
 #if HAVE_IOSFWD
 #include <iosfwd>
@@ -143,6 +147,11 @@ public:
 
     char rfc931[USER_IDENT_SZ];
 
+#if USE_SQUID_EUI
+    Eui::Eui48 remoteEui48;
+    Eui::Eui64 remoteEui64;
+#endif
+
 private:
     // XXX: we need to call this member peer_ but the struct peer_ global type
     //      behind peer* clashes despite our private Comm:: namespace