--------------------- PatchSet 10396 Date: 2008/01/13 15:44:05 Author: adri Branch: s27_adri Tag: (none) Log: Shuffle the buffer manipulation out of clientTryParseRequest() and into clientReadRequest(). Members: src/client_side.c:1.202.2.9.4.31->1.202.2.9.4.32 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.31 retrieving revision 1.202.2.9.4.32 diff -u -r1.202.2.9.4.31 -r1.202.2.9.4.32 --- squid/src/client_side.c 13 Jan 2008 14:47:00 -0000 1.202.2.9.4.31 +++ squid/src/client_side.c 13 Jan 2008 15:44:05 -0000 1.202.2.9.4.32 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.31 2008/01/13 14:47:00 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.32 2008/01/13 15:44:05 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -3901,7 +3901,7 @@ * <0 : error; stop parsing */ static int -clientTryParseRequest(ConnStateData * conn, clientHttpRequest **chttp) +clientTryParseRequest(ConnStateData * conn, int *cbytes, clientHttpRequest **chttp) { int fd = conn->fd; int nrequests; @@ -3914,6 +3914,7 @@ HttpMsgBuf msg; *chttp = NULL; + *cbytes = 0; HttpMsgBufInit(&msg, conn->in.buf, conn->in.offset); /* XXX for now there's no deallocation function needed but this may change */ /* Limit the number of concurrent requests to 2 */ @@ -3995,15 +3996,9 @@ errorAppendEntry(http->entry, err); return -1; } - /* - * If we read past the end of this request, move the remaining - * data to the beginning - */ - assert(conn->in.offset >= http->req_sz); - conn->in.offset -= http->req_sz; - debug(33, 5) ("removing %d bytes; conn->in.offset = %d\n", (int) http->req_sz, (int) conn->in.offset); - if (conn->in.offset > 0) - xmemmove(conn->in.buf, conn->in.buf + http->req_sz, conn->in.offset); + + /* XXX this is where the old data was moved .. -adrian */ + *cbytes = (int) http->req_sz; if (!http->flags.internal && internalCheck(strBuf2(request->urlpath), strLen2(request->urlpath))) { if (internalHostnameIs(request->host)) @@ -4116,6 +4111,7 @@ fde *F = &fd_table[fd]; int len = conn->in.size - conn->in.offset - 1; int ret; + int cbytes; clientHttpRequest *chttp; debug(33, 4) ("clientReadRequest: FD %d: reading request...\n", fd); @@ -4199,7 +4195,18 @@ } chttp = NULL; - ret = clientTryParseRequest(conn, &chttp); + cbytes = 0; + ret = clientTryParseRequest(conn, &cbytes, &chttp); + + if (cbytes > 0) { + /* If we read past the end of this request, move the remaining data to the beginning */ + assert(conn->in.offset >= cbytes); + conn->in.offset -= cbytes; + debug(33, 5) ("removing %d bytes; conn->in.offset = %d\n", (int) cbytes, (int) conn->in.offset); + if (conn->in.offset > 0) + xmemmove(conn->in.buf, conn->in.buf + cbytes, conn->in.offset); + } + if (chttp) clientCheckFollowXForwardedFor(chttp); if (ret <= 0)