--------------------- PatchSet 5042 Date: 2002/09/19 04:16:27 Author: rbcollins Branch: fixrange Tag: (none) Log: pull out more common code Members: src/client_side.c:1.72.2.34->1.72.2.35 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.34 retrieving revision 1.72.2.35 diff -u -r1.72.2.34 -r1.72.2.35 --- squid/src/client_side.c 19 Sep 2002 04:05:11 -0000 1.72.2.34 +++ squid/src/client_side.c 19 Sep 2002 04:16:27 -0000 1.72.2.35 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.34 2002/09/19 04:05:11 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.35 2002/09/19 04:16:27 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1167,6 +1167,26 @@ } } +void +connAddContextToQueue (ConnStateData *conn, clientSocketContext *context) +{ + clientSocketContext **S; + for (S = (clientSocketContext **) & conn->currentobject; *S; + S = &(*S)->next); + *S = context; + ++conn->nrequests; +} + +int +connGetConcurrentRequestCount (ConnStateData *conn) +{ + int result = 0; + clientSocketContext **T; + for (T = (clientSocketContext **) & conn->currentobject; + *T; T = &(*T)->next, ++result); + return result; +} + static void clientReadRequest(int fd, void *data) { @@ -1238,7 +1258,6 @@ clientProcessBody(conn); /* Process next request */ while (conn->in.offset > 0 && conn->body.size_left == 0) { - clientSocketContext **S; int nrequests; size_t req_line_sz; /* Skip leading (and trailing) whitespace */ @@ -1250,8 +1269,7 @@ if (conn->in.offset == 0) break; /* Limit the number of concurrent requests to 2 */ - for (S = (clientSocketContext **) & conn->currentobject, nrequests = 0; - *S; S = &(*S)->next, nrequests++); + nrequests = connGetConcurrentRequestCount(conn); if (nrequests >= (Config.onoff.pipeline_prefetch ? 2 : 1)) { debug(33, 3) ("clientReadRequest: FD %d max concurrent requests reached\n", fd); @@ -1284,11 +1302,7 @@ if (conn->in.offset > 0) xmemmove(conn->in.buf, conn->in.buf + http->req_sz, conn->in.offset); - /* add to the client request queue */ - for (S = (clientSocketContext **) & conn->currentobject; *S; - S = &(*S)->next); - *S = context; - conn->nrequests++; + connAddContextToQueue (conn, context); commSetTimeout(fd, Config.Timeout.lifetime, clientLifetimeTimeout, http); if (parser_return_code < 0) { @@ -1404,10 +1418,7 @@ clientSetReplyToError(node->data, ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE, METHOD_NONE, NULL, &conn->peer.sin_addr, NULL, NULL, NULL); - /* add to the client request queue */ - for (S = (clientSocketContext **) & conn->currentobject; *S; - S = &(*S)->next); - *S = context; + connAddContextToQueue (conn, context); assert(context->http->out.offset == 0); clientPullData (context); return;