--------------------- PatchSet 10399 Date: 2008/01/14 05:47:29 Author: adri Branch: s27_adri Tag: (none) Log: Break out the conn buffer filling into a seperate function. Members: src/client_side.c:1.202.2.9.4.33->1.202.2.9.4.34 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.202.2.9.4.33 retrieving revision 1.202.2.9.4.34 diff -u -r1.202.2.9.4.33 -r1.202.2.9.4.34 --- squid/src/client_side.c 14 Jan 2008 04:51:33 -0000 1.202.2.9.4.33 +++ squid/src/client_side.c 14 Jan 2008 05:47:29 -0000 1.202.2.9.4.34 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.202.2.9.4.33 2008/01/14 04:51:33 adri Exp $ + * $Id: client_side.c,v 1.202.2.9.4.34 2008/01/14 05:47:29 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -194,6 +194,25 @@ (long) in->offset, (long) in->size); } +int +clientConnBufFill(ConnInBuf *in, int fd) +{ + int size; + int len = in->size - in->offset - 1; + + if (len == 0) { + /* Grow the request memory area to accomodate for a large request */ + clientConnBufGrow(in, in->size * 2); + len = in->size - in->offset - 1; + } + statCounter.syscalls.sock.reads++; + size = FD_READ_METHOD(fd, in->buf + in->offset, len); + if (size > 0) { + in->offset += size; + } + return size; +} + void clientConnBufConsume(ConnInBuf *in, int cbytes) { @@ -4151,22 +4170,15 @@ ConnStateData *conn = data; int size; 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); - if (len == 0) { - /* Grow the request memory area to accomodate for a large request */ - clientConnBufGrow(&conn->in, conn->in.size * 2); - len = conn->in.size - conn->in.offset - 1; - } - statCounter.syscalls.sock.reads++; - size = FD_READ_METHOD(fd, conn->in.buf + conn->in.offset, len); + size = clientConnBufFill(&conn->in, fd); if (size > 0) { - fd_bytes(fd, size, FD_READ); - kb_incr(&statCounter.client_http.kbytes_in, size); + fd_bytes(fd, size, FD_READ); + kb_incr(&statCounter.client_http.kbytes_in, size); } /* * Don't reset the timeout value here. The timeout value will be @@ -4175,9 +4187,7 @@ * whole, not individual read() calls. Plus, it breaks our * lame half-close detection */ - if (size > 0) { - conn->in.offset += size; - } else if (size == 0) { + if (size == 0) { if (DLINK_ISEMPTY(conn->reqs) && conn->in.offset == 0) { /* no current or pending requests */ debug(33, 4) ("clientReadRequest: FD %d closed\n", fd);