--------------------- PatchSet 10416 Date: 2008/01/20 00:39:49 Author: adri Branch: s27_adri Tag: (none) Log: call httpMsgBufDone() when the request message has been used. This is a precursor to modifying the client-side parsing code to use a passed-in (buf_t, offset, length) and parse from that. This code allows for the buffer referencing to happen inside the httpMsgBuf*() routines. Members: src/client_side.c:1.202.2.9.4.41->1.202.2.9.4.42 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.41 retrieving revision 1.202.2.9.4.42 diff -u -r1.202.2.9.4.41 -r1.202.2.9.4.42 --- squid/src/client_side.c 19 Jan 2008 16:35:29 -0000 1.202.2.9.4.41 +++ squid/src/client_side.c 20 Jan 2008 00:39:49 -0000 1.202.2.9.4.42 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.41 2008/01/19 16:35:29 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.42 2008/01/20 00:39:49 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -4015,6 +4015,7 @@ int parser_return_code = 0; request_t *request = NULL; HttpMsgBuf msg; + int ret = -1; const char *buf = sbuf; int len = slen; @@ -4022,14 +4023,14 @@ *chttp = NULL; *cbytes = 0; - HttpMsgBufInit(&msg, buf, len); /* XXX for now there's no deallocation function needed but this may change */ + HttpMsgBufInit(&msg, buf, len); /* Limit the number of concurrent requests to 2 */ for (n = conn->reqs.head, nrequests = 0; n; n = n->next, nrequests++); if (nrequests >= (Config.onoff.pipeline_prefetch ? 2 : 1)) { debug(33, 3) ("clientReadRequest: FD %d max concurrent requests reached\n", fd); debug(33, 5) ("clientReadRequest: FD %d defering new request until one is done\n", fd); conn->defer.until = squid_curtime + 100; /* Reset when a request is complete */ - return 0; + ret = 0; goto finish; } if (nrequests == 0) fd_note_static(conn->fd, "Reading next request"); @@ -4057,9 +4058,9 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, METHOD_NONE, null_request_flags); errorAppendEntry(http->entry, err); - return -1; + ret = -1; goto finish; } - return 0; + ret = 0; goto finish; } /* the old code assumed this -adrian */ assert(http); @@ -4076,7 +4077,7 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - return -1; + ret = -1; goto finish; } if ((request = urlParse(method, http->uri, strlen(http->uri))) == NULL) { debug(33, 5) ("Invalid URL: %s\n", http->uri); @@ -4087,7 +4088,7 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - return -1; + ret = -1; goto finish; } /* compile headers */ /* we should skip request line! */ @@ -4100,7 +4101,7 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, method, null_request_flags); errorAppendEntry(http->entry, err); - return -1; + ret = -1; goto finish; } /* XXX this is where the old data was moved .. -adrian */ @@ -4150,7 +4151,7 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); errorAppendEntry(http->entry, err); - return -1; + ret = -1; goto finish; } if (!clientCheckContentLength(request) || httpHeaderHas(&request->header, HDR_TRANSFER_ENCODING)) { err = errorCon(ERR_INVALID_REQ, HTTP_LENGTH_REQUIRED, request); @@ -4158,7 +4159,7 @@ http->log_type = LOG_TCP_DENIED; http->entry = clientCreateStoreEntry(http, request->method, null_request_flags); errorAppendEntry(http->entry, err); - return -1; + ret = -1; goto finish; } http->request = requestLink(request); http->orig_request = requestLink(request); @@ -4176,7 +4177,7 @@ http->entry = clientCreateStoreEntry(http, METHOD_NONE, null_request_flags); errorAppendEntry(http->entry, err); - return -1; + ret = -1; goto finish; } } if (request->method == METHOD_CONNECT) { @@ -4190,12 +4191,13 @@ (ObjPackMethod) & httpRequestPackDebug); debugObj(33, 1, "This request:\n", request, (ObjPackMethod) & httpRequestPackDebug); } - return -2; + ret = -2; goto finish; } else { *chttp = http; } - if (!cbdataValid(conn)) - return -1; + if (!cbdataValid(conn)) { + ret = -1; goto finish; + } /* * For now we assume "here" means "we parsed a valid request. This might not be the case @@ -4206,7 +4208,10 @@ assert(http != NULL); assert(http->req_sz > 0); - return http->req_sz; + ret = http->req_sz; +finish: + httpMsgBufDone(&msg); + return ret; } static void