--------------------- PatchSet 10216 Date: 2007/12/12 10:14:22 Author: adri Branch: s27_adri Tag: (none) Log: strBuf() -> strBuf2() where its easily done (103 to go!) Members: src/peer_digest.c:1.21.10.2->1.21.10.2.4.1 Index: squid/src/peer_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/peer_digest.c,v retrieving revision 1.21.10.2 retrieving revision 1.21.10.2.4.1 diff -u -r1.21.10.2 -r1.21.10.2.4.1 --- squid/src/peer_digest.c 30 Nov 2007 07:44:23 -0000 1.21.10.2 +++ squid/src/peer_digest.c 12 Dec 2007 10:14:22 -0000 1.21.10.2.4.1 @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.c,v 1.21.10.2 2007/11/30 07:44:23 adri Exp $ + * $Id: peer_digest.c,v 1.21.10.2.4.1 2007/12/12 10:14:22 adri Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -151,8 +151,8 @@ static void peerDigestDisable(PeerDigest * pd) { - debug(72, 2) ("peerDigestDisable: peer %s disabled for good\n", - strBuf(pd->host)); + debug(72, 2) ("peerDigestDisable: peer %.*s disabled for good\n", + strLen2(pd->host), strBuf2(pd->host)); pd->times.disabled = squid_curtime; pd->times.next_check = -1; /* never */ pd->flags.usable = 0; @@ -192,8 +192,8 @@ { eventAdd("peerDigestCheck", peerDigestCheck, pd, (double) delay, 1); pd->times.next_check = squid_curtime + delay; - debug(72, 3) ("peerDigestSetCheck: will check peer %s in %d secs\n", - strBuf(pd->host), (int) delay); + debug(72, 3) ("peerDigestSetCheck: will check peer %.*s in %d secs\n", + strLen2(pd->host), strBuf2(pd->host), (int) delay); } /* @@ -203,12 +203,12 @@ peerDigestNotePeerGone(PeerDigest * pd) { if (pd->flags.requested) { - debug(72, 2) ("peerDigest: peer %s gone, will destroy after fetch.\n", - strBuf(pd->host)); + debug(72, 2) ("peerDigest: peer %.*s gone, will destroy after fetch.\n", + strLen2(pd->host), strBuf2(pd->host)); /* do nothing now, the fetching chain will notice and take action */ } else { - debug(72, 2) ("peerDigest: peer %s is gone, destroying now.\n", - strBuf(pd->host)); + debug(72, 2) ("peerDigest: peer %.*s is gone, destroying now.\n", + strLen2(pd->host), strBuf2(pd->host)); peerDigestDestroy(pd); } } @@ -244,15 +244,15 @@ /* per-peer limit */ if (req_time - pd->times.received < PeerDigestReqMinGap) { - debug(72, 2) ("peerDigestCheck: %s, avoiding close peer requests (%d < %d secs).\n", - strBuf(pd->host), (int) (req_time - pd->times.received), + debug(72, 2) ("peerDigestCheck: %.*s, avoiding close peer requests (%d < %d secs).\n", + strLen2(pd->host), strBuf2(pd->host), (int) (req_time - pd->times.received), (int) PeerDigestReqMinGap); req_time = pd->times.received + PeerDigestReqMinGap; } /* global limit */ if (req_time - pd_last_req_time < GlobDigestReqMinGap) { - debug(72, 2) ("peerDigestCheck: %s, avoiding close requests (%d < %d secs).\n", - strBuf(pd->host), (int) (req_time - pd_last_req_time), + debug(72, 2) ("peerDigestCheck: %.*s, avoiding close requests (%d < %d secs).\n", + strLen2(pd->host), strBuf2(pd->host), (int) (req_time - pd_last_req_time), (int) GlobDigestReqMinGap); req_time = pd_last_req_time + GlobDigestReqMinGap; } @@ -354,8 +354,8 @@ assert(reply); httpReplyParse(reply, buf, hdr_size); status = reply->sline.status; - debug(72, 3) ("peerDigestFetchReply: %s status: %d, expires: %ld (%+d)\n", - strBuf(pd->host), status, + debug(72, 3) ("peerDigestFetchReply: %.*s status: %d, expires: %ld (%+d)\n", + strLen2(pd->host), strBuf2(pd->host), status, (long int) reply->expires, (int) (reply->expires - squid_curtime)); /* this "if" is based on clientHandleIMSReply() */ @@ -428,8 +428,8 @@ if (!fetch->entry->mem_obj->reply->sline.status) httpReplyParse(fetch->entry->mem_obj->reply, buf, hdr_size); if (fetch->entry->mem_obj->reply->sline.status != HTTP_OK) { - debug(72, 1) ("peerDigestSwapInHeaders: %s status %d got cached!\n", - strBuf(fetch->pd->host), fetch->entry->mem_obj->reply->sline.status); + debug(72, 1) ("peerDigestSwapInHeaders: %.*s status %d got cached!\n", + strLen2(fetch->pd->host), strBuf2(fetch->pd->host), fetch->entry->mem_obj->reply->sline.status); peerDigestFetchAbort(fetch, buf, "internal status error"); goto finish; } @@ -602,8 +602,8 @@ peerDigestFetchStop(DigestFetchState * fetch, const char *buf, const char *reason) { assert(reason); - debug(72, 2) ("peerDigestFetchStop: peer %s, reason: %s\n", - strBuf(fetch->pd->host), reason); + debug(72, 2) ("peerDigestFetchStop: peer %.*s, reason: %s\n", + strLen2(fetch->pd->host), strBuf2(fetch->pd->host), reason); peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 0); } @@ -612,8 +612,8 @@ peerDigestFetchAbort(DigestFetchState * fetch, const char *buf, const char *reason) { assert(reason); - debug(72, 2) ("peerDigestFetchAbort: peer %s, reason: %s\n", - strBuf(fetch->pd->host), reason); + debug(72, 2) ("peerDigestFetchAbort: peer %.*s, reason: %s\n", + strLen2(fetch->pd->host), strBuf2(fetch->pd->host), reason); peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 1); } @@ -657,7 +657,6 @@ peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, int err) { PeerDigest *pd = fetch->pd; - const char *host = strBuf(pd->host); pd->times.received = squid_curtime; pd->times.req_delay = fetch->resp_time; @@ -667,9 +666,9 @@ pd->stats.recv.msgs += fetch->recv.msg; if (err) { - debug(72, 1) ("%sdisabling (%s) digest from %s\n", + debug(72, 1) ("%sdisabling (%s) digest from %.*s\n", pcb_valid ? "temporary " : "", - pd->req_result, host); + pd->req_result, strLen2(pd->host), strBuf2(pd->host)); if (pd->cd) { cacheDigestDestroy(pd->cd); @@ -686,9 +685,9 @@ /* XXX: ugly condition, but how? */ if (fetch->entry->store_status == STORE_OK) - debug(72, 2) ("re-used old digest from %s\n", host); + debug(72, 2) ("re-used old digest from %.*s\n", strLen2(pd->host), strBuf2(pd->host)); else - debug(72, 2) ("received valid digest from %s\n", host); + debug(72, 2) ("received valid digest from %.*s\n", strLen2(pd->host), strBuf2(pd->host)); } fetch->pd = NULL; cbdataUnlock(pd); @@ -757,7 +756,6 @@ { StoreDigestCBlock cblock; int freed_size = 0; - const char *host = strBuf(pd->host); xmemcpy(&cblock, buf, sizeof(cblock)); /* network -> host conversions */ @@ -767,39 +765,39 @@ cblock.count = ntohl(cblock.count); cblock.del_count = ntohl(cblock.del_count); cblock.mask_size = ntohl(cblock.mask_size); - debug(72, 2) ("got digest cblock from %s; ver: %d (req: %d)\n", - host, (int) cblock.ver.current, (int) cblock.ver.required); + debug(72, 2) ("got digest cblock from %.*s; ver: %d (req: %d)\n", + strLen2(pd->host), strBuf2(pd->host), (int) cblock.ver.current, (int) cblock.ver.required); debug(72, 2) ("\t size: %d bytes, e-cnt: %d, e-util: %d%%\n", cblock.mask_size, cblock.count, xpercentInt(cblock.count, cblock.capacity)); /* check version requirements (both ways) */ if (cblock.ver.required > CacheDigestVer.current) { - debug(72, 1) ("%s digest requires version %d; have: %d\n", - host, cblock.ver.required, CacheDigestVer.current); + debug(72, 1) ("%.*s digest requires version %d; have: %d\n", + strLen2(pd->host), strBuf2(pd->host), cblock.ver.required, CacheDigestVer.current); return 0; } if (cblock.ver.current < CacheDigestVer.required) { - debug(72, 1) ("%s digest is version %d; we require: %d\n", - host, cblock.ver.current, CacheDigestVer.required); + debug(72, 1) ("%.*s digest is version %d; we require: %d\n", + strLen2(pd->host), strBuf2(pd->host), cblock.ver.current, CacheDigestVer.required); return 0; } /* check consistency */ if (cblock.ver.required > cblock.ver.current || cblock.mask_size <= 0 || cblock.capacity <= 0 || cblock.bits_per_entry <= 0 || cblock.hash_func_count <= 0) { - debug(72, 0) ("%s digest cblock is corrupted.\n", host); + debug(72, 0) ("%.*s digest cblock is corrupted.\n", strLen2(pd->host), strBuf2(pd->host)); return 0; } /* check consistency further */ if (cblock.mask_size != cacheDigestCalcMaskSize(cblock.capacity, cblock.bits_per_entry)) { - debug(72, 0) ("%s digest cblock is corrupted (mask size mismatch: %d ? %d).\n", - host, cblock.mask_size, (int) cacheDigestCalcMaskSize(cblock.capacity, cblock.bits_per_entry)); + debug(72, 0) ("%.*s digest cblock is corrupted (mask size mismatch: %d ? %d).\n", + strLen2(pd->host), strBuf2(pd->host), cblock.mask_size, (int) cacheDigestCalcMaskSize(cblock.capacity, cblock.bits_per_entry)); return 0; } /* there are some things we cannot do yet */ if (cblock.hash_func_count != CacheDigestHashFuncCount) { - debug(72, 0) ("%s digest: unsupported #hash functions: %d ? %d.\n", - host, cblock.hash_func_count, CacheDigestHashFuncCount); + debug(72, 0) ("%.*s digest: unsupported #hash functions: %d ? %d.\n", + strLen2(pd->host), strBuf2(pd->host), cblock.hash_func_count, CacheDigestHashFuncCount); return 0; } /* @@ -807,15 +805,15 @@ */ /* check size changes */ if (pd->cd && cblock.mask_size != pd->cd->mask_size) { - debug(72, 2) ("%s digest changed size: %d -> %d\n", - host, cblock.mask_size, pd->cd->mask_size); + debug(72, 2) ("%.*s digest changed size: %d -> %d\n", + strLen2(pd->host), strBuf2(pd->host), cblock.mask_size, pd->cd->mask_size); freed_size = pd->cd->mask_size; cacheDigestDestroy(pd->cd); pd->cd = NULL; } if (!pd->cd) { - debug(72, 2) ("creating %s digest; size: %d (%+d) bytes\n", - host, cblock.mask_size, (int) (cblock.mask_size - freed_size)); + debug(72, 2) ("creating %.*s digest; size: %d (%+d) bytes\n", + strLen2(pd->host), strBuf2(pd->host), cblock.mask_size, (int) (cblock.mask_size - freed_size)); pd->cd = cacheDigestCreate(cblock.capacity, cblock.bits_per_entry); if (cblock.mask_size >= freed_size) kb_incr(&statCounter.cd.memory, cblock.mask_size - freed_size); @@ -833,8 +831,8 @@ /* TODO: we should calculate the prob of a false hit instead of bit util */ const int bit_util = cacheDigestBitUtil(pd->cd); if (bit_util > 65) { - debug(72, 0) ("Warning: %s peer digest has too many bits on (%d%%).\n", - strBuf(pd->host), bit_util); + debug(72, 0) ("Warning: %.*s peer digest has too many bits on (%d%%).\n", + strLen2(pd->host), strBuf2(pd->host), bit_util); return 0; } return 1;