--------------------- PatchSet 5031 Date: 2002/09/17 22:59:48 Author: rbcollins Branch: fixrange Tag: (none) Log: extract stats logic from clientWriteComplete Members: src/client_side.c:1.72.2.23->1.72.2.24 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.23 retrieving revision 1.72.2.24 diff -u -r1.72.2.23 -r1.72.2.24 --- squid/src/client_side.c 17 Sep 2002 22:45:42 -0000 1.72.2.23 +++ squid/src/client_side.c 17 Sep 2002 22:59:48 -0000 1.72.2.24 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.23 2002/09/17 22:45:42 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.24 2002/09/17 22:59:48 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -151,6 +151,7 @@ static void contextSendStartOfMessage(clientSocketContext *context, HttpReply * rep,StoreIOBuffer bodyData); static void connReadNextRequest (ConnStateData *conn); static void clientSocketContextPushDeferredIfNeeded(clientSocketContext *deferredRequest, ConnStateData *conn); +static void clientUpdateSocketStats (log_type logType, size_t size); clientStreamNode * getTail (clientSocketContext *context) @@ -733,6 +734,16 @@ clientSocketContextPushDeferredIfNeeded (deferredRequest, conn); } +void +clientUpdateSocketStats (log_type logType, size_t size) +{ + if (size == 0) + return; + kb_incr(&statCounter.client_http.kbytes_out, size); + if (logTypeIsATcpHit(logType)) + kb_incr(&statCounter.client_http.hit_kbytes_out, size); +} + /* A write has just completed to the client, or we have just realised there is * no more data to send. */ @@ -745,25 +756,20 @@ /* cheating: we are always the tail */ clientStreamNode *node = getTail (context); http->out.size += size; + assert (fd > -1); debug(33, 5) ("clientWriteComplete: FD %d, sz %ld, err %d, off %ld, len %d\n", fd, (long int) size, errflag, (long int) http->out.size, entry ? objectLen(entry) : 0); - if (size > 0 && fd > -1) { - kb_incr(&statCounter.client_http.kbytes_out, size); - if (logTypeIsATcpHit(http->logType)) - kb_incr(&statCounter.client_http.hit_kbytes_out, size); - } + clientUpdateSocketStats (http->logType, size); if (errflag) { /* * just close the socket, httpRequestFree will abort if needed. * errflag is only EVER set by the comms callbacks */ - assert(fd != -1); comm_close(fd); return; } if (clientHttpRequestStatus(fd, http)) { - if (fd != -1) - comm_close(fd); + comm_close(fd); /* Do we leak here ? */ return; }