--------------------- PatchSet 10401 Date: 2008/01/14 08:30:22 Author: adri Branch: s27_adri Tag: (none) Log: Remove direct access to conn.in variables; use methods instead. Members: src/client_side.c:1.202.2.9.4.35->1.202.2.9.4.36 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.35 retrieving revision 1.202.2.9.4.36 diff -u -r1.202.2.9.4.35 -r1.202.2.9.4.36 --- squid/src/client_side.c 14 Jan 2008 06:20:02 -0000 1.202.2.9.4.35 +++ squid/src/client_side.c 14 Jan 2008 08:30:22 -0000 1.202.2.9.4.36 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.35 2008/01/14 06:20:02 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.36 2008/01/14 08:30:22 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -217,7 +217,7 @@ clientConnBufConsume(ConnInBuf *in, int cbytes) { in->offset -= cbytes; - debug(33, 5) ("removing %d bytes; conn->in.offset = %d\n", (int) cbytes, (int) in->offset); + debug(33, 5) ("removing %d bytes; clientConnBufLen(&conn->in) = %d\n", (int) cbytes, (int) in->offset); if (in->offset > 0) xmemmove(in->buf, in->buf + cbytes, in->offset); } @@ -3707,7 +3707,7 @@ http = cbdataAlloc(clientHttpRequest); http->conn = conn; http->start = current_time; - http->req_sz = conn->in.offset; + http->req_sz = clientConnBufLen(&conn->in); http->uri = xstrdup(uri); http->range_iter.boundary = StringNull; httpBuildVersion(&http->http_ver, 1, 0); @@ -3802,7 +3802,7 @@ prefix_sz = req_sz; debug(33, 3) ("parseHttpRequest: prefix_sz = %d, req_line_sz = %d\n", (int) prefix_sz, (int) hmsg->r_len); - assert(prefix_sz <= conn->in.offset); + assert(prefix_sz <= clientConnBufLen(&conn->in)); /* Ok, all headers are received */ http = cbdataAlloc(clientHttpRequest); @@ -4023,10 +4023,10 @@ * Partial request received; reschedule until parseHttpRequest() * is happy with the input */ - if (conn->in.offset >= Config.maxRequestHeaderSize) { + if (clientConnBufLen(&conn->in) >= Config.maxRequestHeaderSize) { /* The request is too large to handle */ debug(33, 1) ("Request header is too large (%d bytes)\n", - (int) conn->in.offset); + (int) clientConnBufLen(&conn->in)); debug(33, 1) ("Config 'request_header_max_size'= %ld bytes.\n", (long int) Config.maxRequestHeaderSize); err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_URI_TOO_LONG, NULL); @@ -4213,7 +4213,7 @@ * lame half-close detection */ if (size == 0) { - if (DLINK_ISEMPTY(conn->reqs) && conn->in.offset == 0) { + if (DLINK_ISEMPTY(conn->reqs) && clientConnBufLen(&conn->in) == 0) { /* no current or pending requests */ debug(33, 4) ("clientReadRequest: FD %d closed\n", fd); comm_close(fd); @@ -4240,14 +4240,14 @@ debug(50, 2) ("clientReadRequest: FD %d: %s\n", fd, xstrerror()); comm_close(fd); return; - } else if (conn->in.offset == 0) { + } else if (clientConnBufLen(&conn->in) == 0) { debug(50, 2) ("clientReadRequest: FD %d: no data to process (%s)\n", fd, xstrerror()); } /* Continue to process previously read data */ } cbdataLock(conn); /* clientProcessBody might pull the connection under our feets */ /* Process request body if any */ - if (conn->in.offset > 0 && conn->body.callback != NULL) { + if (clientConnBufLen(&conn->in) > 0 && conn->body.callback != NULL) { clientProcessBody(conn); if (!cbdataValid(conn)) { cbdataUnlock(conn); @@ -4256,7 +4256,7 @@ } /* Process next request */ ret = 0; - while (cbdataValid(conn) && conn->in.offset > 0 && conn->body.size_left == 0) { + while (cbdataValid(conn) && clientConnBufLen(&conn->in) > 0 && conn->body.size_left == 0) { /* Ret tells us how many bytes was consumed - 0 == didn't consume request, > 0 == consumed, -1 == error, -2 == CONNECT request stole the connection */ /* Skip leading (and trailing) whitespace */ @@ -4264,7 +4264,7 @@ xmemmove(conn->in.buf, conn->in.buf + 1, conn->in.offset - 1); conn->in.offset--; } - if (conn->in.offset == 0) { + if (clientConnBufLen(&conn->in) == 0) { ret = 0; break; } @@ -4275,7 +4275,7 @@ if (cbytes > 0) { /* If we read past the end of this request, move the remaining data to the beginning */ - assert(conn->in.offset >= cbytes); + assert(clientConnBufLen(&conn->in) >= cbytes); clientConnBufConsume(&conn->in, cbytes); } @@ -4292,7 +4292,7 @@ cbdataUnlock(conn); /* Check if a half-closed connection was aborted in the middle */ if (F->flags.socket_eof) { - if (conn->in.offset != conn->body.size_left) { /* != 0 when no request body */ + if (clientConnBufLen(&conn->in) != conn->body.size_left) { /* != 0 when no request body */ /* Partial request received. Abort client connection! */ debug(33, 3) ("clientReadRequest: FD %d aborted, partial request\n", fd); comm_close(fd); @@ -4318,7 +4318,7 @@ return; } assert(cbdataValid(conn)); - debug(33, 2) ("clientReadBody: start fd=%d body_size=%lu in.offset=%ld cb=%p req=%p\n", conn->fd, (unsigned long int) conn->body.size_left, (long int) conn->in.offset, callback, request); + debug(33, 2) ("clientReadBody: start fd=%d body_size=%lu in.offset=%ld cb=%p req=%p\n", conn->fd, (unsigned long int) conn->body.size_left, (long int) clientConnBufLen(&conn->in), callback, request); conn->body.callback = callback; conn->body.cbdata = cbdata; cbdataLock(conn->body.cbdata); @@ -4375,8 +4375,8 @@ CBCB *callback = conn->body.callback; request_t *request = conn->body.request; /* Note: request is null while eating "aborted" transfers */ - debug(33, 2) ("clientProcessBody: start fd=%d body_size=%lu in.offset=%ld cb=%p req=%p\n", conn->fd, (unsigned long int) conn->body.size_left, (long int) conn->in.offset, callback, request); - if (conn->in.offset) { + debug(33, 2) ("clientProcessBody: start fd=%d body_size=%lu in.offset=%ld cb=%p req=%p\n", conn->fd, (unsigned long int) conn->body.size_left, (long int) clientConnBufLen(&conn->in), callback, request); + if (clientConnBufLen(&conn->in)) { int valid = cbdataValid(conn->body.cbdata); if (!valid) { comm_close(conn->fd); @@ -4384,10 +4384,10 @@ } /* Some sanity checks... */ assert(conn->body.size_left > 0); - assert(conn->in.offset > 0); + assert(clientConnBufLen(&conn->in) > 0); assert(callback != NULL); /* How much do we have to process? */ - size = conn->in.offset; + size = clientConnBufLen(&conn->in); if (size > conn->body.size_left) /* only process the body part */ size = conn->body.size_left; if (size > conn->body.bufsize) /* don't copy more than requested */ @@ -4400,7 +4400,7 @@ clientConnBufConsume(&conn->in, size); conn->body.size_left -= size; /* Resume the fd if necessary */ - if (conn->in.offset < conn->in.size - 1) + if (! clientConnBufIsFull(&conn->in)) commResumeFD(conn->fd); /* Remove request link if this is the last part of the body, as * clientReadRequest automatically continues to process next request */ @@ -4425,7 +4425,7 @@ callback(buf, size, cbdata); if (request != NULL) requestUnlink(request); /* Linked in clientReadBody */ - debug(33, 2) ("clientProcessBody: end fd=%d size=%d body_size=%lu in.offset=%ld cb=%p req=%p\n", conn->fd, size, (unsigned long int) conn->body.size_left, (long int) conn->in.offset, callback, request); + debug(33, 2) ("clientProcessBody: end fd=%d size=%d body_size=%lu in.offset=%ld cb=%p req=%p\n", conn->fd, size, (unsigned long int) conn->body.size_left, (long int) clientConnBufLen(&conn->in), callback, request); } }