=== modified file 'src/CommCalls.cc' --- src/CommCalls.cc 2012-08-28 13:00:30 +0000 +++ src/CommCalls.cc 2013-06-09 12:04:13 +0000 @@ -7,12 +7,12 @@ /* CommCommonCbParams */ CommCommonCbParams::CommCommonCbParams(void *aData): - data(cbdataReference(aData)), conn(), flag(COMM_OK), xerrno(0), fd(-1) + data(cbdataReference(aData)), conn(), flag(COMM_OK), xerrno(0), fd(-1), xaction() { } CommCommonCbParams::CommCommonCbParams(const CommCommonCbParams &p): - data(cbdataReference(p.data)), conn(p.conn), flag(p.flag), xerrno(p.xerrno), fd(p.fd) + data(cbdataReference(p.data)), conn(p.conn), flag(p.flag), xerrno(p.xerrno), fd(p.fd), xaction(p.xaction) { } @@ -35,6 +35,9 @@ os << ", flag=" << flag; if (data) os << ", data=" << data; + + if (xaction != NULL) + os << ", " << xaction->id; } /* CommAcceptCbParams */ === modified file 'src/CommCalls.h' --- src/CommCalls.h 2013-01-02 23:40:49 +0000 +++ src/CommCalls.h 2013-06-09 12:04:33 +0000 @@ -5,6 +5,7 @@ #include "base/AsyncJobCalls.h" #include "comm_err_t.h" #include "comm/forward.h" +#include "MasterXaction.h" /* CommCalls implement AsyncCall interface for comm_* callbacks. * The classes cover two call dialer kinds: @@ -79,6 +80,10 @@ int xerrno; ///< The last errno to occur. non-zero if flag is COMM_ERR. int fd; ///< FD which the call was about. Set by the async call creator. + + /// Transaction which this call is part of. + MasterXaction::Pointer xaction; + private: // should not be needed and not yet implemented CommCommonCbParams &operator =(const CommCommonCbParams ¶ms); === modified file 'src/Makefile.am' --- src/Makefile.am 2013-06-07 04:35:25 +0000 +++ src/Makefile.am 2013-06-07 04:41:21 +0000 @@ -422,6 +422,8 @@ LogTags.h \ lookup_t.h \ main.cc \ + MasterXaction.cc \ + MasterXaction.h \ Mem.h \ mem.cc \ mem_node.cc \ @@ -1251,6 +1253,8 @@ HttpRequestMethod.cc \ int.h \ int.cc \ + MasterXaction.cc \ + MasterXaction.h \ SquidList.h \ SquidList.cc \ mem_node.cc \ @@ -1488,6 +1492,8 @@ internal.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ multicast.h \ multicast.cc \ mem_node.cc \ @@ -1668,6 +1674,8 @@ int.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ MemBuf.cc \ MemObject.cc \ mem_node.cc \ @@ -1904,6 +1912,8 @@ internal.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ Mem.h \ mem.cc \ mem_node.cc \ @@ -2152,6 +2162,8 @@ internal.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ MemBlob.cc \ MemBuf.cc \ MemObject.cc \ @@ -2397,6 +2409,8 @@ ipcache.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ MemBlob.cc \ MemBuf.cc \ MemObject.cc \ @@ -2687,6 +2701,8 @@ internal.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ multicast.h \ multicast.cc \ mem_node.cc \ @@ -2860,6 +2876,8 @@ int.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ Mem.h \ mem.cc \ mem_node.cc \ @@ -3085,6 +3103,8 @@ RequestFlags.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ MemObject.cc \ StoreSwapLogData.cc \ StoreIOState.cc \ @@ -3271,6 +3291,8 @@ int.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ Mem.h \ mem.cc \ MemBuf.cc \ @@ -3655,6 +3677,8 @@ internal.cc \ SquidList.h \ SquidList.cc \ + MasterXaction.cc \ + MasterXaction.h \ multicast.h \ multicast.cc \ Mem.h \ === modified file 'src/anyp/Makefile.am' --- src/anyp/Makefile.am 2013-01-28 13:24:51 +0000 +++ src/anyp/Makefile.am 2013-06-07 04:41:21 +0000 @@ -4,6 +4,7 @@ noinst_LTLIBRARIES = libanyp.la libanyp_la_SOURCES = \ + forward.h \ PortCfg.cc \ PortCfg.h \ ProtocolType.cc \ === modified file 'src/anyp/PortCfg.h' --- src/anyp/PortCfg.h 2013-02-10 16:31:40 +0000 +++ src/anyp/PortCfg.h 2013-06-07 04:41:21 +0000 @@ -1,8 +1,8 @@ #ifndef SQUID_ANYP_PORTCFG_H #define SQUID_ANYP_PORTCFG_H +#include "anyp/forward.h" #include "anyp/TrafficMode.h" -#include "cbdata.h" #include "comm/Connection.h" #if USE_SSL === added file 'src/anyp/forward.h' --- src/anyp/forward.h 1970-01-01 00:00:00 +0000 +++ src/anyp/forward.h 2013-06-07 04:16:20 +0000 @@ -0,0 +1,15 @@ +#ifndef _SQUID_SRC_ANYP_FORWARD_H +#define _SQUID_SRC_ANYP_FORWARD_H + +#include "base/CbcPointer.h" + +namespace AnyP +{ + +class PortCfg; +typedef CbcPointer PortCfgPointer; + +} // namespace AnyP + +#endif /* _SQUID_SRC_ANYP_FORWARD_H */ + === modified file 'src/client_side.cc' --- src/client_side.cc 2013-06-07 08:49:36 +0000 +++ src/client_side.cc 2013-06-09 12:19:09 +0000 @@ -245,8 +245,6 @@ char *skipLeadingSpace(char *aString); static void connNoteUseOfBuffer(ConnStateData* conn, size_t byteCount); -static ConnStateData *connStateCreate(const Comm::ConnectionPointer &client, AnyP::PortCfg *port); - clientStreamNode * ClientSocketContext::getTail() const { @@ -3330,23 +3328,37 @@ io.conn->close(); } -ConnStateData * -connStateCreate(const Comm::ConnectionPointer &client, AnyP::PortCfg *port) +ConnStateData::ConnStateData(const MasterXaction::Pointer &xact) : + AsyncJob("ConnStateData"), +#if USE_SSL + sslBumpMode(Ssl::bumpEnd), + switchedToHttps_(false), + sslServerBump(NULL), +#endif + stoppedSending_(NULL), + stoppedReceiving_(NULL) { - ConnStateData *result = new ConnStateData; - - result->clientConnection = client; - result->log_addr = client->remote; - result->log_addr.applyMask(Config.Addrs.client_netmask); - result->in.buf = (char *)memAllocBuf(CLIENT_REQ_BUF_SZ, &result->in.allocatedSize); - result->port = cbdataReference(port); + pinning.host = NULL; + pinning.port = -1; + pinning.pinned = false; + pinning.auth = false; + pinning.zeroReply = false; + pinning.peer = NULL; + + // store the details required for creating more MasterXaction objects as new requests come in + clientConnection = xact->tcpClient; + port = cbdataReference(xact->squidPort.get()); + log_addr = xact->tcpClient->remote; + log_addr.applyMask(Config.Addrs.client_netmask); + + in.buf = (char *)memAllocBuf(CLIENT_REQ_BUF_SZ, &in.allocatedSize); if (port->disable_pmtu_discovery != DISABLE_PMTU_OFF && - (result->transparent() || port->disable_pmtu_discovery == DISABLE_PMTU_ALWAYS)) { + (transparent() || port->disable_pmtu_discovery == DISABLE_PMTU_ALWAYS)) { #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT) int i = IP_PMTUDISC_DONT; - if (setsockopt(client->fd, SOL_IP, IP_MTU_DISCOVER, &i, sizeof(i)) < 0) - debugs(33, 2, "WARNING: Path MTU discovery disabling failed on " << client << " : " << xstrerror()); + if (setsockopt(clientConnection->fd, SOL_IP, IP_MTU_DISCOVER, &i, sizeof(i)) < 0) + debugs(33, 2, "WARNING: Path MTU discovery disabling failed on " << clientConnection << " : " << xstrerror()); #else static bool reported = false; @@ -3358,33 +3370,33 @@ } typedef CommCbMemFunT Dialer; - AsyncCall::Pointer call = JobCallback(33, 5, Dialer, result, ConnStateData::connStateClosed); - comm_add_close_handler(client->fd, call); + AsyncCall::Pointer call = JobCallback(33, 5, Dialer, this, ConnStateData::connStateClosed); + comm_add_close_handler(clientConnection->fd, call); if (Config.onoff.log_fqdn) - fqdncache_gethostbyaddr(client->remote, FQDN_LOOKUP_IF_MISS); + fqdncache_gethostbyaddr(clientConnection->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; + identChecklist.src_addr = xact->tcpClient->remote; + identChecklist.my_addr = xact->tcpClient->local; if (identChecklist.fastCheck() == ACCESS_ALLOWED) - Ident::Start(client, clientIdentDone, result); + Ident::Start(xact->tcpClient, clientIdentDone, this); } #endif - clientdbEstablished(client->remote, 1); + clientdbEstablished(clientConnection->remote, 1); - result->flags.readMore = true; - return result; + flags.readMore = true; } /** Handle a new connection on HTTP socket. */ void httpAccept(const CommAcceptCbParams ¶ms) { - AnyP::PortCfg *s = static_cast(params.data); + MasterXaction::Pointer xact = params.xaction; + AnyP::PortCfgPointer s = xact->squidPort; if (params.flag != COMM_OK) { // Its possible the call was still queued when the client disconnected @@ -3402,7 +3414,7 @@ ++ incoming_sockets_accepted; // Socket is ready, setup the connection manager to start using it - ConnStateData *connState = connStateCreate(params.conn, s); + ConnStateData *connState = new ConnStateData(xact); typedef CommCbMemFunT TimeoutDialer; AsyncCall::Pointer timeoutCall = JobCallback(33, 5, @@ -3651,7 +3663,7 @@ /** * A callback function to use with the ACLFilledChecklist callback. - * In the case of ACCES_ALLOWED answer initializes a bumped SSL connection, + * In the case of ACCESS_ALLOWED answer initializes a bumped SSL connection, * else reverts the connection to tunnel mode. */ static void @@ -3693,7 +3705,9 @@ static void httpsAccept(const CommAcceptCbParams ¶ms) { - AnyP::PortCfg *s = static_cast(params.data); + MasterXaction::Pointer xact = params.xaction; + const AnyP::PortCfgPointer s = xact->squidPort; + assert(s.valid()); if (params.flag != COMM_OK) { // Its possible the call was still queued when the client disconnected @@ -3711,7 +3725,7 @@ ++incoming_sockets_accepted; // Socket is ready, setup the connection manager to start using it - ConnStateData *connState = connStateCreate(params.conn, s); + ConnStateData *connState = new ConnStateData(xact); if (s->flags.tunnelSslBumping) { debugs(33, 5, "httpsAccept: accept transparent connection: " << params.conn); @@ -4310,24 +4324,6 @@ CBDATA_CLASS_INIT(ConnStateData); -ConnStateData::ConnStateData() : - AsyncJob("ConnStateData"), -#if USE_SSL - sslBumpMode(Ssl::bumpEnd), - switchedToHttps_(false), - sslServerBump(NULL), -#endif - stoppedSending_(NULL), - stoppedReceiving_(NULL) -{ - pinning.host = NULL; - pinning.port = -1; - pinning.pinned = false; - pinning.auth = false; - pinning.zeroReply = false; - pinning.peer = NULL; -} - bool ConnStateData::transparent() const { === modified file 'src/client_side.h' --- src/client_side.h 2013-05-30 14:58:49 +0000 +++ src/client_side.h 2013-06-09 12:09:06 +0000 @@ -187,8 +187,7 @@ { public: - - ConnStateData(); + explicit ConnStateData(const MasterXaction::Pointer &xact); ~ConnStateData(); void readSomeData(); @@ -255,13 +254,14 @@ */ ClientSocketContext::Pointer currentobject; - Ip::Address log_addr; + Ip::Address log_addr; // TODO: remove entirely and produce masked IP on demand. int nrequests; struct { bool readMore; ///< needs comm_read (for this request or new requests) bool swanSang; // XXX: temporary flag to check proper cleanup } flags; + struct { Comm::ConnectionPointer serverConnection; /* pinned server side connection */ char *host; /* host name of pinned connection */ @@ -273,6 +273,7 @@ AsyncCall::Pointer closeHandler; /*The close handler for pinned server side connection*/ } pinning; + // Squid listening port details where this connection arrived. AnyP::PortCfg *port; bool transparent() const; === modified file 'src/comm/TcpAcceptor.cc' --- src/comm/TcpAcceptor.cc 2013-06-03 14:05:16 +0000 +++ src/comm/TcpAcceptor.cc 2013-06-07 04:41:21 +0000 @@ -33,6 +33,7 @@ */ #include "squid.h" +#include "anyp/PortCfg.h" #include "base/TextException.h" #include "client_db.h" #include "comm/AcceptLimiter.h" @@ -46,6 +47,7 @@ #include "fde.h" #include "globals.h" #include "ip/Intercept.h" +#include "MasterXaction.h" #include "profiler/Profiler.h" #include "SquidConfig.h" #include "SquidTime.h" @@ -286,8 +288,10 @@ if (theCallSub != NULL) { AsyncCall::Pointer call = theCallSub->callback(); CommAcceptCbParams ¶ms = GetCommParams(call); + params.xaction = new MasterXaction; + params.xaction->squidPort = static_cast(params.data); params.fd = conn->fd; - params.conn = newConnDetails; + params.conn = params.xaction->tcpClient = newConnDetails; params.flag = flag; params.xerrno = errcode; ScheduleCallHere(call);