--------------------- PatchSet 5016 Date: 2002/09/17 13:15:54 Author: rbcollins Branch: fixrange Tag: (none) Log: extract various methods from clientUpdateCounters Members: src/client_side.c:1.72.2.8->1.72.2.9 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.8 retrieving revision 1.72.2.9 diff -u -r1.72.2.8 -r1.72.2.9 --- squid/src/client_side.c 17 Sep 2002 12:52:46 -0000 1.72.2.8 +++ squid/src/client_side.c 17 Sep 2002 13:15:54 -0000 1.72.2.9 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.8 2002/09/17 12:52:46 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.9 2002/09/17 13:15:54 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -131,7 +131,9 @@ static clientStreamNode * getTail(clientSocketContext *); static void clientSocketRemoveThisFromConnectionList(clientSocketContext *, ConnStateData *); - +static void clientUpdateStatHistCounters(log_type logType, int svc_time); +static void clientUpdateStatCounters(log_type logType); +static void clientUpdateHierCounters (HierarchyLogEntry *); clientStreamNode * getTail (clientSocketContext *context) @@ -177,12 +179,12 @@ clientSocketContext * clientSocketContextNew(clientHttpRequest * http) { - clientSocketContext *rv; + clientSocketContext *newContext; assert(http != NULL); CBDATA_INIT_TYPE_FREECB(clientSocketContext, clientSocketContextFree); - rv = cbdataAlloc(clientSocketContext); - rv->http = http; - return rv; + newContext = cbdataAlloc(clientSocketContext); + newContext->http = http; + return newContext; } #if USE_IDENT @@ -194,21 +196,21 @@ } #endif -static void -clientUpdateCounters(clientHttpRequest * http) +void +clientUpdateStatCounters(log_type logType) { - int svc_time = tvSubMsec(http->start, current_time); - ping_data *i; - HierarchyLogEntry *H; statCounter.client_http.requests++; - if (isTcpHit(http->logType)) - statCounter.client_http.hits++; - if (http->logType == LOG_TCP_HIT) - statCounter.client_http.disk_hits++; - else if (http->logType == LOG_TCP_MEM_HIT) - statCounter.client_http.mem_hits++; - if (http->request->errType != ERR_NONE) - statCounter.client_http.errors++; + if (isTcpHit(logType)) + statCounter.client_http.hits++; + if (logType == LOG_TCP_HIT) + statCounter.client_http.disk_hits++; + else if (logType == LOG_TCP_MEM_HIT) + statCounter.client_http.mem_hits++; +} + +void +clientUpdateStatHistCounters(log_type logType, int svc_time) +{ statHistCount(&statCounter.client_http.all_svc_time, svc_time); /* * The idea here is not to be complete, but to get service times @@ -216,48 +218,64 @@ * LOG_TCP_REFRESH_FAIL_HIT because its not really a cache hit * (we *tried* to validate it, but failed). */ - switch (http->logType) { + switch (logType) { case LOG_TCP_REFRESH_HIT: - statHistCount(&statCounter.client_http.nh_svc_time, svc_time); - break; + statHistCount(&statCounter.client_http.nh_svc_time, svc_time); + break; case LOG_TCP_IMS_HIT: - statHistCount(&statCounter.client_http.nm_svc_time, svc_time); - break; + statHistCount(&statCounter.client_http.nm_svc_time, svc_time); + break; case LOG_TCP_HIT: case LOG_TCP_MEM_HIT: case LOG_TCP_OFFLINE_HIT: - statHistCount(&statCounter.client_http.hit_svc_time, svc_time); - break; + statHistCount(&statCounter.client_http.hit_svc_time, svc_time); + break; case LOG_TCP_MISS: case LOG_TCP_CLIENT_REFRESH_MISS: - statHistCount(&statCounter.client_http.miss_svc_time, svc_time); - break; + statHistCount(&statCounter.client_http.miss_svc_time, svc_time); + break; default: - /* make compiler warnings go away */ - break; + /* make compiler warnings go away */ + break; } - H = &http->request->hier; - switch (H->alg) { +} + +void +clientUpdateHierCounters (HierarchyLogEntry *someEntry) +{ + ping_data *i; + switch (someEntry->alg) { case PEER_SA_DIGEST: - statCounter.cd.times_used++; - break; + statCounter.cd.times_used++; + break; case PEER_SA_ICP: - statCounter.icp.times_used++; - i = &H->ping; - if (0 != i->stop.tv_sec && 0 != i->start.tv_sec) - statHistCount(&statCounter.icp.query_svc_time, - tvSubUsec(i->start, i->stop)); - if (i->timeout) - statCounter.icp.query_timeouts++; - break; + statCounter.icp.times_used++; + i = &someEntry->ping; + if (0 != i->stop.tv_sec && 0 != i->start.tv_sec) + statHistCount(&statCounter.icp.query_svc_time, + tvSubUsec(i->start, i->stop)); + if (i->timeout) + statCounter.icp.query_timeouts++; + break; case PEER_SA_NETDB: - statCounter.netdb.times_used++; - break; + statCounter.netdb.times_used++; + break; default: - break; + break; } } +static void +clientUpdateCounters(clientHttpRequest * http) +{ + clientUpdateStatCounters(http->logType); + if (http->request->errType != ERR_NONE) + statCounter.client_http.errors++; + clientUpdateStatHistCounters(http->logType, + tvSubMsec(http->start, current_time)); + clientUpdateHierCounters(&http->request->hier); +} + void httpRequestFree(void *data) {