From 73c36fd94272a1871ab925faba2fbc8bf6fe59a8 Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Wed, 2 Feb 2011 23:23:15 +1300 Subject: [PATCH] Move IDENT results into Connection data object. rename some ConnStateData fields --- src/acl/FilledChecklist.cc | 4 +- src/auth/UserRequest.cc | 2 +- src/client_side.cc | 250 ++++++++++++++++++------------------- src/client_side.h | 6 +- src/client_side_reply.cc | 36 +++--- src/client_side_request.cc | 34 ++--- src/comm/Connection.cc | 4 +- src/comm/Connection.h | 5 + src/external_acl.cc | 16 +-- src/ident/AclIdent.cc | 12 +- src/redirect.cc | 8 +- src/stat.cc | 14 +-- src/tunnel.cc | 4 +- 13 files changed, 196 insertions(+), 199 deletions(-) diff --git a/src/acl/FilledChecklist.cc b/src/acl/FilledChecklist.cc index a5c81d2cd4..56b7c55ad9 100644 --- a/src/acl/FilledChecklist.cc +++ b/src/acl/FilledChecklist.cc @@ -108,13 +108,13 @@ ACLFilledChecklist::conn(ConnStateData *aConn) int ACLFilledChecklist::fd() const { - return (conn_ != NULL && conn_->clientConn != NULL) ? conn_->clientConn->fd : fd_; + return (conn_ != NULL && conn_->clientConnection != NULL) ? conn_->clientConnection->fd : fd_; } void ACLFilledChecklist::fd(int aDescriptor) { - assert(!conn() || conn()->clientConn == NULL || conn()->clientConn->fd == aDescriptor); + assert(!conn() || conn()->clientConnection == NULL || conn()->clientConnection->fd == aDescriptor); fd_ = aDescriptor; } diff --git a/src/auth/UserRequest.cc b/src/auth/UserRequest.cc index 29815f9f37..bee0f7346d 100644 --- a/src/auth/UserRequest.cc +++ b/src/auth/UserRequest.cc @@ -343,7 +343,7 @@ AuthUserRequest::authenticate(AuthUserRequest::Pointer * auth_user_request, http if (*auth_user_request == NULL) { if (conn != NULL) { - debugs(29, 9, HERE << "This is a new checklist test on:" << conn->clientConn); + debugs(29, 9, HERE << "This is a new checklist test on:" << conn->clientConnection); } if (proxy_auth && request->auth_user_request == NULL && conn != NULL && conn->auth_user_request != NULL) { diff --git a/src/client_side.cc b/src/client_side.cc index 4af6a95818..28c3f66f0c 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -223,13 +223,6 @@ static void connNoteUseOfBuffer(ConnStateData* conn, size_t byteCount); static ConnStateData *connStateCreate(const Comm::ConnectionPointer &client, http_port_list *port); -const Comm::ConnectionPointer & -ClientSocketContext::clientConn() const -{ - assert (clientConnection != NULL); - return clientConnection; -} - clientStreamNode * ClientSocketContext::getTail() const { @@ -255,14 +248,14 @@ ConnStateData::readSomeData() if (reading()) return; - debugs(33, 4, "clientReadSomeData: FD " << clientConn->fd << ": reading request..."); + debugs(33, 4, HERE << clientConnection << ": reading request..."); if (!maybeMakeSpaceAvailable()) return; typedef CommCbMemFunT Dialer; reader = JobCallback(33, 5, Dialer, this, ConnStateData::clientReadRequest); - comm_read(clientConn, in.addressToReadInto(), getAvailableBufferLength(), reader); + comm_read(clientConnection, in.addressToReadInto(), getAvailableBufferLength(), reader); } @@ -380,7 +373,7 @@ ClientSocketContext::writeControlMsg(HttpControlMsg &msg) AsyncCall::Pointer call = commCbCall(33, 5, "ClientSocketContext::wroteControlMsg", CommIoCbPtrFun(&WroteControlMsg, this)); - Comm::Write(clientConn(), mb, call); + Comm::Write(clientConnection, mb, call); delete mb; } @@ -419,7 +412,7 @@ static void clientIdentDone(const char *ident, void *data) { ConnStateData *conn = (ConnStateData *)data; - xstrncpy(conn->rfc931, ident ? ident : dash_str, USER_IDENT_SZ); + xstrncpy(conn->clientConnection->rfc931, ident ? ident : dash_str, USER_IDENT_SZ); } #endif @@ -654,8 +647,8 @@ ClientHttpRequest::logRequest() if (request) prepareLogWithRequestDetails(request, &al); - if (getConn() != NULL && getConn()->rfc931[0]) - al.cache.rfc931 = getConn()->rfc931; + if (getConn() != NULL && getConn()->clientConnection != NULL && getConn()->clientConnection->rfc931[0]) + al.cache.rfc931 = getConn()->clientConnection->rfc931; #if USE_SSL && 0 @@ -678,8 +671,8 @@ ClientHttpRequest::logRequest() accessLogLog(&al, checklist); updateCounters(); - if (getConn() != NULL && getConn()->clientConn != NULL) - clientdbUpdate(getConn()->clientConn->remote, logType, PROTO_HTTP, out.size); + if (getConn() != NULL && getConn()->clientConnection != NULL) + clientdbUpdate(getConn()->clientConnection->remote, logType, PROTO_HTTP, out.size); } delete checklist; @@ -757,9 +750,9 @@ void ConnStateData::connStateClosed(const CommCloseCbParams &io) void ConnStateData::swanSong() { - debugs(33, 2, HERE << clientConn); + debugs(33, 2, HERE << clientConnection); flags.readMoreRequests = false; - clientdbEstablished(clientConn->remote, -1); /* decrement */ + clientdbEstablished(clientConnection->remote, -1); /* decrement */ assert(areAllContextsForThisConnection()); freeAllContexts(); @@ -768,13 +761,13 @@ ConnStateData::swanSong() auth_user_request->onConnectionClose(this); } - if (Comm::IsConnOpen(pinning.serverConn)) - pinning.serverConn->close(); - pinning.serverConn = NULL; + if (Comm::IsConnOpen(pinning.serverConnection)) + pinning.serverConnection->close(); + pinning.serverConnection = NULL; - if (Comm::IsConnOpen(clientConn)) - clientConn->close(); - clientConn = NULL; + if (Comm::IsConnOpen(clientConnection)) + clientConnection->close(); + clientConnection = NULL; BodyProducer::swanSong(); flags.swanSang = true; @@ -784,20 +777,20 @@ bool ConnStateData::isOpen() const { return cbdataReferenceValid(this) && // XXX: checking "this" in a method - Comm::IsConnOpen(clientConn) && - !fd_table[clientConn->fd].closing(); + Comm::IsConnOpen(clientConnection) && + !fd_table[clientConnection->fd].closing(); } ConnStateData::~ConnStateData() { assert(this != NULL); - debugs(33, 3, HERE << clientConn ); + debugs(33, 3, HERE << clientConnection); if (isOpen()) - debugs(33, 1, "BUG: ConnStateData did not close " << clientConn); + debugs(33, 1, "BUG: ConnStateData did not close " << clientConnection); if (!flags.swanSang) - debugs(33, 1, "BUG: ConnStateData was not destroyed properly; " << clientConn); + debugs(33, 1, "BUG: ConnStateData was not destroyed properly; " << clientConnection); cbdataReferenceDone(port); @@ -858,7 +851,7 @@ clientIsRequestBodyTooLargeForPolicy(int64_t bodyLength) bool connIsUsable(ConnStateData * conn) { - if (conn == NULL || !cbdataReferenceValid(conn) || !Comm::IsConnOpen(conn->clientConn)) + if (conn == NULL || !cbdataReferenceValid(conn) || !Comm::IsConnOpen(conn->clientConnection)) return false; return true; @@ -963,7 +956,7 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData) noteSentBodyBytes (length); AsyncCall::Pointer call = commCbCall(33, 5, "clientWriteBodyComplete", CommIoCbPtrFun(clientWriteBodyComplete, this)); - Comm::Write(clientConn(), bodyData.data, length, call, NULL); + Comm::Write(clientConnection, bodyData.data, length, call, NULL); return; } @@ -978,9 +971,9 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData) /* write */ AsyncCall::Pointer call = commCbCall(33, 5, "clientWriteComplete", CommIoCbPtrFun(clientWriteComplete, this)); - Comm::Write(clientConn(), &mb, call); + Comm::Write(clientConnection, &mb, call); } else - writeComplete(clientConn(), NULL, 0, COMM_OK); + writeComplete(clientConnection, NULL, 0, COMM_OK); } /** @@ -1381,7 +1374,7 @@ ClientSocketContext::sendStartOfMessage(HttpReply * rep, StoreIOBuffer bodyData) debugs(33,7, HERE << "sendStartOfMessage schedules clientWriteComplete"); AsyncCall::Pointer call = commCbCall(33, 5, "clientWriteComplete", CommIoCbPtrFun(clientWriteComplete, this)); - Comm::Write(clientConn(), mb, call); + Comm::Write(clientConnection, mb, call); delete mb; } @@ -1425,7 +1418,7 @@ clientSocketRecipient(clientStreamNode * node, ClientHttpRequest * http, const bool mustSendLastChunk = http->request->flags.chunked_reply && !http->request->flags.stream_error && !context->startOfOutput(); if (responseFinishedOrFailed(rep, receivedData) && !mustSendLastChunk) { - context->writeComplete(http->getConn()->clientConn, NULL, 0, COMM_OK); + context->writeComplete(context->clientConnection, NULL, 0, COMM_OK); PROF_stop(clientSocketRecipient); return; } @@ -1477,16 +1470,16 @@ clientWriteBodyComplete(const Comm::ConnectionPointer &conn, char *buf, size_t s void ConnStateData::readNextRequest() { - debugs(33, 5, HERE << clientConn << " reading next req"); + debugs(33, 5, HERE << clientConnection << " reading next req"); - fd_note(clientConn->fd, "Waiting for next request"); + fd_note(clientConnection->fd, "Waiting for next request"); /** * Set the timeout BEFORE calling clientReadRequest(). */ typedef CommCbMemFunT TimeoutDialer; AsyncCall::Pointer timeoutCall = JobCallback(33, 5, TimeoutDialer, this, ConnStateData::requestTimeout); - commSetConnTimeout(clientConn, Config.Timeout.persistent_request, timeoutCall); + commSetConnTimeout(clientConnection, Config.Timeout.persistent_request, timeoutCall); readSomeData(); /** Please don't do anything with the FD past here! */ @@ -1495,7 +1488,7 @@ ConnStateData::readNextRequest() static void ClientSocketContextPushDeferredIfNeeded(ClientSocketContext::Pointer deferredRequest, ConnStateData * conn) { - debugs(33, 2, HERE << conn->clientConn << " Sending next"); + debugs(33, 2, HERE << conn->clientConnection << " Sending next"); /** If the client stream is waiting on a socket write to occur, then */ @@ -1520,12 +1513,12 @@ ClientSocketContext::keepaliveNextRequest() ConnStateData * conn = http->getConn(); bool do_next_read = false; - debugs(33, 3, HERE << conn->clientConn); + debugs(33, 3, HERE << "ConnnStateData(" << conn->clientConnection << "), Context(" << clientConnection << ")"); connIsFinished(); - if (conn->pinning.pinned && !Comm::IsConnOpen(conn->pinning.serverConn)) { - debugs(33, 2, HERE << conn->clientConn << " Connection was pinned but server side gone. Terminating client connection"); - conn->clientConn->close(); + if (conn->pinning.pinned && !Comm::IsConnOpen(conn->pinning.serverConnection)) { + debugs(33, 2, HERE << conn->clientConnection << " Connection was pinned but server side gone. Terminating client connection"); + conn->clientConnection->close(); return; } @@ -1540,7 +1533,7 @@ ClientSocketContext::keepaliveNextRequest() */ if (clientParseRequest(conn, do_next_read)) { - debugs(33, 3, HERE << conn->clientConn << ": parsed next request from buffer"); + debugs(33, 3, HERE << conn->clientConnection << ": parsed next request from buffer"); } /** \par @@ -1550,9 +1543,9 @@ ClientSocketContext::keepaliveNextRequest() * half-closed _AND_ then, sometimes, spending "Timeout" time in * the keepalive "Waiting for next request" state. */ - if (commIsHalfClosed(conn->clientConn->fd) && (conn->getConcurrentRequestCount() == 0)) { + if (commIsHalfClosed(conn->clientConnection->fd) && (conn->getConcurrentRequestCount() == 0)) { debugs(33, 3, "ClientSocketContext::keepaliveNextRequest: half-closed client with no pending requests, closing"); - conn->clientConn->close(); + conn->clientConnection->close(); return; } @@ -1567,10 +1560,10 @@ ClientSocketContext::keepaliveNextRequest() */ if ((deferredRequest = conn->getCurrentContext()).getRaw()) { - debugs(33, 3, HERE << conn->clientConn << ": calling PushDeferredIfNeeded"); + debugs(33, 3, HERE << conn->clientConnection << ": calling PushDeferredIfNeeded"); ClientSocketContextPushDeferredIfNeeded(deferredRequest, conn); } else { - debugs(33, 3, HERE << conn->clientConn << ": calling conn->readNextRequest()"); + debugs(33, 3, HERE << conn->clientConnection << ": calling conn->readNextRequest()"); conn->readNextRequest(); } } @@ -1600,7 +1593,7 @@ ClientSocketContext::canPackMoreRanges() const /** first update iterator "i" if needed */ if (!http->range_iter.debt()) { - debugs(33, 5, "ClientSocketContext::canPackMoreRanges: At end of current range spec for FD " << clientConn()); + debugs(33, 5, HERE << "At end of current range spec for " << clientConnection); if (http->range_iter.pos.incrementable()) ++http->range_iter.pos; @@ -1658,7 +1651,7 @@ ClientSocketContext::getNextRangeOffset() const void ClientSocketContext::pullData() { - debugs(33, 5, HERE << clientConn() << " attempting to pull upstream data"); + debugs(33, 5, HERE << clientConnection << " attempting to pull upstream data"); /* More data will be coming from the stream. */ StoreIOBuffer readBuffer; @@ -1686,7 +1679,7 @@ ClientSocketContext::socketState() if (!canPackMoreRanges()) { debugs(33, 5, HERE << "Range request at end of returnable " << - "range sequence on " << clientConn()); + "range sequence on " << clientConnection); if (http->request->flags.proxy_keepalive) return STREAM_COMPLETE; @@ -1763,11 +1756,10 @@ ClientSocketContext::noteIoError(const int xerrno) } } - void ClientSocketContext::doClose() { - http->getConn()->clientConn->close(); + clientConnection->close(); } /** Called to initiate (and possibly complete) closing of the context. @@ -1869,7 +1861,7 @@ parseHttpRequestAbort(ConnStateData * csd, const char *uri) http->req_sz = csd->in.notYetUsed; http->uri = xstrdup(uri); setLogUri (http, uri); - context = ClientSocketContextNew(csd->clientConn, http); + context = ClientSocketContextNew(csd->clientConnection, http); tempBuffer.data = context->reqbuf; tempBuffer.length = HTTP_REQBUF_SZ; clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach, @@ -1992,16 +1984,16 @@ prepareAcceleratedURL(ConnStateData * conn, ClientHttpRequest *http, char *url, /* Put the local socket IP address as the hostname. */ int url_sz = strlen(url) + 32 + Config.appendDomainLen; http->uri = (char *)xcalloc(url_sz, 1); - http->getConn()->clientConn->local.ToHostname(ipbuf,MAX_IPSTRLEN); + http->getConn()->clientConnection->local.ToHostname(ipbuf,MAX_IPSTRLEN); snprintf(http->uri, url_sz, "%s://%s:%d%s", http->getConn()->port->protocol, - ipbuf, http->getConn()->clientConn->local.GetPort(), url); + ipbuf, http->getConn()->clientConnection->local.GetPort(), url); debugs(33, 5, "ACCEL VPORT REWRITE: '" << http->uri << "'"); } else if (vport > 0) { /* Put the local socket IP address as the hostname, but static port */ int url_sz = strlen(url) + 32 + Config.appendDomainLen; http->uri = (char *)xcalloc(url_sz, 1); - http->getConn()->clientConn->local.ToHostname(ipbuf,MAX_IPSTRLEN); + http->getConn()->clientConnection->local.ToHostname(ipbuf,MAX_IPSTRLEN); snprintf(http->uri, url_sz, "%s://%s:%d%s", http->getConn()->port->protocol, ipbuf, vport, url); @@ -2031,10 +2023,10 @@ prepareTransparentURL(ConnStateData * conn, ClientHttpRequest *http, char *url, /* Put the local socket IP address as the hostname. */ int url_sz = strlen(url) + 32 + Config.appendDomainLen; http->uri = (char *)xcalloc(url_sz, 1); - http->getConn()->clientConn->local.ToHostname(ipbuf,MAX_IPSTRLEN), + http->getConn()->clientConnection->local.ToHostname(ipbuf,MAX_IPSTRLEN), snprintf(http->uri, url_sz, "%s://%s:%d%s", http->getConn()->port->protocol, - ipbuf, http->getConn()->clientConn->local.GetPort(), url); + ipbuf, http->getConn()->clientConnection->local.GetPort(), url); debugs(33, 5, "TRANSPARENT REWRITE: '" << http->uri << "'"); } } @@ -2158,7 +2150,7 @@ parseHttpRequest(ConnStateData *csd, HttpParser *hp, HttpRequestMethod * method_ http = new ClientHttpRequest(csd); http->req_sz = HttpParserRequestLen(hp); - result = ClientSocketContextNew(csd->clientConn, http); + result = ClientSocketContextNew(csd->clientConnection, http); tempBuffer.data = result->reqbuf; tempBuffer.length = HTTP_REQBUF_SZ; @@ -2288,16 +2280,16 @@ int ConnStateData::connReadWasError(comm_err_t flag, int size, int xerrno) { if (flag != COMM_OK) { - debugs(33, 2, "connReadWasError: FD " << (clientConn!=NULL?clientConn->fd:-1) << ": got flag " << flag); + debugs(33, 2, "connReadWasError: FD " << clientConnection << ": got flag " << flag); return 1; } if (size < 0) { if (!ignoreErrno(xerrno)) { - debugs(33, 2, "connReadWasError: FD " << clientConn->fd << ": " << xstrerr(xerrno)); + debugs(33, 2, "connReadWasError: FD " << clientConnection << ": " << xstrerr(xerrno)); return 1; } else if (in.notYetUsed == 0) { - debugs(33, 2, "connReadWasError: FD " << clientConn->fd << ": no data to process (" << xstrerr(xerrno) << ")"); + debugs(33, 2, "connReadWasError: FD " << clientConnection << ": no data to process (" << xstrerr(xerrno) << ")"); } } @@ -2310,11 +2302,11 @@ ConnStateData::connFinishedWithConn(int size) if (size == 0) { if (getConcurrentRequestCount() == 0 && in.notYetUsed == 0) { /* no current or pending requests */ - debugs(33, 4, "connFinishedWithConn: FD " << clientConn->fd << " closed"); + debugs(33, 4, HERE << clientConnection << " closed"); return 1; } else if (!Config.onoff.half_closed_clients) { /* admin doesn't want to support half-closed client sockets */ - debugs(33, 3, "connFinishedWithConn: FD " << clientConn->fd << " aborted (half_closed_clients disabled)"); + debugs(33, 3, HERE << clientConnection << " aborted (half_closed_clients disabled)"); notifyAllContexts(0); // no specific error implies abort return 1; } @@ -2354,7 +2346,7 @@ ConnStateData::checkHeaderLimits() assert (repContext); repContext->setReplyToError(ERR_TOO_BIG, HTTP_BAD_REQUEST, METHOD_NONE, NULL, - clientConn->remote, NULL, NULL, NULL); + clientConnection->remote, NULL, NULL, NULL); context->registerWithConn(); context->pullData(); } @@ -2372,9 +2364,9 @@ void ConnStateData::clientAfterReadingRequests(int do_next_read) { // Were we expecting to read more request body from half-closed connection? - if (mayNeedToReadMoreBody() && commIsHalfClosed(clientConn->fd)) { - debugs(33, 3, HERE << "truncated body: closing half-closed " << clientConn); - clientConn->close(); + if (mayNeedToReadMoreBody() && commIsHalfClosed(clientConnection->fd)) { + debugs(33, 3, HERE << "truncated body: closing half-closed " << clientConnection); + clientConnection->close(); return; } @@ -2403,15 +2395,15 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c assert (repContext); switch (hp->request_parse_status) { case HTTP_HEADER_TOO_LARGE: - repContext->setReplyToError(ERR_TOO_BIG, HTTP_BAD_REQUEST, method, http->uri, conn->clientConn->remote, NULL, conn->in.buf, NULL); + repContext->setReplyToError(ERR_TOO_BIG, HTTP_BAD_REQUEST, method, http->uri, conn->clientConnection->remote, NULL, conn->in.buf, NULL); break; case HTTP_METHOD_NOT_ALLOWED: repContext->setReplyToError(ERR_UNSUP_REQ, HTTP_METHOD_NOT_ALLOWED, method, http->uri, - conn->clientConn->remote, NULL, conn->in.buf, NULL); + conn->clientConnection->remote, NULL, conn->in.buf, NULL); break; default: repContext->setReplyToError(ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, http->uri, - conn->clientConn->remote, NULL, conn->in.buf, NULL); + conn->clientConnection->remote, NULL, conn->in.buf, NULL); } assert(context->http->out.offset == 0); context->pullData(); @@ -2424,7 +2416,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c debugs(33, 5, "Invalid URL: " << http->uri); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); - repContext->setReplyToError(ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri, conn->clientConn->remote, NULL, NULL, NULL); + repContext->setReplyToError(ERR_INVALID_URL, HTTP_BAD_REQUEST, method, http->uri, conn->clientConnection->remote, NULL, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; @@ -2442,7 +2434,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); repContext->setReplyToError(ERR_UNSUP_HTTPVERSION, HTTP_HTTP_VERSION_NOT_SUPPORTED, method, http->uri, - conn->clientConn->remote, NULL, HttpParserHdrBuf(hp), NULL); + conn->clientConnection->remote, NULL, HttpParserHdrBuf(hp), NULL); assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; @@ -2457,7 +2449,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c debugs(33, 5, "Failed to parse request headers:\n" << HttpParserHdrBuf(hp)); clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); - repContext->setReplyToError(ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, http->uri, conn->clientConn->remote, NULL, NULL, NULL); + repContext->setReplyToError(ERR_INVALID_REQ, HTTP_BAD_REQUEST, method, http->uri, conn->clientConnection->remote, NULL, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; @@ -2497,15 +2489,15 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c request->flags.internal = http->flags.internal; setLogUri (http, urlCanonicalClean(request)); - request->client_addr = conn->clientConn->remote; // XXX: remove reuest->client_addr member. + 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; #endif #if FOLLOW_X_FORWARDED_FOR - request->indirect_client_addr = conn->clientConn->remote; + request->indirect_client_addr = conn->clientConnection->remote; #endif /* FOLLOW_X_FORWARDED_FOR */ - request->my_addr = conn->clientConn->local; + request->my_addr = conn->clientConnection->local; request->myportname = conn->port->name; request->http_ver = http_ver; @@ -2524,7 +2516,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); repContext->setReplyToError(ERR_UNSUP_REQ, HTTP_NOT_IMPLEMENTED, request->method, NULL, - conn->clientConn->remote, request, NULL, NULL); + conn->clientConnection->remote, request, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; @@ -2538,7 +2530,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c assert (repContext); repContext->setReplyToError(ERR_INVALID_REQ, HTTP_LENGTH_REQUIRED, request->method, NULL, - conn->clientConn->remote, request, NULL, NULL); + conn->clientConnection->remote, request, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; @@ -2553,7 +2545,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c clientReplyContext *repContext = dynamic_cast(node->data.getRaw()); assert (repContext); repContext->setReplyToError(ERR_INVALID_REQ, HTTP_EXPECTATION_FAILED, request->method, http->uri, - conn->clientConn->remote, request, NULL, NULL); + conn->clientConnection->remote, request, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); goto finish; @@ -2585,7 +2577,7 @@ clientProcessRequest(ConnStateData *conn, HttpParser *hp, ClientSocketContext *c assert (repContext); repContext->setReplyToError(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE, METHOD_NONE, NULL, - conn->clientConn->remote, http->request, NULL, NULL); + conn->clientConnection->remote, http->request, NULL, NULL); assert(context->http->out.offset == 0); context->pullData(); goto finish; @@ -2617,10 +2609,10 @@ finish: * be freed and the above connNoteUseOfBuffer() would hit an * assertion, not to mention that we were accessing freed memory. */ - if (http->request->flags.resetTCP() && Comm::IsConnOpen(conn->clientConn)) { - debugs(33, 3, HERE << "Sending TCP RST on " << conn->clientConn); + if (http->request->flags.resetTCP() && Comm::IsConnOpen(conn->clientConnection)) { + debugs(33, 3, HERE << "Sending TCP RST on " << conn->clientConnection); conn->flags.readMoreRequests = false; - comm_reset_close(conn->clientConn); + comm_reset_close(conn->clientConnection); return; } } @@ -2640,8 +2632,8 @@ connOkToAddRequest(ConnStateData * conn) int result = conn->getConcurrentRequestCount() < (Config.onoff.pipeline_prefetch ? 2 : 1); if (!result) { - debugs(33, 3, HERE << conn->clientConn << " max concurrent requests reached"); - debugs(33, 5, HERE << conn->clientConn << " defering new request until one is done"); + debugs(33, 3, HERE << conn->clientConnection << " max concurrent requests reached"); + debugs(33, 5, HERE << conn->clientConnection << " defering new request until one is done"); } return result; @@ -2663,7 +2655,7 @@ clientParseRequest(ConnStateData * conn, bool &do_next_read) HttpVersion http_ver; HttpParser hp; - debugs(33, 5, HERE << conn->clientConn << ": attempting to parse"); + debugs(33, 5, HERE << conn->clientConnection << ": attempting to parse"); // Loop while we have read bytes that are not needed for producing the body // On errors, bodyPipe may become nil, but readMoreRequests will be cleared @@ -2706,10 +2698,10 @@ clientParseRequest(ConnStateData * conn, bool &do_next_read) /* status -1 or 1 */ if (context) { - debugs(33, 5, HERE << conn->clientConn << ": parsed a request"); + debugs(33, 5, HERE << conn->clientConnection << ": parsed a request"); AsyncCall::Pointer timeoutCall = commCbCall(5, 4, "clientLifetimeTimeout", CommTimeoutCbPtrFun(clientLifetimeTimeout, context->http)); - commSetConnTimeout(conn->clientConn, Config.Timeout.lifetime, timeoutCall); + commSetConnTimeout(conn->clientConnection, Config.Timeout.lifetime, timeoutCall); clientProcessRequest(conn, &hp, context, method, http_ver); @@ -2743,8 +2735,8 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) return; } - assert(Comm::IsConnOpen(clientConn)); - assert(io.conn->fd == clientConn->fd); + assert(Comm::IsConnOpen(clientConnection)); + assert(io.conn->fd == clientConnection->fd); /* * Don't reset the timeout value here. The timeout value will be @@ -2771,7 +2763,7 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) debugs(33, 5, HERE << io.conn << " closed?"); if (connFinishedWithConn(io.size)) { - clientConn->close(); + clientConnection->close(); return; } @@ -2809,7 +2801,7 @@ ConnStateData::clientReadRequest(const CommIoCbParams &io) */ if (getConcurrentRequestCount() == 0 && commIsHalfClosed(io.fd)) { debugs(33, 5, HERE << io.conn << ": half-closed connection, no completed request parsed, connection closing."); - clientConn->close(); + clientConnection->close(); return; } } @@ -2864,7 +2856,7 @@ ConnStateData::handleRequestBodyData() return false; } } else { // identity encoding - debugs(33,5, HERE << "handling plain request body for " << clientConn); + debugs(33,5, HERE << "handling plain request body for " << clientConnection); putSize = bodyPipe->putMoreData(in.buf, in.notYetUsed); if (!bodyPipe->mayNeedMoreData()) { // BodyPipe will clear us automagically when we produced everything @@ -2876,13 +2868,13 @@ ConnStateData::handleRequestBodyData() connNoteUseOfBuffer(this, putSize); if (!bodyPipe) { - debugs(33,5, HERE << "produced entire request body for " << clientConn); + debugs(33,5, HERE << "produced entire request body for " << clientConnection); if (closing()) { /* we've finished reading like good clients, * now do the close that initiateClose initiated. */ - clientConn->close(); + clientConnection->close(); return false; } } @@ -2894,7 +2886,7 @@ ConnStateData::handleRequestBodyData() err_type ConnStateData::handleChunkedRequestBody(size_t &putSize) { - debugs(33,7, HERE << "chunked from " << clientConn << ": " << in.notYetUsed); + debugs(33,7, HERE << "chunked from " << clientConnection << ": " << in.notYetUsed); try { // the parser will throw on errors @@ -2962,11 +2954,11 @@ ConnStateData::abortChunkedRequestBody(const err_type error) context->pullData(); } else { // close or otherwise we may get stuck as nobody will notice the error? - comm_reset_close(clientConn); + comm_reset_close(clientConnection); } #else debugs(33, 3, HERE << "aborting chunked request without error " << error); - comm_reset_close(clientConn); + comm_reset_close(clientConnection); #endif flags.readMoreRequests = false; } @@ -3001,12 +2993,12 @@ ConnStateData::requestTimeout(const CommTimeoutCbParams &io) /* * Some data has been sent to the client, just close the FD */ - clientConn->close(); + clientConnection->close(); } else if (nrequests) { /* * assume its a persistent connection; just close it */ - clientConn->close(); + clientConnection->close(); } else { /* * Generate an error @@ -3074,7 +3066,7 @@ connStateCreate(const Comm::ConnectionPointer &client, http_port_list *port) { ConnStateData *result = new ConnStateData; - result->clientConn = client; + 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); @@ -3085,8 +3077,8 @@ connStateCreate(const Comm::ConnectionPointer &client, http_port_list *port) Ip::Address cl, dst; if (Ip::Interceptor.NatLookup(client->fd, client->local, client->remote, cl, dst) == 0) { - result->clientConn->local = cl; - result->clientConn->remote = dst; + result->clientConnection->local = cl; + result->clientConnection->remote = dst; result->transparent(true); } } @@ -3491,7 +3483,7 @@ ConnStateData::getSslContextDone(SSL_CTX * sslContext, bool isNew) if (sslContext && sslHostName != "") { if (!ssl_ctx_cache.add(sslHostName.termedBuf(), sslContext)) { // If it is not in storage delete after using. Else storage deleted it. - fd_table[clientConn->fd].dynamicSslContext = sslContext; + fd_table[clientConnection->fd].dynamicSslContext = sslContext; } } else { debugs(33, 2, HERE << "Failed to generate SSL cert for " << sslHostName); @@ -3501,8 +3493,8 @@ ConnStateData::getSslContextDone(SSL_CTX * sslContext, bool isNew) // If generated ssl context = NULL, try to use static ssl context. if (!sslContext) { if (!port->staticSslContext) { - debugs(83, 1, "Closing SSL " << clientConn->remote << " as lacking SSL context"); - clientConn->close(); + debugs(83, 1, "Closing SSL " << clientConnection->remote << " as lacking SSL context"); + clientConnection->close(); return false; } else { debugs(33, 5, HERE << "Using static ssl context."); @@ -3511,14 +3503,14 @@ ConnStateData::getSslContextDone(SSL_CTX * sslContext, bool isNew) } SSL *ssl = NULL; - if (!(ssl = httpsCreate(clientConn, sslContext))) + if (!(ssl = httpsCreate(clientConnection, sslContext))) return false; // commSetConnTimeout() was called for this request before we switched. // Disable the client read handler until peer selection is complete - Comm::SetSelect(clientConn->fd, COMM_SELECT_READ, NULL, NULL, 0); - Comm::SetSelect(clientConn->fd, COMM_SELECT_READ, clientNegotiateSSL, this, 0); + Comm::SetSelect(clientConnection->fd, COMM_SELECT_READ, NULL, NULL, 0); + Comm::SetSelect(clientConnection->fd, COMM_SELECT_READ, clientNegotiateSSL, this, 0); switchedToHttps_ = true; return true; } @@ -3535,7 +3527,7 @@ ConnStateData::switchToHttps(const char *host) freeAllContexts(); //currentobject->connIsFinished(); - debugs(33, 5, HERE << "converting " << clientConn << " to SSL"); + debugs(33, 5, HERE << "converting " << clientConnection << " to SSL"); return getSslContextStart(); } @@ -3544,9 +3536,9 @@ ConnStateData::switchToHttps(const char *host) /// check FD after clientHttp[s]ConnectionOpened, adjust HttpSockets as needed static bool -OpenedHttpSocket(const Comm::ConnectionPointer &clientConn, const Ipc::FdNoteId portType) +OpenedHttpSocket(const Comm::ConnectionPointer &c, const Ipc::FdNoteId portType) { - if (!Comm::IsConnOpen(clientConn)) { + if (!Comm::IsConnOpen(c)) { Must(NHttpSockets > 0); // we tried to open some --NHttpSockets; // there will be fewer sockets than planned Must(HttpSockets[NHttpSockets] < 0); // no extra fds received @@ -3802,7 +3794,7 @@ clientAclChecklistCreate(const acl_access * acl, ClientHttpRequest * http) { ConnStateData * conn = http->getConn(); ACLFilledChecklist *ch = new ACLFilledChecklist(acl, http->request, - cbdataReferenceValid(conn) && conn != NULL ? conn->rfc931 : dash_str); + cbdataReferenceValid(conn) && conn != NULL && conn->clientConnection != NULL ? conn->clientConnection->rfc931 : dash_str); /* * hack for ident ACL. It needs to get full addresses, and a place to store @@ -3856,7 +3848,7 @@ void ConnStateData::stopReading() { if (reading()) { - comm_read_cancel(clientConn->fd, reader); + comm_read_cancel(clientConnection->fd, reader); reader = NULL; } } @@ -3984,7 +3976,7 @@ ConnStateData::sendControlMsg(HttpControlMsg msg) } debugs(33, 3, HERE << " closing due to missing context for 1xx"); - clientConn->close(); + clientConnection->close(); } /* This is a comm call normally scheduled by comm_close() */ @@ -3995,20 +3987,20 @@ ConnStateData::clientPinnedConnectionClosed(const CommCloseCbParams &io) } void -ConnStateData::pinConnection(const Comm::ConnectionPointer &pinServerConn, HttpRequest *request, struct peer *aPeer, bool auth) +ConnStateData::pinConnection(const Comm::ConnectionPointer &pinServer, HttpRequest *request, struct peer *aPeer, bool auth) { char desc[FD_DESC_SZ]; - if (Comm::IsConnOpen(pinning.serverConn)) { - if (pinning.serverConn->fd == pinServerConn->fd) + if (Comm::IsConnOpen(pinning.serverConnection)) { + if (pinning.serverConnection->fd == pinServer->fd) return; unpinConnection(); // clears fields ready for re-use. Prevent close() scheduling our close handler. - pinning.serverConn->close(); + pinning.serverConnection->close(); } else unpinConnection(); // clears fields ready for re-use. - pinning.serverConn = pinServerConn; + pinning.serverConnection = pinServer; pinning.host = xstrdup(request->GetHost()); pinning.port = request->port; pinning.pinned = true; @@ -4017,20 +4009,20 @@ ConnStateData::pinConnection(const Comm::ConnectionPointer &pinServerConn, HttpR pinning.auth = auth; char stmp[MAX_IPSTRLEN]; snprintf(desc, FD_DESC_SZ, "%s pinned connection for %s (%d)", - (auth || !aPeer) ? request->GetHost() : aPeer->name, clientConn->remote.ToURL(stmp,MAX_IPSTRLEN), clientConn->fd); - fd_note(pinning.serverConn->fd, desc); + (auth || !aPeer) ? request->GetHost() : aPeer->name, clientConnection->remote.ToURL(stmp,MAX_IPSTRLEN), clientConnection->fd); + fd_note(pinning.serverConnection->fd, desc); typedef CommCbMemFunT Dialer; pinning.closeHandler = JobCallback(33, 5, Dialer, this, ConnStateData::clientPinnedConnectionClosed); - comm_add_close_handler(pinning.serverConn->fd, pinning.closeHandler); + comm_add_close_handler(pinning.serverConnection->fd, pinning.closeHandler); } const Comm::ConnectionPointer ConnStateData::validatePinnedConnection(HttpRequest *request, const struct peer *aPeer) { bool valid = true; - if (!Comm::IsConnOpen(pinning.serverConn)) + if (!Comm::IsConnOpen(pinning.serverConnection)) valid = false; if (pinning.auth && request && strcasecmp(pinning.host, request->GetHost()) != 0) { valid = false; @@ -4052,11 +4044,11 @@ ConnStateData::validatePinnedConnection(HttpRequest *request, const struct peer /* also close the server side socket, we should not use it for invalid/unauthenticated requests... */ - if (Comm::IsConnOpen(pinning.serverConn)) - pinning.serverConn->close(); + if (Comm::IsConnOpen(pinning.serverConnection)) + pinning.serverConnection->close(); } - return pinning.serverConn; + return pinning.serverConnection; } void @@ -4066,7 +4058,7 @@ ConnStateData::unpinConnection() cbdataReferenceDone(pinning.peer); if (pinning.closeHandler != NULL) { - comm_remove_close_handler(pinning.serverConn->fd, pinning.closeHandler); + comm_remove_close_handler(pinning.serverConnection->fd, pinning.closeHandler); pinning.closeHandler = NULL; } diff --git a/src/client_side.h b/src/client_side.h index b3042a6548..e128cb15db 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -130,7 +130,6 @@ public: size_t lengthToSend(Range const &available); void noteSentBodyBytes(size_t); void buildRangeHeader(HttpReply * rep); - const Comm::ConnectionPointer & clientConn() const; clientStreamNode * getTail() const; clientStreamNode * getClientReplyContext() const; void connIsFinished(); @@ -202,7 +201,7 @@ public: virtual void sendControlMsg(HttpControlMsg msg); // Client TCP connection details from comm layer. - Comm::ConnectionPointer clientConn; + Comm::ConnectionPointer clientConnection; struct In { In(); @@ -236,7 +235,6 @@ public: ClientSocketContext::Pointer currentobject; Ip::Address log_addr; - char rfc931[USER_IDENT_SZ]; int nrequests; #if USE_SQUID_EUI @@ -249,7 +247,7 @@ public: bool swanSang; // XXX: temporary flag to check proper cleanup } flags; struct { - Comm::ConnectionPointer serverConn; /* pinned server side connection */ + Comm::ConnectionPointer serverConnection; /* pinned server side connection */ char *host; /* host name of pinned connection */ int port; /* port of pinned connection */ bool pinned; /* this connection was pinned */ diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 1d6141a99e..11162361b5 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -262,13 +262,13 @@ clientReplyContext::processExpired() http->storeEntry(entry); assert(http->out.offset == 0); - http->request->clientConnection = http->getConn(); + http->request->clientConnection = http->getConn(); // AYJ: irrelevant? /* * A refcounted pointer so that FwdState stays around as long as * this clientReplyContext does */ - Comm::ConnectionPointer conn = http->getConn() != NULL ? http->getConn()->clientConn : NULL; + Comm::ConnectionPointer conn = http->getConn() != NULL ? http->getConn()->clientConnection : NULL; FwdState::fwdStart(conn, http->storeEntry(), http->request); /* Register with storage manager to receive updates when data comes in. */ @@ -624,7 +624,7 @@ clientReplyContext::processMiss() if (r->flags.loopdetect && (http->flags.accel || http->flags.intercepted)) { http->al.http.code = HTTP_FORBIDDEN; - err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->clientConn->remote, http->request); + err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->clientConnection->remote, http->request); createStoreEntry(r->method, request_flags()); errorAppendEntry(http->storeEntry(), err); triggerInitialStoreRead(); @@ -655,7 +655,7 @@ clientReplyContext::processMiss() r->clientConnection = http->getConn(); /** Start forwarding to get the new object from network */ - Comm::ConnectionPointer conn = http->getConn() != NULL ? http->getConn()->clientConn : NULL; + Comm::ConnectionPointer conn = http->getConn() != NULL ? http->getConn()->clientConnection : NULL; FwdState::fwdStart(conn, http->storeEntry(), r); } } @@ -673,7 +673,7 @@ clientReplyContext::processOnlyIfCachedMiss() RequestMethodStr(http->request->method) << " " << http->uri << "'"); http->al.http.code = HTTP_GATEWAY_TIMEOUT; ErrorState *err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, HTTP_GATEWAY_TIMEOUT, NULL, - http->getConn()->clientConn->remote, http->request); + http->getConn()->clientConnection->remote, http->request); removeClientStoreReference(&sc, http); startError(err); } @@ -840,7 +840,7 @@ clientReplyContext::purgeFoundObject(StoreEntry *entry) if (EBIT_TEST(entry->flags, ENTRY_SPECIAL)) { http->logType = LOG_TCP_DENIED; ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, - http->getConn()->clientConn->remote, http->request); + http->getConn()->clientConnection->remote, http->request); startError(err); return; } @@ -878,7 +878,7 @@ clientReplyContext::purgeRequest() if (!Config2.onoff.enable_purge) { http->logType = LOG_TCP_DENIED; - ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->clientConn->remote, http->request); + ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->clientConnection->remote, http->request); startError(err); return; } @@ -1724,11 +1724,11 @@ clientReplyContext::doGetMoreData() assert(http->out.offset == 0); if (Ip::Qos::TheConfig.isHitTosActive()) { - Ip::Qos::doTosLocalHit(http->getConn()->clientConn); + Ip::Qos::doTosLocalHit(http->getConn()->clientConnection); } if (Ip::Qos::TheConfig.isHitNfmarkActive()) { - Ip::Qos::doNfmarkLocalHit(http->getConn()->clientConn); + Ip::Qos::doNfmarkLocalHit(http->getConn()->clientConnection); } localTempBuffer.offset = reqofs; @@ -1829,7 +1829,7 @@ clientReplyContext::sendBodyTooLargeError() tmp_noaddr.SetNoAddr(); // TODO: make a global const http->logType = LOG_TCP_DENIED_REPLY; ErrorState *err = clientBuildError(ERR_TOO_BIG, HTTP_FORBIDDEN, NULL, - http->getConn() != NULL ? http->getConn()->clientConn->remote : tmp_noaddr, + http->getConn() != NULL ? http->getConn()->clientConnection->remote : tmp_noaddr, http->request); removeClientStoreReference(&(sc), http); HTTPMSGUNLOCK(reply); @@ -1844,7 +1844,7 @@ clientReplyContext::sendPreconditionFailedError() http->logType = LOG_TCP_HIT; ErrorState *const err = clientBuildError(ERR_PRECONDITION_FAILED, HTTP_PRECONDITION_FAILED, - NULL, http->getConn()->clientConn->remote, http->request); + NULL, http->getConn()->clientConnection->remote, http->request); removeClientStoreReference(&sc, http); HTTPMSGUNLOCK(reply); startError(err); @@ -1951,7 +1951,7 @@ clientReplyContext::processReplyAccessResult(bool accessAllowed) Ip::Address tmp_noaddr; tmp_noaddr.SetNoAddr(); err = clientBuildError(page_id, HTTP_FORBIDDEN, NULL, - http->getConn() != NULL ? http->getConn()->clientConn->remote : tmp_noaddr, + http->getConn() != NULL ? http->getConn()->clientConnection->remote : tmp_noaddr, http->request); removeClientStoreReference(&sc, http); @@ -2038,10 +2038,10 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) ConnStateData * conn = http->getConn(); // AYJ: this seems a bit weird to ignore CLOSED but drop on closing. - if (conn != NULL && Comm::IsConnOpen(conn->clientConn) && fd_table[conn->clientConn->fd].closing()) { + if (conn != NULL && Comm::IsConnOpen(conn->clientConnection) && fd_table[conn->clientConnection->fd].closing()) { // too late, our conn is closing // TODO: should we also quit? - debugs(33,3, HERE << "not sending more data to a closing " << conn->clientConn); + debugs(33,3, HERE << "not sending more data to a closing " << conn->clientConnection); return; } @@ -2056,12 +2056,12 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) body_buf = buf; } - if (reqofs==0 && !logTypeIsATcpHit(http->logType) && Comm::IsConnOpen(conn->clientConn)) { + if (reqofs==0 && !logTypeIsATcpHit(http->logType) && Comm::IsConnOpen(conn->clientConnection)) { if (Ip::Qos::TheConfig.isHitTosActive()) { - Ip::Qos::doTosLocalMiss(conn->clientConn, http->request->hier.code); + Ip::Qos::doTosLocalMiss(conn->clientConnection, http->request->hier.code); } if (Ip::Qos::TheConfig.isHitNfmarkActive()) { - Ip::Qos::doNfmarkLocalMiss(conn->clientConn, http->request->hier.code); + Ip::Qos::doNfmarkLocalMiss(conn->clientConnection, http->request->hier.code); } } @@ -2084,7 +2084,7 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) reqofs << " bytes (" << result.length << " new bytes)"); debugs(88, 5, "clientReplyContext::sendMoreData:" - << conn->clientConn << + << conn->clientConnection << " '" << entry->url() << "'" << " out.offset=" << http->out.offset); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 4a31bbc26b..4d4d540a8d 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -167,7 +167,7 @@ ClientHttpRequest::ClientHttpRequest(ConnStateData * aConn) : { start_time = current_time; setConn(aConn); - clientConnection = aConn->clientConn; + clientConnection = aConn->clientConnection; dlinkAdd(this, &active, &ClientActiveRequests); #if USE_ADAPTATION request_satisfaction_mode = false; @@ -631,7 +631,7 @@ ClientRequestContext::clientAccessCheckDone(int answer) tmpnoaddr.SetNoAddr(); repContext->setReplyToError(page_id, status, http->request->method, NULL, - http->getConn() != NULL ? http->getConn()->clientConn->remote : tmpnoaddr, + http->getConn() != NULL ? http->getConn()->clientConnection->remote : tmpnoaddr, http->request, NULL, http->getConn() != NULL && http->getConn()->auth_user_request != NULL ? @@ -672,10 +672,10 @@ ClientRequestContext::adaptationAclCheckDone(Adaptation::ServiceGroupPointer g) Adaptation::Icap::History::Pointer ih = http->request->icapHistory(); if (ih != NULL) { if (http->getConn() != NULL) { - ih->rfc931 = http->getConn()->rfc931; + ih->rfc931 = http->getConn()->clientConnection->rfc931; #if USE_SSL - assert(http->getConn()->clientConn != NULL); - ih->ssluser = sslGetUserEmail(fd_table[http->getConn()->clientConn->fd].ssl); + assert(http->getConn()->clientConnection != NULL); + ih->ssluser = sslGetUserEmail(fd_table[http->getConn()->clientConnection->fd].ssl); #endif } ih->log_uri = http->log_uri; @@ -784,7 +784,7 @@ clientCheckPinning(ClientHttpRequest * http) request->flags.connection_auth_disabled = http_conn->port->connection_auth_disabled; if (!request->flags.connection_auth_disabled) { - if (Comm::IsConnOpen(http_conn->pinning.serverConn)) { + if (Comm::IsConnOpen(http_conn->pinning.serverConnection)) { if (http_conn->pinning.auth) { request->flags.connection_auth = 1; request->flags.auth = 1; @@ -1061,8 +1061,8 @@ ClientRequestContext::clientRedirectDone(char *result) /* FIXME PIPELINE: This is innacurate during pipelining */ - if (http->getConn() != NULL && Comm::IsConnOpen(http->getConn()->clientConn)) - fd_note(http->getConn()->clientConn->fd, http->uri); + if (http->getConn() != NULL && Comm::IsConnOpen(http->getConn()->clientConnection)) + fd_note(http->getConn()->clientConnection->fd, http->uri); assert(http->uri); @@ -1191,15 +1191,15 @@ ClientHttpRequest::sslBumpEstablish(comm_err_t errflag) void ClientHttpRequest::sslBumpStart() { - debugs(85, 5, HERE << "Confirming CONNECT tunnel on FD " << getConn()->clientConn); + debugs(85, 5, HERE << "Confirming CONNECT tunnel on FD " << getConn()->clientConnection); // send an HTTP 200 response to kick client SSL negotiation - debugs(33, 7, HERE << "Confirming CONNECT tunnel on FD " << getConn()->clientConn); + debugs(33, 7, HERE << "Confirming CONNECT tunnel on FD " << getConn()->clientConnection); // TODO: Unify with tunnel.cc and add a Server(?) header static const char *const conn_established = "HTTP/1.1 200 Connection established\r\n\r\n"; AsyncCall::Pointer call = commCbCall(85, 5, "ClientSocketContext::sslBumpEstablish", CommIoCbPtrFun(&SslBumpEstablish, this)); - Comm::Write(getConn()->clientConn, conn_established, strlen(conn_established), call, NULL); + Comm::Write(getConn()->clientConnection, conn_established, strlen(conn_established), call, NULL); } #endif @@ -1334,25 +1334,25 @@ ClientHttpRequest::doCallouts() if (!calloutContext->tosToClientDone) { calloutContext->tosToClientDone = true; - if (getConn() != NULL && Comm::IsConnOpen(getConn()->clientConn)) { + if (getConn() != NULL && Comm::IsConnOpen(getConn()->clientConnection)) { ACLFilledChecklist ch(NULL, request, NULL); ch.src_addr = request->client_addr; ch.my_addr = request->my_addr; tos_t tos = aclMapTOS(Ip::Qos::TheConfig.tosToClient, &ch); if (tos) - Ip::Qos::setSockTos(getConn()->clientConn, tos); + Ip::Qos::setSockTos(getConn()->clientConnection, tos); } } if (!calloutContext->nfmarkToClientDone) { calloutContext->nfmarkToClientDone = true; - if (getConn() != NULL && Comm::IsConnOpen(getConn()->clientConn)) { + if (getConn() != NULL && Comm::IsConnOpen(getConn()->clientConnection)) { ACLFilledChecklist ch(NULL, request, NULL); ch.src_addr = request->client_addr; ch.my_addr = request->my_addr; nfmark_t mark = aclMapNfmark(Ip::Qos::TheConfig.nfmarkToClient, &ch); if (mark) - Ip::Qos::setSockNfmark(getConn()->clientConn, mark); + Ip::Qos::setSockNfmark(getConn()->clientConnection, mark); } } @@ -1507,7 +1507,7 @@ ClientHttpRequest::noteBodyProducerAborted(BodyPipe::Pointer) debugs(85,3, HERE << "REQMOD body production failed"); if (request_satisfaction_mode) { // too late to recover or serve an error request->detailError(ERR_ICAP_FAILURE, ERR_DETAIL_CLT_REQMOD_RESP_BODY); - const Comm::ConnectionPointer c = getConn()->clientConn; + const Comm::ConnectionPointer c = getConn()->clientConnection; Must(Comm::IsConnOpen(c)); c->close(); // drastic, but we may be writing a response already } else { @@ -1545,7 +1545,7 @@ ClientHttpRequest::handleAdaptationFailure(int errDetail, bool bypassable) ConnStateData * c = getConn(); repContext->setReplyToError(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request->method, NULL, - (c != NULL ? c->clientConn->remote : noAddr), request, NULL, + (c != NULL ? c->clientConnection->remote : noAddr), request, NULL, (c != NULL && c->auth_user_request != NULL ? c->auth_user_request : request->auth_user_request)); diff --git a/src/comm/Connection.cc b/src/comm/Connection.cc index 8a2a04b04a..51b1711267 100644 --- a/src/comm/Connection.cc +++ b/src/comm/Connection.cc @@ -19,7 +19,9 @@ Comm::Connection::Connection() : tos(0), flags(COMM_NONBLOCKING), _peer(NULL) -{} +{ + *rfc931 = 0; // quick init the head. the rest does not matter. +} static int64_t lost_conn = 0; Comm::Connection::~Connection() diff --git a/src/comm/Connection.h b/src/comm/Connection.h index 50155e40ad..d8a34279e9 100644 --- a/src/comm/Connection.h +++ b/src/comm/Connection.h @@ -141,6 +141,8 @@ public: /** COMM flags set on this connection */ int flags; + char rfc931[USER_IDENT_SZ]; + private: // XXX: we need to call this member peer_ but the struct peer_ global type // behind peer* clashes despite our private Comm:: namespace @@ -162,6 +164,9 @@ operator << (std::ostream &os, const Comm::Connection &conn) { os << "FD " << conn.fd << " local=" << conn.local << " remote=" << conn.remote << " flags=" << conn.flags; +#if USE_IDENT + os << " IDENT::" << conn.rfc931; +#endif return os; } diff --git a/src/external_acl.cc b/src/external_acl.cc index b4006bc3c2..86665cf336 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -996,8 +996,8 @@ makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data) case _external_acl_format::EXT_ACL_USER_CERT_RAW: - if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConn)) { - SSL *ssl = fd_table[ch->conn()->clientConn->fd].ssl; + if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConnection)) { + SSL *ssl = fd_table[ch->conn()->clientConnection->fd].ssl; if (ssl) str = sslGetUserCertificatePEM(ssl); @@ -1007,8 +1007,8 @@ makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data) case _external_acl_format::EXT_ACL_USER_CERTCHAIN_RAW: - if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConn)) { - SSL *ssl = fd_table[ch->conn()->clientConn->fd].ssl; + if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConnection)) { + SSL *ssl = fd_table[ch->conn()->clientConnection->fd].ssl; if (ssl) str = sslGetUserCertificateChainPEM(ssl); @@ -1018,8 +1018,8 @@ makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data) case _external_acl_format::EXT_ACL_USER_CERT: - if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConn)) { - SSL *ssl = fd_table[ch->conn()->clientConn->fd].ssl; + if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConnection)) { + SSL *ssl = fd_table[ch->conn()->clientConnection->fd].ssl; if (ssl) str = sslGetUserAttribute(ssl, format->header); @@ -1029,8 +1029,8 @@ makeExternalAclKey(ACLFilledChecklist * ch, external_acl_data * acl_data) case _external_acl_format::EXT_ACL_CA_CERT: - if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConn)) { - SSL *ssl = fd_table[ch->conn()->clientConn->fd].ssl; + if (ch->conn() != NULL && Comm::IsConnOpen(ch->conn()->clientConnection)) { + SSL *ssl = fd_table[ch->conn()->clientConnection->fd].ssl; if (ssl) str = sslGetCAAttribute(ssl, format->header); diff --git a/src/ident/AclIdent.cc b/src/ident/AclIdent.cc index ee26394a5d..c5ddb176d0 100644 --- a/src/ident/AclIdent.cc +++ b/src/ident/AclIdent.cc @@ -87,8 +87,8 @@ ACLIdent::match(ACLChecklist *cl) ACLFilledChecklist *checklist = Filled(cl); if (checklist->rfc931[0]) { return data->match(checklist->rfc931); - } else if (checklist->conn() != NULL && checklist->conn()->rfc931[0]) { - return data->match(checklist->conn()->rfc931); + } else if (checklist->conn() != NULL && checklist->conn()->clientConnection != NULL && checklist->conn()->clientConnection->rfc931[0]) { + return data->match(checklist->conn()->clientConnection->rfc931); } else { debugs(28, 3, HERE << "switching to ident lookup state"); checklist->changeState(IdentLookup::Instance()); @@ -127,10 +127,10 @@ void IdentLookup::checkForAsync(ACLChecklist *cl)const { ACLFilledChecklist *checklist = Filled(cl); - if (checklist->conn() != NULL) { + if (checklist->conn() != NULL && Comm::IsConnOpen(checklist->conn()->clientConnection)) { debugs(28, 3, HERE << "Doing ident lookup" ); checklist->asyncInProgress(true); - Ident::Start(checklist->conn()->clientConn, LookupDone, checklist); + Ident::Start(checklist->conn()->clientConnection, LookupDone, checklist); } else { debugs(28, DBG_IMPORTANT, "IdentLookup::checkForAsync: Can't start ident lookup. No client connection" ); checklist->currentAnswer(ACCESS_DENIED); @@ -154,8 +154,8 @@ IdentLookup::LookupDone(const char *ident, void *data) * Cache the ident result in the connection, to avoid redoing ident lookup * over and over on persistent connections */ - if (checklist->conn() != NULL && !checklist->conn()->rfc931[0]) - xstrncpy(checklist->conn()->rfc931, checklist->rfc931, USER_IDENT_SZ); + if (checklist->conn() != NULL && checklist->conn()->clientConnection != NULL && !checklist->conn()->clientConnection->rfc931[0]) + xstrncpy(checklist->conn()->clientConnection->rfc931, checklist->rfc931, USER_IDENT_SZ); checklist->asyncInProgress(false); checklist->changeState(ACLChecklist::NullState::Instance()); diff --git a/src/redirect.cc b/src/redirect.cc index 5dc30b236a..a3cafe26c1 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -146,13 +146,13 @@ redirectStart(ClientHttpRequest * http, RH * handler, void *data) r->client_ident = http->request->extacl_user.termedBuf(); } - if (!r->client_ident && (conn != NULL && conn->rfc931[0])) - r->client_ident = conn->rfc931; + if (!r->client_ident && conn != NULL && conn->clientConnection != NULL && conn->clientConnection->rfc931[0]) + r->client_ident = conn->clientConnection->rfc931; #if USE_SSL - if (!r->client_ident && conn != NULL && Comm::IsConnOpen(conn->clientConn)) - r->client_ident = sslGetUserEmail(fd_table[conn->clientConn->fd].ssl); + if (!r->client_ident && conn != NULL && Comm::IsConnOpen(conn->clientConnection)) + r->client_ident = sslGetUserEmail(fd_table[conn->clientConnection->fd].ssl); #endif diff --git a/src/stat.cc b/src/stat.cc index 83c3c69186..a4fe88811e 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -2020,16 +2020,16 @@ statClientRequests(StoreEntry * s) storeAppendPrintf(s, "Connection: %p\n", conn); if (conn != NULL) { - const int fd = conn->clientConn->fd; + const int fd = conn->clientConnection->fd; storeAppendPrintf(s, "\tFD %d, read %"PRId64", wrote %"PRId64"\n", fd, fd_table[fd].bytes_read, fd_table[fd].bytes_written); storeAppendPrintf(s, "\tFD desc: %s\n", fd_table[fd].desc); storeAppendPrintf(s, "\tin: buf %p, offset %ld, size %ld\n", conn->in.buf, (long int) conn->in.notYetUsed, (long int) conn->in.allocatedSize); storeAppendPrintf(s, "\tremote: %s\n", - conn->clientConn->remote.ToURL(buf,MAX_IPSTRLEN)); + conn->clientConnection->remote.ToURL(buf,MAX_IPSTRLEN)); storeAppendPrintf(s, "\tlocal: %s\n", - conn->clientConn->local.ToURL(buf,MAX_IPSTRLEN)); + conn->clientConnection->local.ToURL(buf,MAX_IPSTRLEN)); storeAppendPrintf(s, "\tnrequests: %d\n", conn->nrequests); } @@ -2058,13 +2058,13 @@ statClientRequests(StoreEntry * s) p = http->request->extacl_user.termedBuf(); } - if (!p && (conn != NULL && conn->rfc931[0])) - p = conn->rfc931; + if (!p && conn != NULL && conn->clientConnection->rfc931[0]) + p = conn->clientConnection->rfc931; #if USE_SSL - if (!p && conn != NULL && Comm::IsConnOpen(conn->clientConn)) - p = sslGetUserEmail(fd_table[conn->clientConn->fd].ssl); + if (!p && conn != NULL && Comm::IsConnOpen(conn->clientConnection)) + p = sslGetUserEmail(fd_table[conn->clientConnection->fd].ssl); #endif diff --git a/src/tunnel.cc b/src/tunnel.cc index ed10495368..f5173c678c 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -616,7 +616,7 @@ tunnelStart(ClientHttpRequest * http, int64_t * size_ptr, int *status_ptr) if (answer == 0) { err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN, request); *status_ptr = HTTP_FORBIDDEN; - errorSend(http->getConn()->clientConn, err); + errorSend(http->getConn()->clientConnection, err); return; } } @@ -633,7 +633,7 @@ tunnelStart(ClientHttpRequest * http, int64_t * size_ptr, int *status_ptr) tunnelState->request = HTTPMSGLOCK(request); tunnelState->server.size_ptr = size_ptr; tunnelState->status_ptr = status_ptr; - tunnelState->client.conn = http->getConn()->clientConn; + tunnelState->client.conn = http->getConn()->clientConnection; comm_add_close_handler(tunnelState->client.conn->fd, tunnelClientClosed, -- 2.47.2