--------------------- PatchSet 4689 Date: 2002/08/15 14:12:02 Author: rbcollins Branch: esi Tag: (none) Log: move transient request prep variables out of clientHttpRequest Members: src/client_side.c:1.65.2.13->1.65.2.14 src/client_side_request.c:1.1.2.9->1.1.2.10 src/structs.h:1.61.2.6->1.61.2.7 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.65.2.13 retrieving revision 1.65.2.14 diff -u -r1.65.2.13 -r1.65.2.14 --- squid/src/client_side.c 15 Aug 2002 09:17:15 -0000 1.65.2.13 +++ squid/src/client_side.c 15 Aug 2002 14:12:02 -0000 1.65.2.14 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.65.2.13 2002/08/15 09:17:15 rbcollins Exp $ + * $Id: client_side.c,v 1.65.2.14 2002/08/15 14:12:02 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -338,8 +338,6 @@ if (conn) clientdbUpdate(conn->peer.sin_addr, http->log_type, PROTO_HTTP, http->out.size); } - if (http->acl_checklist) - aclChecklistFree(http->acl_checklist); if (request) checkFailureRatio(request->err_type, http->al.hier.code); safe_free(http->uri); Index: squid/src/client_side_request.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_request.c,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid/src/client_side_request.c 15 Aug 2002 09:17:15 -0000 1.1.2.9 +++ squid/src/client_side_request.c 15 Aug 2002 14:12:02 -0000 1.1.2.10 @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.c,v 1.1.2.9 2002/08/15 09:17:15 rbcollins Exp $ + * $Id: client_side_request.c,v 1.1.2.10 2002/08/15 14:12:02 rbcollins Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originall Duane Wessels in client_side.c) @@ -49,7 +49,18 @@ static const char *const crlf = "\r\n"; +typedef struct _clientRequestContext { + aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */ + int redirect_state; + clientHttpRequest *http; +} clientRequestContext; +CBDATA_TYPE (clientRequestContext); + /* Local functions */ +/* clientRequestContext */ +clientRequestContext *clientRequestContextNew (clientHttpRequest *); +FREE clientRequestContextFree; +/* other */ static int checkAccelOnly(clientHttpRequest *); static void clientAccessCheckDone(int, void *); /*static*/ aclCheck_t * clientAclChecklistCreate(const acl_access * acl, const clientHttpRequest * http); @@ -57,12 +68,32 @@ static int clientHierarchical(clientHttpRequest * http); static void clientInterpretRequestHeaders(clientHttpRequest * http); static RH clientRedirectDone; -static void clientCheckNoCache(clientHttpRequest *); +static void clientCheckNoCache(clientRequestContext * context); static void clientCheckNoCacheDone(int answer, void *data); void clientProcessRequest(clientHttpRequest *); extern CSR clientGetMoreData; extern CSS clientReplyStatus; +void +clientRequestContextFree (void *data) +{ + clientRequestContext *context = data; + cbdataReferenceDone (context->http); + if (context->acl_checklist) + aclChecklistFree(context->acl_checklist); +} + +clientRequestContext * +clientRequestContextNew (clientHttpRequest *http) +{ + clientRequestContext *rv; + assert (http != NULL); + CBDATA_INIT_TYPE_FREECB (clientRequestContext, clientRequestContextFree); + rv = cbdataAlloc (clientRequestContext); + rv->http = cbdataReference (http); + return rv; +} + /* Create a request and kick it off */ /* TODO: Pass in the buffers to be used in the inital Read request, * as they are determined by the user @@ -173,20 +204,22 @@ clientAccessCheck(void *data) { clientHttpRequest *http = data; + clientRequestContext *context = clientRequestContextNew (http); if (checkAccelOnly(http)) { /* deny proxy requests in accel_only mode */ debug(85, 1) ("clientAccessCheck: proxy request denied in accel_only mode\n"); - clientAccessCheckDone(ACCESS_DENIED, http); + clientAccessCheckDone(ACCESS_DENIED, context); return; } - http->acl_checklist = clientAclChecklistCreate(Config.accessList.http, http); - aclNBCheck(http->acl_checklist, clientAccessCheckDone, http); + context->acl_checklist = clientAclChecklistCreate(Config.accessList.http, http); + aclNBCheck(context->acl_checklist, clientAccessCheckDone, context); } void clientAccessCheckDone(int answer, void *data) { - clientHttpRequest *http = data; + clientRequestContext *context = data; + clientHttpRequest *http = context->http; err_type page_id; http_status status; char *proxy_auth_msg = NULL; @@ -195,15 +228,17 @@ answer == ACCESS_ALLOWED ? "ALLOWED" : "DENIED", AclMatchedName ? AclMatchedName : "NO ACL's"); proxy_auth_msg = authenticateAuthUserRequestMessage((http->conn && http->conn->auth_user_request) ? http->conn->auth_user_request : http->request->auth_user_request); - http->acl_checklist = NULL; + context->acl_checklist = NULL; if (answer == ACCESS_ALLOWED) { safe_free(http->uri); http->uri = xstrdup(urlCanonical(http->request)); - assert(http->redirect_state == REDIRECT_NONE); - http->redirect_state = REDIRECT_PENDING; - redirectStart(http, clientRedirectDone, http); + assert(context->redirect_state == REDIRECT_NONE); + context->redirect_state = REDIRECT_PENDING; + redirectStart(http, clientRedirectDone, context); } else { + /* Send an error */ clientStreamNode *node = http->client_stream.tail->prev->data; + cbdataFree (context); debug(85, 5) ("Access Denied: %s\n", http->uri); debug(85, 5) ("AclMatchedName = %s\n", AclMatchedName ? AclMatchedName : ""); @@ -251,7 +286,11 @@ /* FTP is always cachable */ if (req->protocol == PROTO_WAIS) return 0; - if (method == METHOD_CONNECT) + /* The below looks questionable: what non HTTP + * protocols use connect, trace, put and post? + * RC + */ + if (method == METHOD_CONNECT) return 0; if (method == METHOD_TRACE) return 0; @@ -278,6 +317,11 @@ * if our neighbors support private keys */ if (request->flags.ims && !neighbors_do_private_keys) return 0; + /* This is incorrect: authenticating requests + * can be sent via a hierarchy (they can even + * be cached if the correct headers are set on + * the reply + */ if (request->flags.auth) return 0; if (method == METHOD_TRACE) @@ -423,13 +467,14 @@ void clientRedirectDone(void *data, char *result) { - clientHttpRequest *http = data; + clientRequestContext *context = data; + clientHttpRequest *http = context->http; request_t *new_request = NULL; request_t *old_request = http->request; debug(85, 5) ("clientRedirectDone: '%s' result=%s\n", http->uri, result ? result : "NULL"); - assert(http->redirect_state == REDIRECT_PENDING); - http->redirect_state = REDIRECT_DONE; + assert(context->redirect_state == REDIRECT_PENDING); + context->redirect_state = REDIRECT_DONE; if (result) { http_status status = (http_status) atoi(result); if (status == HTTP_MOVED_PERMANENTLY || status == HTTP_MOVED_TEMPORARILY) { @@ -473,26 +518,29 @@ /* FIXME PIPELINE: This is innacurate during pipelining */ if (http->conn) fd_note(http->conn->fd, http->uri); - clientCheckNoCache(http); + clientCheckNoCache(context); } void -clientCheckNoCache(clientHttpRequest * http) +clientCheckNoCache(clientRequestContext * context) { + clientHttpRequest *http = context->http; if (Config.accessList.noCache && http->request->flags.cachable) { - http->acl_checklist = clientAclChecklistCreate(Config.accessList.noCache, http); - aclNBCheck(http->acl_checklist, clientCheckNoCacheDone, http); + context->acl_checklist = clientAclChecklistCreate(Config.accessList.noCache, http); + aclNBCheck(context->acl_checklist, clientCheckNoCacheDone, context); } else { - clientCheckNoCacheDone(http->request->flags.cachable, http); + clientCheckNoCacheDone(http->request->flags.cachable, context); } } void clientCheckNoCacheDone(int answer, void *data) { - clientHttpRequest *http = data; + clientRequestContext * context = data; + clientHttpRequest *http = context->http; http->request->flags.cachable = answer; - http->acl_checklist = NULL; + context->acl_checklist = NULL; + cbdataFree (context); clientProcessRequest(http); } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.61.2.6 retrieving revision 1.61.2.7 diff -u -r1.61.2.6 -r1.61.2.7 --- squid/src/structs.h 15 Aug 2002 09:17:15 -0000 1.61.2.6 +++ squid/src/structs.h 15 Aug 2002 14:12:02 -0000 1.61.2.7 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.61.2.6 2002/08/15 09:17:15 rbcollins Exp $ + * $Id: structs.h,v 1.61.2.7 2002/08/15 14:12:02 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1074,8 +1074,6 @@ log_type log_type; struct timeval start; http_version_t http_ver; - int redirect_state; - aclCheck_t *acl_checklist; /* need ptr back so we can unreg if needed */ AccessLogEntry al; struct { unsigned int accel:1;