From: adrian <> Date: Mon, 2 Oct 2006 07:34:18 +0000 (+0000) Subject: Fix/Add request-line parser debugging; fix bug with pipelined connection parsing X-Git-Tag: SQUID_3_0_PRE5~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c29340e57a94949ce7eef4b4c52984996ebfc22;p=thirdparty%2Fsquid.git Fix/Add request-line parser debugging; fix bug with pipelined connection parsing The unparsed request buffer was being relocated before the headers were being parsed. That was fine - the request parsing used to happen with a copy of the buffer - but now a copy isn't being made. The buffer relocation needed to be changed to happen after the request was parsed. --- diff --git a/src/HttpMsg.cc b/src/HttpMsg.cc index 478141c161..a3adbe0b8a 100644 --- a/src/HttpMsg.cc +++ b/src/HttpMsg.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.cc,v 1.36 2006/10/01 17:27:10 adrian Exp $ + * $Id: HttpMsg.cc,v 1.37 2006/10/02 01:34:18 adrian Exp $ * * DEBUG: section 74 HTTP Message * AUTHOR: Alex Rousskov @@ -399,6 +399,7 @@ HttpParserInit(HttpParser *hdr, const char *buf, int bufsiz) hdr->bufsiz = bufsiz; hdr->req_start = hdr->req_end = -1; hdr->hdr_start = hdr->hdr_end = -1; + debug(74, 5)("httpParseInit: Request buffer is %s\n", buf); } #if MSGDODEBUG @@ -464,6 +465,8 @@ HttpParserParseReqLine(HttpParser *hmsg) int maj = -1, min = -1; int last_whitespace = -1, line_end = -1; + debug(74, 5)("httpParserParseReqLine: parsing %s\n", hmsg->buf); + PROF_start(HttpParserParseReqLine); /* Find \r\n - end of URL+Version (and the request) */ hmsg->req_end = -1; @@ -481,7 +484,8 @@ HttpParserParseReqLine(HttpParser *hmsg) retcode = 0; goto finish; } - assert(hmsg->buf[hmsg->req_end] != '\n' && hmsg->buf[hmsg->req_end] != '\r'); + assert(hmsg->buf[hmsg->req_end] != '\n'); + assert(hmsg->buf[hmsg->req_end - 1] == '\n'); /* Start at the beginning again */ i = 0; @@ -608,7 +612,7 @@ finish: assert(maj != -1); assert(min != -1); PROF_stop(HttpParserParseReqLine); - debug(1, 1) ("Parser: retval %d: from %d->%d: method %d->%d; url %d->%d; version %d->%d (%d/%d)\n", + debug(74, 5) ("Parser: retval %d: from %d->%d: method %d->%d; url %d->%d; version %d->%d (%d/%d)\n", retcode, hmsg->req_start, hmsg->req_end, hmsg->m_start, hmsg->m_end, hmsg->u_start, hmsg->u_end, diff --git a/src/HttpMsg.h b/src/HttpMsg.h index 66495bacc5..efc6d64e71 100644 --- a/src/HttpMsg.h +++ b/src/HttpMsg.h @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.h,v 1.13 2006/09/27 13:47:53 adrian Exp $ + * $Id: HttpMsg.h,v 1.14 2006/10/02 01:34:18 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -117,6 +117,7 @@ typedef struct _HttpParser HttpParser; extern void HttpParserInit(HttpParser *, const char *buf, int len); extern int HttpParserParseReqLine(HttpParser *hp); +#define MSGDODEBUG 0 #if MSGDODEBUG extern int HttpParserReqSz(HttpParser *); extern int HttpParserHdrSz(HttpParser *); diff --git a/src/client_side.cc b/src/client_side.cc index 55d7245908..26715aaeda 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.740 2006/09/27 13:47:53 adrian Exp $ + * $Id: client_side.cc,v 1.741 2006/10/02 01:34:18 adrian Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -2140,8 +2140,6 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC HttpRequest *request = NULL; /* We have an initial client stream in place should it be needed */ /* setup our private context */ - connNoteUseOfBuffer(conn.getRaw(), http->req_sz); - context->registerWithConn(); if (context->flags.parsed_ok == 0) { @@ -2154,7 +2152,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; - return; + goto finish; } if ((request = HttpRequest::CreateFromUrlAndMethod(http->uri, method)) == NULL) { @@ -2168,7 +2166,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; - return; + goto finish; } /* compile headers */ @@ -2185,7 +2183,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; - return; + goto finish; } request->flags.accelerated = http->flags.accel; @@ -2228,7 +2226,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; - return; + goto finish; } @@ -2242,7 +2240,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; - return; + goto finish; } http->request = HTTPMSGLOCK(request); @@ -2274,7 +2272,7 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC assert(context->http->out.offset == 0); context->pullData(); conn->flags.readMoreRequests = false; - return; + goto finish; } context->mayUseConnection(true); @@ -2287,6 +2285,10 @@ clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketC http->calloutContext = new ClientRequestContext(http); http->doCallouts(); + +finish: + /* Consume request buffer */ + connNoteUseOfBuffer(conn.getRaw(), http->req_sz); } static void