--------------------- PatchSet 2988 Date: 2001/09/09 12:08:28 Author: serassio Branch: nt-2_3-tolsty Tag: (none) Log: Fixed indent problems Members: src/CacheDigest.c:1.1.1.2.4.1.2.1.2.1->1.1.1.2.4.1.2.1.2.2 src/peer_digest.c:1.1.1.3.4.1.2.1.2.1->1.1.1.3.4.1.2.1.2.2 src/peer_select.c:1.1.1.3.4.1.2.1.2.1->1.1.1.3.4.1.2.1.2.2 Index: squid/src/CacheDigest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/CacheDigest.c,v retrieving revision 1.1.1.2.4.1.2.1.2.1 retrieving revision 1.1.1.2.4.1.2.1.2.2 diff -u -r1.1.1.2.4.1.2.1.2.1 -r1.1.1.2.4.1.2.1.2.2 --- squid/src/CacheDigest.c 27 Aug 2001 21:48:18 -0000 1.1.1.2.4.1.2.1.2.1 +++ squid/src/CacheDigest.c 9 Sep 2001 12:08:28 -0000 1.1.1.2.4.1.2.1.2.2 @@ -1,5 +1,6 @@ + /* - * $Id: CacheDigest.c,v 1.1.1.2.4.1.2.1.2.1 2001/08/27 21:48:18 tolsty Exp $ + * $Id: CacheDigest.c,v 1.1.1.2.4.1.2.1.2.2 2001/09/09 12:08:28 serassio Exp $ * * DEBUG: section 70 Cache Digest * AUTHOR: Alex Rousskov @@ -37,14 +38,12 @@ #if USE_CACHE_DIGESTS /* local types */ -typedef struct -{ +typedef struct { int bit_count; /* total number of bits */ int bit_on_count; /* #bits turned on */ int bseq_len_sum; /* sum of all bit seq length */ int bseq_count; /* number of bit seqs */ -} -CacheDigestStats; +} CacheDigestStats; /* local functions */ static void cacheDigestHashKey(const CacheDigest * cd, const cache_key * key); @@ -63,8 +62,7 @@ cd->bits_per_entry = bpe; cd->mask_size = mask_size; cd->mask = xcalloc(cd->mask_size, 1); - debug(70, - 2) ("cacheDigestInit: capacity: %d entries, bpe: %d; size: %d bytes\n", + debug(70, 2) ("cacheDigestInit: capacity: %d entries, bpe: %d; size: %d bytes\n", cd->capacity, cd->bits_per_entry, cd->mask_size); } @@ -240,8 +238,7 @@ } void -cacheDigestGuessStatsReport(const cd_guess_stats * stats, StoreEntry * sentry, - const char *label) +cacheDigestGuessStatsReport(const cd_guess_stats * stats, StoreEntry * sentry, const char *label) { const int true_count = stats->true_hits + stats->true_misses; const int false_count = stats->false_hits + stats->false_misses; @@ -271,8 +268,7 @@ hit_count, xpercent(hit_count, tot_count), miss_count, xpercent(miss_count, tot_count), tot_count, xpercent(tot_count, tot_count)); - storeAppendPrintf(sentry, - "\tclose_hits: %d ( %d%%) /* cd said hit, doc was in the peer cache, but we got a miss */\n", + storeAppendPrintf(sentry, "\tclose_hits: %d ( %d%%) /* cd said hit, doc was in the peer cache, but we got a miss */\n", stats->close_hits, xpercentInt(stats->close_hits, stats->false_hits)); } @@ -283,22 +279,29 @@ assert(cd && e); cacheDigestStats(cd, &stats); storeAppendPrintf(e, "%s digest: size: %d bytes\n", - label ? label : "", stats.bit_count / 8); + label ? label : "", stats.bit_count / 8 + ); storeAppendPrintf(e, "\t entries: count: %d capacity: %d util: %d%%\n", - cd->count, cd->capacity, xpercentInt(cd->count, cd->capacity) + cd->count, + cd->capacity, + xpercentInt(cd->count, cd->capacity) + ); + storeAppendPrintf(e, "\t deletion attempts: %d\n", + cd->del_count ); - storeAppendPrintf(e, "\t deletion attempts: %d\n", cd->del_count); - storeAppendPrintf(e, - "\t bits: per entry: %d on: %d capacity: %d util: %d%%\n", - cd->bits_per_entry, stats.bit_on_count, stats.bit_count, + storeAppendPrintf(e, "\t bits: per entry: %d on: %d capacity: %d util: %d%%\n", + cd->bits_per_entry, + stats.bit_on_count, stats.bit_count, xpercentInt(stats.bit_on_count, stats.bit_count) ); storeAppendPrintf(e, "\t bit-seq: count: %d avg.len: %.2f\n", - stats.bseq_count, xdiv(stats.bseq_len_sum, stats.bseq_count) + stats.bseq_count, + xdiv(stats.bseq_len_sum, stats.bseq_count) ); } -size_t cacheDigestCalcMaskSize(int cap, int bpe) +size_t +cacheDigestCalcMaskSize(int cap, int bpe) { return (size_t) (cap * bpe + 7) / 8; } Index: squid/src/peer_digest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/peer_digest.c,v retrieving revision 1.1.1.3.4.1.2.1.2.1 retrieving revision 1.1.1.3.4.1.2.1.2.2 diff -u -r1.1.1.3.4.1.2.1.2.1 -r1.1.1.3.4.1.2.1.2.2 --- squid/src/peer_digest.c 27 Aug 2001 21:48:21 -0000 1.1.1.3.4.1.2.1.2.1 +++ squid/src/peer_digest.c 9 Sep 2001 12:08:28 -0000 1.1.1.3.4.1.2.1.2.2 @@ -1,5 +1,6 @@ + /* - * $Id: peer_digest.c,v 1.1.1.3.4.1.2.1.2.1 2001/08/27 21:48:21 tolsty Exp $ + * $Id: peer_digest.c,v 1.1.1.3.4.1.2.1.2.2 2001/09/09 12:08:28 serassio Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -49,16 +50,11 @@ static STCB peerDigestSwapInHeaders; static STCB peerDigestSwapInCBlock; static STCB peerDigestSwapInMask; -static int peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, - ssize_t size, const char *step_name); -static void peerDigestFetchStop(DigestFetchState * fetch, char *buf, - const char *reason); -static void peerDigestFetchAbort(DigestFetchState * fetch, char *buf, - const char *reason); -static void peerDigestReqFinish(DigestFetchState * fetch, char *buf, int, int, - int, const char *reason, int err); -static void peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, - int err); +static int peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, const char *step_name); +static void peerDigestFetchStop(DigestFetchState * fetch, char *buf, const char *reason); +static void peerDigestFetchAbort(DigestFetchState * fetch, char *buf, const char *reason); +static void peerDigestReqFinish(DigestFetchState * fetch, char *buf, int, int, int, const char *reason, int err); +static void peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, int err); static void peerDigestFetchFinish(DigestFetchState * fetch, int err); static void peerDigestFetchSetStats(DigestFetchState * fetch); static int peerDigestSetCBlock(PeerDigest * pd, const char *buf); @@ -172,7 +168,8 @@ peerDigestIncDelay(const PeerDigest * pd) { assert(pd); - return pd->times.retry_delay > 0 ? 2 * pd->times.retry_delay : /* exponential backoff */ + return pd->times.retry_delay > 0 ? + 2 * pd->times.retry_delay : /* exponential backoff */ PeerDigestReqMinGap; /* minimal delay */ } @@ -235,11 +232,9 @@ peerDigestNotePeerGone(pd); return; } - debug(72, 3) ("peerDigestCheck: peer %s:%d\n", pd->peer->host, - pd->peer->http_port); + debug(72, 3) ("peerDigestCheck: peer %s:%d\n", pd->peer->host, pd->peer->http_port); debug(72, 3) ("peerDigestCheck: time: %d, last received: %d (%+d)\n", - squid_curtime, pd->times.received, - (squid_curtime - pd->times.received)); + squid_curtime, pd->times.received, (squid_curtime - pd->times.received)); /* decide when we should send the request: * request now unless too close to other requests */ @@ -247,19 +242,16 @@ /* per-peer limit */ if (req_time - pd->times.received < PeerDigestReqMinGap) { - debug(72, 2) - - - ("peerDigestCheck: %s, avoiding close peer requests (%d < %d secs).\n", + debug(72, 2) ("peerDigestCheck: %s, avoiding close peer requests (%d < %d secs).\n", strBuf(pd->host), req_time - pd->times.received, 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), req_time - pd_last_req_time, GlobDigestReqMinGap); + debug(72, 2) ("peerDigestCheck: %s, avoiding close requests (%d < %d secs).\n", + strBuf(pd->host), req_time - pd_last_req_time, + GlobDigestReqMinGap); req_time = pd_last_req_time + GlobDigestReqMinGap; } if (req_time <= squid_curtime) @@ -357,10 +349,9 @@ assert(reply); httpReplyParse(reply, buf, hdr_size); status = reply->sline.status; - debug(72, - 3) ("peerDigestFetchReply: %s status: %d, expires: %d (%+d)\n", - strBuf(pd->host), status, reply->expires, - reply->expires - squid_curtime); + debug(72, 3) ("peerDigestFetchReply: %s status: %d, expires: %d (%+d)\n", + strBuf(pd->host), status, + reply->expires, reply->expires - squid_curtime); /* this "if" is based on clientHandleIMSReply() */ if (status == HTTP_NOT_MODIFIED) { @@ -371,8 +362,7 @@ fetch->old_entry->mem_obj->request = r = requestLink(fetch->entry->mem_obj->request); assert(fetch->old_entry->mem_obj->request); - httpReplyUpdateOnNotModified(fetch->old_entry->mem_obj->reply, - reply); + httpReplyUpdateOnNotModified(fetch->old_entry->mem_obj->reply, reply); storeTimestampsSet(fetch->old_entry); /* get rid of 304 reply */ storeUnregister(fetch->entry, fetch); @@ -385,8 +375,7 @@ } else if (status == HTTP_OK) { /* get rid of old entry if any */ if (fetch->old_entry) { - debug(72, 3) - ("peerDigestFetchReply: got new digest, releasing old one\n"); + debug(72, 3) ("peerDigestFetchReply: got new digest, releasing old one\n"); storeUnregister(fetch->old_entry, fetch); storeReleaseRequest(fetch->old_entry); storeUnlockObject(fetch->old_entry); @@ -394,8 +383,7 @@ } } else { /* some kind of a bug */ - peerDigestFetchAbort(fetch, buf, - httpStatusLineReason(&reply->sline)); + peerDigestFetchAbort(fetch, buf, httpStatusLineReason(&reply->sline)); return; } /* must have a ready-to-use store entry if we got here */ @@ -432,14 +420,14 @@ 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); + strBuf(fetch->pd->host), fetch->entry->mem_obj->reply->sline.status); peerDigestFetchAbort(fetch, buf, "internal status error"); return; } fetch->offset += hdr_size; storeClientCopy(fetch->entry, size, fetch->offset, - SM_PAGE_SIZE, buf, peerDigestSwapInCBlock, fetch); + SM_PAGE_SIZE, buf, + peerDigestSwapInCBlock, fetch); } else { /* need more data, do we have space? */ if (size >= SM_PAGE_SIZE) @@ -474,7 +462,9 @@ storeClientCopy(fetch->entry, seen, fetch->offset, - pd->cd->mask_size, pd->cd->mask, peerDigestSwapInMask, fetch); + pd->cd->mask_size, + pd->cd->mask, + peerDigestSwapInMask, fetch); } else { peerDigestFetchAbort(fetch, buf, "invalid digest cblock"); } @@ -515,13 +505,13 @@ fetch->offset, fetch->offset, buf_sz, - pd->cd->mask + fetch->mask_offset, peerDigestSwapInMask, fetch); + pd->cd->mask + fetch->mask_offset, + peerDigestSwapInMask, fetch); } } static int -peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, - const char *step_name) +peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, const char *step_name) { PeerDigest *pd = NULL; const char *host = ""; /* peer host */ @@ -609,7 +599,8 @@ /* complete the digest transfer, update stats, unlock/release everything */ static void peerDigestReqFinish(DigestFetchState * fetch, char *buf, - int fcb_valid, int pdcb_valid, int pcb_valid, const char *reason, int err) + int fcb_valid, int pdcb_valid, int pcb_valid, + const char *reason, int err) { assert(reason); @@ -658,7 +649,8 @@ if (err) { debug(72, 1) ("%sdisabling (%s) digest from %s\n", - pcb_valid ? "temporary " : "", pd->req_result, host); + pcb_valid ? "temporary " : "", + pd->req_result, host); if (pd->cd) { cacheDigestDestroy(pd->cd); @@ -780,12 +772,9 @@ 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, cacheDigestCalcMaskSize(cblock.capacity, - cblock.bits_per_entry)); + 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, cacheDigestCalcMaskSize(cblock.capacity, cblock.bits_per_entry)); return 0; } /* there are some things we cannot do yet */ @@ -854,8 +843,7 @@ cacheDigestGuessStatsReport(&pd->stats.guess, e, host); - storeAppendPrintf(e, - "\nevent\t timestamp\t secs from now\t secs from init\n"); + storeAppendPrintf(e, "\nevent\t timestamp\t secs from now\t secs from init\n"); appendTime(initialized); appendTime(needed); appendTime(requested); Index: squid/src/peer_select.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/peer_select.c,v retrieving revision 1.1.1.3.4.1.2.1.2.1 retrieving revision 1.1.1.3.4.1.2.1.2.2 diff -u -r1.1.1.3.4.1.2.1.2.1 -r1.1.1.3.4.1.2.1.2.2 --- squid/src/peer_select.c 27 Aug 2001 21:48:21 -0000 1.1.1.3.4.1.2.1.2.1 +++ squid/src/peer_select.c 9 Sep 2001 12:08:28 -0000 1.1.1.3.4.1.2.1.2.2 @@ -1,5 +1,6 @@ + /* - * $Id: peer_select.c,v 1.1.1.3.4.1.2.1.2.1 2001/08/27 21:48:21 tolsty Exp $ + * $Id: peer_select.c,v 1.1.1.3.4.1.2.1.2.2 2001/09/09 12:08:28 serassio Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -34,7 +35,8 @@ #include "squid.h" -const char *hier_strings[] = { +const char *hier_strings[] = +{ "NONE", "DIRECT", "SIBLING_HIT", @@ -60,13 +62,12 @@ "INVALID CODE" }; -static struct -{ +static struct { int timeouts; -} -PeerStats; +} PeerStats; -static char *DirectStr[] = { +static char *DirectStr[] = +{ "DIRECT_UNKNOWN", "DIRECT_NO", "DIRECT_MAYBE", @@ -128,7 +129,9 @@ void peerSelect(request_t * request, - StoreEntry * entry, PSC * callback, void *callback_data) + StoreEntry * entry, + PSC * callback, + void *callback_data) { ps_state *psstate = xcalloc(1, sizeof(ps_state)); if (entry) @@ -227,19 +230,28 @@ StoreEntry *entry = ps->entry; request_t *request = ps->request; debug(44, 3) ("peerSelectFoo: '%s %s'\n", - RequestMethodStr[request->method], request->host); + RequestMethodStr[request->method], + request->host); if (ps->direct == DIRECT_UNKNOWN) { if (ps->always_direct == 0 && Config.accessList.AlwaysDirect) { - ps->acl_checklist = - aclChecklistCreate(Config.accessList.AlwaysDirect, request, NULL); /* ident */ - aclNBCheck(ps->acl_checklist, peerCheckAlwaysDirectDone, ps); + ps->acl_checklist = aclChecklistCreate( + Config.accessList.AlwaysDirect, + request, + NULL); /* ident */ + aclNBCheck(ps->acl_checklist, + peerCheckAlwaysDirectDone, + ps); return; } else if (ps->always_direct > 0) { ps->direct = DIRECT_YES; } else if (ps->never_direct == 0 && Config.accessList.NeverDirect) { - ps->acl_checklist = - aclChecklistCreate(Config.accessList.NeverDirect, request, NULL); /* ident */ - aclNBCheck(ps->acl_checklist, peerCheckNeverDirectDone, ps); + ps->acl_checklist = aclChecklistCreate( + Config.accessList.NeverDirect, + request, + NULL); /* ident */ + aclNBCheck(ps->acl_checklist, + peerCheckNeverDirectDone, + ps); return; } else if (ps->never_direct > 0) { ps->direct = DIRECT_NO; @@ -248,7 +260,8 @@ } else { ps->direct = DIRECT_MAYBE; } - debug(44, 3) ("peerSelectFoo: direct = %s\n", DirectStr[ps->direct]); + debug(44, 3) ("peerSelectFoo: direct = %s\n", + DirectStr[ps->direct]); } if (entry == NULL) { (void) 0; @@ -311,7 +324,9 @@ ps->ping.n_sent = neighborsUdpPing(request, entry, peerHandlePingReply, - ps, &ps->ping.n_replies_expected, &ps->ping.timeout); + ps, + &ps->ping.n_replies_expected, + &ps->ping.timeout); if (ps->ping.n_sent == 0) debug(44, 0) ("WARNING: neighborsUdpPing returned 0\n"); debug(44, 3) ("peerSelect: %d ICP replies expected, RTT %d msec\n", @@ -319,7 +334,10 @@ if (ps->ping.n_replies_expected > 0) { entry->ping_status = PING_WAITING; eventAdd("peerPingTimeout", - peerPingTimeout, ps, 0.001 * ps->ping.timeout, 0); + peerPingTimeout, + ps, + 0.001 * ps->ping.timeout, + 0); return; } } @@ -398,7 +416,8 @@ request_t *request = ps->request; hier_code code = HIER_NONE; debug(44, 3) ("peerGetSomeParent: %s %s\n", - RequestMethodStr[request->method], request->host); + RequestMethodStr[request->method], + request->host); if (ps->direct == DIRECT_YES) return; if ((p = getDefaultParent(request))) { @@ -478,7 +497,8 @@ ps_state *psstate = data; icp_opcode op = header->opcode; debug(44, 3) ("peerHandleIcpReply: %s %s\n", - icp_opcode_str[op], storeUrl(psstate->entry)); + icp_opcode_str[op], + storeUrl(psstate->entry)); #if USE_CACHE_DIGESTS && 0 /* do cd lookup to count false misses */ if (p && request) @@ -513,7 +533,8 @@ { ps_state *psstate = data; debug(44, 3) ("peerHandleIcpReply: %s %s\n", - htcp->hit ? "HIT" : "MISS", storeUrl(psstate->entry)); + htcp->hit ? "HIT" : "MISS", + storeUrl(psstate->entry)); psstate->ping.n_recv++; if (htcp->hit) { psstate->hit = p; @@ -559,8 +580,7 @@ #endif static void -peerHandlePingReply(peer * p, peer_t type, protocol_t proto, void *pingdata, - void *data) +peerHandlePingReply(peer * p, peer_t type, protocol_t proto, void *pingdata, void *data) { if (proto == PROTO_ICP) peerHandleIcpReply(p, type, pingdata, data); @@ -569,8 +589,7 @@ peerHandleHtcpReply(p, type, pingdata, data); #endif else - debug(44, 1) ("peerHandlePingReply: unknown protocol_t %d\n", - (int) proto); + debug(44, 1) ("peerHandlePingReply: unknown protocol_t %d\n", (int) proto); } static void @@ -578,7 +597,8 @@ { FwdServer *fs = memAllocate(MEM_FWD_SERVER); debug(44, 5) ("peerAddFwdServer: adding %s %s\n", - p ? p->host : "DIRECT", hier_strings[code]); + p ? p->host : "DIRECT", + hier_strings[code]); fs->peer = p; fs->code = code; cbdataLock(fs->peer);