From: robertc <> Date: Thu, 10 Jul 2003 17:04:06 +0000 (+0000) Subject: Summary: Refactoring: ClientHttpRequest. X-Git-Tag: SQUID_3_0_PRE1~46 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9824206900d1fbbd6c5ae64d40176307215f8151;p=thirdparty%2Fsquid.git Summary: Refactoring: ClientHttpRequest. Keywords: * Self encapsulation ClientHttpRequest::conn. --- diff --git a/src/DelayId.cc b/src/DelayId.cc index be3ea7685f..0f2d76f0d5 100644 --- a/src/DelayId.cc +++ b/src/DelayId.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayId.cc,v 1.10 2003/05/20 12:17:38 robertc Exp $ + * $Id: DelayId.cc,v 1.11 2003/07/10 11:04:06 robertc Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -109,8 +109,8 @@ DelayId::DelayClient(clientHttpRequest * http) ch.my_addr = r->my_addr; ch.my_port = r->my_port; - if (http->conn) - ch.conn(cbdataReference(http->conn)); + if (http->getConn()) + ch.conn(cbdataReference(http->getConn())); ch.request = requestLink(r); diff --git a/src/client_side.cc b/src/client_side.cc index c5c6687316..36ae3b620a 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.646 2003/07/06 21:50:55 hno Exp $ + * $Id: client_side.cc,v 1.647 2003/07/10 11:04:06 robertc Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -191,8 +191,8 @@ int ClientSocketContext::fd() const { assert (http); - assert (http->conn); - return http->conn->fd; + assert (http->getConn()); + return http->getConn()->fd; } clientStreamNode * @@ -283,16 +283,16 @@ ClientSocketContext::registerWithConn() { assert (!connRegistered_); assert (http); - assert (http->conn); + assert (http->getConn()); connRegistered_ = true; - http->conn->addContextToQueue(this); + http->getConn()->addContextToQueue(this); } void ClientSocketContext::deRegisterWithConn() { assert (connRegistered_); - removeFromConnectionList(http->conn); + removeFromConnectionList(http->getConn()); connRegistered_ = false; } @@ -300,7 +300,7 @@ void ClientSocketContext::connIsFinished() { assert (http); - assert (http->conn); + assert (http->getConn()); deRegisterWithConn(); /* we can't handle any more stream data - detach */ clientStreamDetach(getTail(), http); @@ -510,7 +510,7 @@ ClientHttpRequest::logRequest() al.http.content_type = memObject()->getReply()->content_type.buf(); } - al.cache.caddr = conn ? conn->log_addr : no_addr; + al.cache.caddr = getConn() ? getConn()->log_addr : no_addr; al.cache.size = out.size; al.cache.code = logType; al.cache.msec = tvSubMsec(start, current_time); @@ -518,13 +518,13 @@ ClientHttpRequest::logRequest() if (request) clientPrepareLogWithRequestDetails(request, &al); - if (conn && conn->rfc931[0]) - al.cache.rfc931 = conn->rfc931; + if (getConn() && getConn()->rfc931[0]) + al.cache.rfc931 = getConn()->rfc931; #if USE_SSL - if (conn) - al.cache.ssluser = sslGetUserEmail(fd_table[conn->fd].ssl); + if (getConn()) + al.cache.ssluser = sslGetUserEmail(fd_table[getConn()->fd].ssl); #endif @@ -537,8 +537,8 @@ ClientHttpRequest::logRequest() accessLogLog(&al, checklist); updateCounters(); - if (conn) - clientdbUpdate(conn->peer.sin_addr, logType, PROTO_HTTP, out.size); + if (getConn()) + clientdbUpdate(getConn()->peer.sin_addr, logType, PROTO_HTTP, out.size); } delete checklist; @@ -576,7 +576,7 @@ ConnStateData::areAllContextsForThisConnection() const ClientSocketContext::Pointer context = getCurrentContext(); while (context.getRaw()) { - if (context->http->conn != this) + if (context->http->getConn() != this) return false; context = context->next; @@ -1198,11 +1198,11 @@ clientSocketRecipient(clientStreamNode * node, clientHttpRequest * http, assert(node->node.next == NULL); ClientSocketContext::Pointer context = dynamic_cast(node->data.getRaw()); assert(context.getRaw() != NULL); - assert(connIsUsable(http->conn)); - fd = http->conn->fd; + assert(connIsUsable(http->getConn())); + fd = http->getConn()->fd; /* TODO: check offset is what we asked for */ - if (context != http->conn->getCurrentContext()) { + if (context != http->getConn()->getCurrentContext()) { context->deferRecipientForLater(node, rep, recievedData); return; } @@ -1290,7 +1290,7 @@ ClientSocketContextPushDeferredIfNeeded(ClientSocketContext::Pointer deferredReq void ClientSocketContext::keepaliveNextRequest() { - ConnStateData *conn = http->conn; + ConnStateData *conn = http->getConn(); debug(33, 3) ("ClientSocketContext::keepaliveNextRequest: FD %d\n", conn->fd); connIsFinished(); @@ -1491,7 +1491,7 @@ parseHttpRequestAbort(ConnStateData * conn, const char *uri) ClientSocketContext *context; StoreIOBuffer tempBuffer; http = new ClientHttpRequest; - http->conn = conn; + http->setConn(conn); http->req_sz = conn->in.notYetUsed; http->uri = xstrdup(uri); setLogUri (http, uri); @@ -1699,17 +1699,17 @@ prepareAcceleratedURL(ConnStateData * conn, clientHttpRequest *http, char *url, int url_sz = strlen(url) + 32 + Config.appendDomainLen; http->uri = (char *)xcalloc(url_sz, 1); snprintf(http->uri, url_sz, "%s://%s:%d%s", - http->conn->port->protocol, - inet_ntoa(http->conn->me.sin_addr), - ntohs(http->conn->me.sin_port), url); + http->getConn()->port->protocol, + inet_ntoa(http->getConn()->me.sin_addr), + ntohs(http->getConn()->me.sin_port), url); debug(33, 5) ("ACCEL VPORT REWRITE: '%s'\n", 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); snprintf(http->uri, url_sz, "%s://%s:%d%s", - http->conn->port->protocol, - inet_ntoa(http->conn->me.sin_addr), + http->getConn()->port->protocol, + inet_ntoa(http->getConn()->me.sin_addr), vport, url); debug(33, 5) ("ACCEL VPORT REWRITE: '%s'\n", http->uri); } @@ -1743,9 +1743,9 @@ prepareTransparentURL(ConnStateData * conn, clientHttpRequest *http, char *url, int url_sz = strlen(url) + 32 + Config.appendDomainLen; http->uri = (char *)xcalloc(url_sz, 1); snprintf(http->uri, url_sz, "%s://%s:%d%s", - http->conn->port->protocol, - inet_ntoa(http->conn->me.sin_addr), - ntohs(http->conn->me.sin_port), url); + http->getConn()->port->protocol, + inet_ntoa(http->getConn()->me.sin_addr), + ntohs(http->getConn()->me.sin_port), url); debug(33, 5) ("TRANSPARENT REWRITE: '%s'\n", http->uri); } } @@ -1855,7 +1855,7 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, http->http_ver = http_ver; - http->conn = conn; + http->setConn(conn); http->req_sz = prefix_sz; @@ -2062,7 +2062,7 @@ clientAfterReadingRequests(int fd, ConnStateData *conn, int do_next_read) if (conn->in.notYetUsed != conn->body.size_left) { /* != 0 when no request body */ /* Partial request received. Abort client connection! */ - debug(33, 3) ("clientAfterReadingRequests: FD %d aborted, partial request\n",+ fd); + debug(33, 3) ("clientAfterReadingRequests: FD %d aborted, partial request\n", fd); comm_close(fd); return; } @@ -2610,7 +2610,7 @@ static void clientLifetimeTimeout(int fd, void *data) { clientHttpRequest *http = (clientHttpRequest *)data; - ConnStateData *conn = http->conn; + ConnStateData *conn = http->getConn(); debug(33, 1) ("WARNING: Closing client %s connection due to lifetime timeout\n", inet_ntoa(conn->peer.sin_addr)); @@ -3017,10 +3017,10 @@ varyEvaluateMatch(StoreEntry * entry, request_t * request) } ACLChecklist * -clientAclChecklistCreate(const acl_access * acl, const clientHttpRequest * http) +clientAclChecklistCreate(const acl_access * acl, clientHttpRequest * http) { ACLChecklist *ch; - ConnStateData *conn = http->conn; + ConnStateData *conn = http->getConn(); ch = aclChecklistCreate(acl, http->request, conn ? conn->rfc931 : dash_str); /* diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index f82e9c8b56..054da41c3b 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.56 2003/07/06 21:50:56 hno Exp $ + * $Id: client_side_reply.cc,v 1.57 2003/07/10 11:04:06 robertc Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -268,7 +268,7 @@ clientReplyContext::processExpired() (long int) entry->lastmod); http->storeEntry(entry); assert(http->out.offset == 0); - fwdStart(http->conn ? http->conn->fd : -1, http->storeEntry(), http->request); + fwdStart(http->getConn() ? http->getConn()->fd : -1, http->storeEntry(), http->request); /* Register with storage manager to receive updates when data comes in. */ if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) @@ -805,7 +805,7 @@ clientReplyContext::processMiss() http->al.http.code = HTTP_FORBIDDEN; err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, - &http->conn->peer.sin_addr, http->request); + &http->getConn()->peer.sin_addr, http->request); createStoreEntry(r->method, request_flags()); errorAppendEntry(http->storeEntry(), err); triggerInitialStoreRead(); @@ -833,7 +833,7 @@ clientReplyContext::processMiss() if (http->flags.internal) r->protocol = PROTO_INTERNAL; - fwdStart(http->conn ? http->conn->fd : -1, http->storeEntry(), r); + fwdStart(http->getConn() ? http->getConn()->fd : -1, http->storeEntry(), r); } } @@ -851,7 +851,7 @@ clientReplyContext::processOnlyIfCachedMiss() RequestMethodStr[http->request->method], http->uri); http->al.http.code = HTTP_GATEWAY_TIMEOUT; err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, HTTP_GATEWAY_TIMEOUT, NULL, - &http->conn->peer.sin_addr, http->request); + &http->getConn()->peer.sin_addr, http->request); removeClientStoreReference(&sc, http); startError(err); } @@ -929,7 +929,7 @@ clientReplyContext::purgeRequest() http->logType = LOG_TCP_DENIED; ErrorState *err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, - &http->conn->peer.sin_addr, http->request); + &http->getConn()->peer.sin_addr, http->request); startError(err); return; } @@ -1146,7 +1146,7 @@ clientHttpRequestStatus(int fd, clientHttpRequest const *http) debug(88, 1) ("WARNING: closing FD %d to prevent counter overflow\n", fd); debug(88, 1) ("\tclient %s\n", - inet_ntoa(http->conn ? http->conn->peer.sin_addr : no_addr)); + inet_ntoa(http->getConn() ? http->getConn()->peer.sin_addr : no_addr)); debug(88, 1) ("\treceived %d bytes\n", (int) http->out.size); debug(88, 1) ("\tURI %s\n", http->log_uri); return 1; @@ -1158,7 +1158,7 @@ clientHttpRequestStatus(int fd, clientHttpRequest const *http) debug(88, 1) ("WARNING: closing FD %d to prevent counter overflow\n", fd); debug(88, 1) ("\tclient %s\n", - inet_ntoa(http->conn ? http->conn->peer.sin_addr : no_addr)); + inet_ntoa(http->getConn() ? http->getConn()->peer.sin_addr : no_addr)); debug(88, 1) ("\treceived %d bytes (offset %d)\n", (int) http->out.size, (int) http->out.offset); debug(88, 1) ("\tURI %s\n", http->log_uri); @@ -1859,7 +1859,7 @@ clientReplyContext::processReplyAccess () if (http->isReplyBodyTooLarge(rep->content_length)) { ErrorState *err = clientBuildError(ERR_TOO_BIG, HTTP_FORBIDDEN, NULL, - http->conn ? &http->conn->peer.sin_addr : &no_addr, + http->getConn() ? &http->getConn()->peer.sin_addr : &no_addr, http->request); removeClientStoreReference(&sc, http); startError(err); @@ -1900,7 +1900,7 @@ clientReplyContext::processReplyAccessResult(bool accessAllowed) ErrorState *err; err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, - http->conn ? &http->conn->peer.sin_addr : &no_addr, + http->getConn() ? &http->getConn()->peer.sin_addr : &no_addr, http->request); removeClientStoreReference(&sc, http); startError(err); @@ -1967,7 +1967,7 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) StoreEntry *entry = http->storeEntry(); - ConnStateData *conn = http->conn; + ConnStateData *conn = http->getConn(); int fd = conn ? conn->fd : -1; diff --git a/src/client_side_request.cc b/src/client_side_request.cc index ed122aae68..04a221dcb1 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.25 2003/07/06 21:43:36 hno Exp $ + * $Id: client_side_request.cc,v 1.26 2003/07/10 11:04:06 robertc Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -293,7 +293,7 @@ clientBeginRequest(method_t method, char const *url, CSCB * streamcallback, request_t *request; StoreIOBuffer tempBuffer; http->http_ver = http_ver; - http->conn = NULL; + http->setConn(NULL); http->start = current_time; /* this is only used to adjust the connection offset in client_side.c */ http->req_sz = 0; @@ -396,8 +396,8 @@ clientAccessCheckDone(int answer, void *data) RequestMethodStr[http->request->method], http->uri, answer == ACCESS_ALLOWED ? "ALLOWED" : "DENIED", AclMatchedName ? AclMatchedName : "NO ACL's"); - proxy_auth_msg = authenticateAuthUserRequestMessage((http->conn - && http->conn->auth_user_request) ? http->conn-> + proxy_auth_msg = authenticateAuthUserRequestMessage((http->getConn() + && http->getConn()->auth_user_request) ? http->getConn()-> auth_user_request : http->request->auth_user_request); if (answer == ACCESS_ALLOWED) { @@ -446,9 +446,9 @@ clientAccessCheckDone(int answer, void *data) assert (repContext); repContext->setReplyToError(page_id, status, http->request->method, NULL, - http->conn ? &http->conn->peer.sin_addr : &no_addr, http->request, - NULL, http->conn - && http->conn->auth_user_request ? http->conn-> + http->getConn() ? &http->getConn()->peer.sin_addr : &no_addr, http->request, + NULL, http->getConn() + && http->getConn()->auth_user_request ? http->getConn()-> auth_user_request : http->request->auth_user_request); node = (clientStreamNode *)http->client_stream.tail->data; clientStreamRead(node, http, node->readBuffer); @@ -674,13 +674,13 @@ clientInterpretRequestHeaders(clientHttpRequest * http) #if USE_USERAGENT_LOG if ((str = httpHeaderGetStr(req_hdr, HDR_USER_AGENT))) - logUserAgent(fqdnFromAddr(http->conn ? http->conn->log_addr : no_addr), str); + logUserAgent(fqdnFromAddr(http->getConn() ? http->getConn()->log_addr : no_addr), str); #endif #if USE_REFERER_LOG if ((str = httpHeaderGetStr(req_hdr, HDR_REFERER))) - logReferer(fqdnFromAddr(http->conn ? http->conn->log_addr : no_addr), str, http->log_uri); + logReferer(fqdnFromAddr(http->getConn() ? http->getConn()->log_addr : no_addr), str, http->log_uri); #endif #if FORW_VIA_DB @@ -788,8 +788,8 @@ clientRedirectDone(void *data, char *result) #endif /* FIXME PIPELINE: This is innacurate during pipelining */ - if (http->conn) - fd_note(http->conn->fd, http->uri); + if (http->getConn()) + fd_note(http->getConn()->fd, http->uri); assert(http->uri); diff --git a/src/client_side_request.cci b/src/client_side_request.cci index 2e622f655e..5660d800f1 100644 --- a/src/client_side_request.cci +++ b/src/client_side_request.cci @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cci,v 1.1 2003/06/20 01:01:05 robertc Exp $ + * $Id: client_side_request.cci,v 1.2 2003/07/10 11:04:06 robertc Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins @@ -49,3 +49,21 @@ ClientHttpRequest::memObject() const return NULL; } +ConnStateData * +ClientHttpRequest::getConn() +{ + return conn_; +} + +ConnStateData const * +ClientHttpRequest::getConn() const +{ + return conn_; +} + +void +ClientHttpRequest::setConn(ConnStateData *aConn) +{ + assert (!conn_ || !aConn); + conn_ = aConn; +} diff --git a/src/client_side_request.h b/src/client_side_request.h index 0f01174121..dcd63fd7e6 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.h,v 1.12 2003/06/20 12:36:35 robertc Exp $ + * $Id: client_side_request.h,v 1.13 2003/07/10 11:04:06 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -71,7 +71,9 @@ public: _SQUID_INLINE_ StoreEntry *storeEntry() const; void storeEntry(StoreEntry *); - ConnStateData *conn; + _SQUID_INLINE_ ConnStateData *getConn(); + _SQUID_INLINE_ ConnStateData const *getConn() const; + _SQUID_INLINE_ void setConn(ConnStateData *); request_t *request; /* Parsed URL ... */ char *uri; char *log_uri; @@ -132,11 +134,12 @@ private: CBDATA_CLASS(ClientHttpRequest); ssize_t maxReplyBodySize_; StoreEntry *entry_; + ConnStateData *conn_; }; /* client http based routines */ SQUIDCEXTERN char *clientConstructTraceEcho(clientHttpRequest *); -SQUIDCEXTERN ACLChecklist *clientAclChecklistCreate(const acl_access * acl, const clientHttpRequest * http); +SQUIDCEXTERN ACLChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http); SQUIDCEXTERN int clientHttpRequestStatus(int fd, clientHttpRequest const *http); SQUIDCEXTERN void clientAccessCheck(ClientHttpRequest *); diff --git a/src/redirect.cc b/src/redirect.cc index e7fb14510f..52b8ec68c2 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.98 2003/05/29 15:54:08 hno Exp $ + * $Id: redirect.cc,v 1.99 2003/07/10 11:04:06 robertc Exp $ * * DEBUG: section 61 Redirector * AUTHOR: Duane Wessels @@ -106,7 +106,7 @@ redirectStats(StoreEntry * sentry) void redirectStart(clientHttpRequest * http, RH * handler, void *data) { - ConnStateData *conn = http->conn; + ConnStateData *conn = http->getConn(); redirectStateData *r = NULL; const char *fqdn; char buf[8192]; @@ -121,9 +121,9 @@ redirectStart(clientHttpRequest * http, RH * handler, void *data) if (Config.accessList.redirector) { ACLChecklist ch; - ch.src_addr = http->conn->peer.sin_addr; - ch.my_addr = http->conn->me.sin_addr; - ch.my_port = ntohs(http->conn->me.sin_port); + ch.src_addr = http->getConn()->peer.sin_addr; + ch.my_addr = http->getConn()->me.sin_addr; + ch.my_port = ntohs(http->getConn()->me.sin_port); ch.request = requestLink(http->request); if (!aclCheckFast(Config.accessList.redirector, &ch)) { diff --git a/src/stat.cc b/src/stat.cc index 03631a7feb..c1f9658d3a 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.376 2003/06/22 21:31:24 wessels Exp $ + * $Id: stat.cc,v 1.377 2003/07/10 11:04:06 robertc Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -1582,7 +1582,7 @@ statClientRequests(StoreEntry * s) for (i = ClientActiveRequests.head; i; i = i->next) { http = static_cast(i->data); assert(http); - conn = http->conn; + conn = http->getConn(); storeAppendPrintf(s, "Connection: %p\n", conn); if (conn) { diff --git a/src/tunnel.cc b/src/tunnel.cc index 3d5bf9f929..a7c7bdde41 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.141 2003/03/04 01:40:31 robertc Exp $ + * $Id: tunnel.cc,v 1.142 2003/07/10 11:04:07 robertc Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -544,7 +544,7 @@ sslStart(clientHttpRequest * http, size_t * size_ptr, int *status_ptr) int sock; ErrorState *err = NULL; int answer; - int fd = http->conn->fd; + int fd = http->getConn()->fd; request_t *request = http->request; char *url = http->uri; /*