From: hno <> Date: Sun, 29 Apr 2007 04:26:37 +0000 (+0000) Subject: Author: Tsantilas Christos X-Git-Tag: SQUID_3_0_PRE6~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bf8fe701ad4d77da617b6847fdd42ed1eae940da;p=thirdparty%2Fsquid.git Author: Tsantilas Christos Convert debug statements to debugs --- diff --git a/src/ACLARP.cc b/src/ACLARP.cc index 7b2261da01..1af39c43ad 100644 --- a/src/ACLARP.cc +++ b/src/ACLARP.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLARP.cc,v 1.23 2006/12/21 20:01:00 serassio Exp $ + * $Id: ACLARP.cc,v 1.24 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -160,7 +160,7 @@ decode_eth(const char *asc, char *eth) int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0; if (sscanf(asc, "%x:%x:%x:%x:%x:%x", &a1, &a2, &a3, &a4, &a5, &a6) != 6) { - debug(28, 0) ("decode_eth: Invalid ethernet address '%s'\n", asc); + debugs(28, 0, "decode_eth: Invalid ethernet address '" << asc << "'"); return 0; /* This is not valid address */ } @@ -178,18 +178,17 @@ aclParseArpData(const char *t) { LOCAL_ARRAY(char, eth, 256); acl_arp_data *q = new acl_arp_data; - debug(28, 5) ("aclParseArpData: %s\n", t); + debugs(28, 5, "aclParseArpData: " << t); if (sscanf(t, "%[0-9a-fA-F:]", eth) != 1) { - debug(28, 0) ("aclParseArpData: Bad ethernet address: '%s'\n", t); + debugs(28, 0, "aclParseArpData: Bad ethernet address: '" << t << "'"); safe_free(q); return NULL; } if (!decode_eth(eth, q->eth)) { - debug(28, 0) ("%s line %d: %s\n", - cfg_filename, config_lineno, config_input_line); - debug(28, 0) ("aclParseArpData: Ignoring invalid ARP acl entry: can't parse '%s'\n", eth); + debugs(28, 0, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); + debugs(28, 0, "aclParseArpData: Ignoring invalid ARP acl entry: can't parse '" << eth << "'"); safe_free(q); return NULL; } @@ -276,16 +275,19 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) return 0; } - debug(28, 4) ("Got address %02x:%02x:%02x:%02x:%02x:%02x\n", - arpReq.arp_ha.sa_data[0] & 0xff, arpReq.arp_ha.sa_data[1] & 0xff, - arpReq.arp_ha.sa_data[2] & 0xff, arpReq.arp_ha.sa_data[3] & 0xff, - arpReq.arp_ha.sa_data[4] & 0xff, arpReq.arp_ha.sa_data[5] & 0xff); + debugs(28, 4, "Got address "<< std::setfill('0') << std::hex << + std::setw(2) << (arpReq.arp_ha.sa_data[0] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[1] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[2] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[3] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[4] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[5] & 0xff)); + /* Do lookup */ acl_arp_data X; memcpy (X.eth, arpReq.arp_ha.sa_data, 6); *Top = (*Top)->splay(&X, aclArpCompare); - debug(28, 3) ("aclMatchArp: '%s' %s\n", - inet_ntoa(c), splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found")); return (0 == splayLastResult); } @@ -295,13 +297,12 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) ifc.ifc_buf = (char *)ifbuffer; if (ioctl(HttpSockets[0], SIOCGIFCONF, &ifc) < 0) { - debug(28, 1) ("Attempt to retrieve interface list failed: %s\n", - xstrerror()); + debugs(28, 1, "Attempt to retrieve interface list failed: " << xstrerror()); return 0; } if (ifc.ifc_len > (int)sizeof(ifbuffer)) { - debug(28, 1) ("Interface list too long - %d\n", ifc.ifc_len); + debugs(28, 1, "Interface list too long - " << ifc.ifc_len); return 0; } @@ -320,8 +321,7 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) if (NULL != strchr(ifr->ifr_name, ':')) continue; - debug(28, 4) ("Looking up ARP address for %s on %s\n", inet_ntoa(c), - ifr->ifr_name); + debugs(28, 4, "Looking up ARP address for " << inet_ntoa(c) << " on " << ifr->ifr_name); /* Set up structures for ARP lookup */ ipAddr.sin_family = AF_INET; @@ -350,8 +350,7 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) else if (ENODEV == errno) (void) 0; else - debug(28, 1) ("ARP query failed: %s: %s\n", - ifr->ifr_name, xstrerror()); + debugs(28, 1, "ARP query failed: " << ifr->ifr_name << ": " << xstrerror()); continue; } @@ -360,13 +359,14 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) if (arpReq.arp_ha.sa_family != ARPHRD_ETHER) continue; - debug(28, 4) ("Got address %02x:%02x:%02x:%02x:%02x:%02x on %s\n", - arpReq.arp_ha.sa_data[0] & 0xff, - arpReq.arp_ha.sa_data[1] & 0xff, - arpReq.arp_ha.sa_data[2] & 0xff, - arpReq.arp_ha.sa_data[3] & 0xff, - arpReq.arp_ha.sa_data[4] & 0xff, - arpReq.arp_ha.sa_data[5] & 0xff, ifr->ifr_name); + debugs(28, 4, "Got address "<< std::setfill('0') << std::hex << + std::setw(2) << (arpReq.arp_ha.sa_data[0] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[1] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[2] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[3] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[4] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[5] & 0xff) << " on "<< + std::setfill(' ') << ifr->ifr_name); /* Do lookup */ acl_arp_data X; @@ -377,8 +377,7 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) /* Return if match, otherwise continue to other interfaces */ if (0 == splayLastResult) { - debug(28, 3) ("aclMatchArp: %s found on %s\n", - inet_ntoa(c), ifr->ifr_name); + debugs(28, 3, "aclMatchArp: " << inet_ntoa(c) << " found on " << ifr->ifr_name); return 1; } @@ -423,16 +422,18 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) arpReq.arp_ha.sa_data[4] == 0 && arpReq.arp_ha.sa_data[5] == 0) return 0; - debug(28, 4) ("Got address %02x:%02x:%02x:%02x:%02x:%02x\n", - arpReq.arp_ha.sa_data[0] & 0xff, arpReq.arp_ha.sa_data[1] & 0xff, - arpReq.arp_ha.sa_data[2] & 0xff, arpReq.arp_ha.sa_data[3] & 0xff, - arpReq.arp_ha.sa_data[4] & 0xff, arpReq.arp_ha.sa_data[5] & 0xff); + debugs(28, 4, "Got address "<< std::setfill('0') << std::hex << + std::setw(2) << (arpReq.arp_ha.sa_data[0] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[1] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[2] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[3] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[4] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[5] & 0xff)); /* Do lookup */ *Top = (*Top)->splay((acl_arp_data *)&arpReq.arp_ha.sa_data, aclArpCompare); - debug(28, 3) ("aclMatchArp: '%s' %s\n", - inet_ntoa(c), splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found")); return (0 == splayLastResult); } @@ -484,17 +485,17 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) mib[5] = RTF_LLINFO; if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) { - debug(28, 0) ("Can't estimate ARP table size!\n"); + debugs(28, 0, "Can't estimate ARP table size!"); return 0; } if ((buf = (char *)xmalloc(needed)) == NULL) { - debug(28, 0) ("Can't allocate temporary ARP table!\n"); + debugs(28, 0, "Can't allocate temporary ARP table!"); return 0; } if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { - debug(28, 0) ("Can't retrieve ARP table!\n"); + debugs(28, 0, "Can't retrieve ARP table!"); xfree(buf); return 0; } @@ -530,16 +531,18 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) arpReq.arp_ha.sa_data[4] == 0 && arpReq.arp_ha.sa_data[5] == 0) return 0; - debug(28, 4) ("Got address %02x:%02x:%02x:%02x:%02x:%02x\n", - arpReq.arp_ha.sa_data[0] & 0xff, arpReq.arp_ha.sa_data[1] & 0xff, - arpReq.arp_ha.sa_data[2] & 0xff, arpReq.arp_ha.sa_data[3] & 0xff, - arpReq.arp_ha.sa_data[4] & 0xff, arpReq.arp_ha.sa_data[5] & 0xff); + debugs(28, 4, "Got address "<< std::setfill('0') << std::hex << + std::setw(2) << (arpReq.arp_ha.sa_data[0] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[1] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[2] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[3] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[4] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[5] & 0xff)); /* Do lookup */ *Top = (*Top)->splay((acl_arp_data *)&arpReq.arp_ha.sa_data, aclArpCompare); - debug(28, 3) ("aclMatchArp: '%s' %s\n", - inet_ntoa(c), splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found")); return (0 == splayLastResult); @@ -561,19 +564,19 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) /* Get size of Windows ARP table */ if (GetIpNetTable(NetTable, &ipNetTableLen, FALSE) != ERROR_INSUFFICIENT_BUFFER) { - debug(28, 0) ("Can't estimate ARP table size!\n"); + debugs(28, 0, "Can't estimate ARP table size!"); return 0; } /* Allocate space for ARP table and assign pointers */ if ((NetTable = (PMIB_IPNETTABLE)xmalloc(ipNetTableLen)) == NULL) { - debug(28, 0) ("Can't allocate temporary ARP table!\n"); + debugs(28, 0, "Can't allocate temporary ARP table!"); return 0; } /* Get actual ARP table */ if ((dwNetTable = GetIpNetTable(NetTable, &ipNetTableLen, FALSE)) != NO_ERROR) { - debug(28, 0) ("Can't retrieve ARP table!\n"); + debugs(28, 0, "Can't retrieve ARP table!"); xfree(NetTable); return 0; } @@ -593,16 +596,18 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) arpReq.arp_ha.sa_data[4] == 0 && arpReq.arp_ha.sa_data[5] == 0) return 0; - debug(28, 4) ("Got address %02x:%02x:%02x:%02x:%02x:%02x\n", - arpReq.arp_ha.sa_data[0] & 0xff, arpReq.arp_ha.sa_data[1] & 0xff, - arpReq.arp_ha.sa_data[2] & 0xff, arpReq.arp_ha.sa_data[3] & 0xff, - arpReq.arp_ha.sa_data[4] & 0xff, arpReq.arp_ha.sa_data[5] & 0xff); + debugs(28, 4, "Got address "<< std::setfill('0') << std::hex << + std::setw(2) << (arpReq.arp_ha.sa_data[0] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[1] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[2] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[3] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[4] & 0xff) << ":" << + std::setw(2) << (arpReq.arp_ha.sa_data[5] & 0xff)); /* Do lookup */ *Top = (*Top)->splay((acl_arp_data *)&arpReq.arp_ha.sa_data, aclArpCompare); - debug(28, 3) ("aclMatchArp: '%s' %s\n", - inet_ntoa(c), splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchArp: '" << inet_ntoa(c) << "' " << (splayLastResult ? "NOT found" : "found")); return (0 == splayLastResult); @@ -614,7 +619,7 @@ aclMatchArp(SplayNode **dataptr, struct IN_ADDR c) /* * Address was not found on any interface */ - debug(28, 3) ("aclMatchArp: %s NOT found\n", inet_ntoa(c)); + debugs(28, 3, "aclMatchArp: " << inet_ntoa(c) << " NOT found"); return 0; } diff --git a/src/ACLChecklist.cc b/src/ACLChecklist.cc index 3e6fa4428b..d450c8e564 100644 --- a/src/ACLChecklist.cc +++ b/src/ACLChecklist.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLChecklist.cc,v 1.35 2007/04/20 22:24:07 wessels Exp $ + * $Id: ACLChecklist.cc,v 1.36 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -54,7 +54,7 @@ ACLChecklist::authenticated() /* WWW authorization on accelerated requests */ headertype = HDR_AUTHORIZATION; } else if (request->flags.transparent) { - debug(28, 1) ("ACHChecklist::authenticated: authentication not applicable on transparently intercepted requests.\n"); + debugs(28, 1, "ACHChecklist::authenticated: authentication not applicable on transparently intercepted requests."); return -1; } else { /* Proxy authorization on proxy requests */ @@ -66,7 +66,7 @@ ACLChecklist::authenticated() switch (AuthUserRequest::tryToAuthenticateAndSetAuthUser (&auth_user_request, headertype, request, conn(), src_addr)) { case AUTH_ACL_CANNOT_AUTHENTICATE: - debug(28, 4) ("aclMatchAcl: returning 0 user authenticated but not authorised.\n"); + debugs(28, 4, "aclMatchAcl: returning 0 user authenticated but not authorised."); return 0; case AUTH_AUTHENTICATED: @@ -75,12 +75,12 @@ ACLChecklist::authenticated() break; case AUTH_ACL_HELPER: - debug(28, 4) ("aclMatchAcl: returning 0 sending credentials to helper.\n"); + debugs(28, 4, "aclMatchAcl: returning 0 sending credentials to helper."); changeState (ProxyAuthLookup::Instance()); return 0; case AUTH_ACL_CHALLENGE: - debug(28, 4) ("aclMatchAcl: returning 0 sending authentication challenge.\n"); + debugs(28, 4, "aclMatchAcl: returning 0 sending authentication challenge."); changeState (ProxyAuthNeeded::Instance()); return 0; @@ -123,7 +123,7 @@ ACLChecklist::check() if (!cbdataReferenceValid(accessList)) { cbdataReferenceDone(accessList); - debug (28,4)("ACLChecklist::check: %p accessList is invalid\n", this); + debugs(28, 4, "ACLChecklist::check: " << this << " accessList is invalid"); continue; } @@ -140,7 +140,7 @@ ACLChecklist::check() * We are done. Either the request * is allowed, denied, requires authentication. */ - debug(28, 3) ("ACLChecklist::check: %p match found, calling back with %d\n", this, currentAnswer()); + debugs(28, 3, "ACLChecklist::check: " << this << " match found, calling back with " << currentAnswer()); cbdataReferenceDone(accessList); /* A */ checkCallback(currentAnswer()); /* From here on in, this may be invalid */ @@ -160,8 +160,9 @@ ACLChecklist::check() } /* dropped off the end of the list */ - debug(28, 3) ("ACLChecklist::check: %p NO match found, returning %d\n", this, - currentAnswer() != ACCESS_DENIED ? ACCESS_DENIED : ACCESS_ALLOWED); + debugs(28, 3, "ACLChecklist::check: " << this << + " NO match found, returning " << + (currentAnswer() != ACCESS_DENIED ? ACCESS_DENIED : ACCESS_ALLOWED)); checkCallback(currentAnswer() != ACCESS_DENIED ? ACCESS_DENIED : ACCESS_ALLOWED); } @@ -177,7 +178,8 @@ ACLChecklist::asyncInProgress(bool const newAsync) { assert (!finished() && !(asyncInProgress() && newAsync)); async_ = newAsync; - debug (28,3)("ACLChecklist::asyncInProgress: %p async set to %d\n", this, async_); + debugs(28, 3, "ACLChecklist::asyncInProgress: " << this << + " async set to " << async_); } void @@ -197,13 +199,14 @@ ACLChecklist::markFinished() { assert (!finished() && !asyncInProgress()); finished_ = true; - debug (28,3)("ACLChecklist::markFinished: %p checklist processing finished\n", this); + debugs(28, 3, "ACLChecklist::markFinished: " << this << + " checklist processing finished"); } void ACLChecklist::preCheck() { - debug(28, 3) ("ACLChecklist::preCheck: %p checking '%s'\n", this, accessList->cfgline); + debugs(28, 3, "ACLChecklist::preCheck: " << this << " checking '" << accessList->cfgline << "'"); /* what is our result on a match? */ currentAnswer(accessList->allow); } @@ -227,7 +230,8 @@ ACLChecklist::checkCallback(allow_t answer) { PF *callback_; void *cbdata_; - debug(28, 3) ("ACLChecklist::checkCallback: %p answer=%d\n", this, answer); + debugs(28, 3, "ACLChecklist::checkCallback: " << this << " answer=" << answer); + /* During reconfigure, we can end up not finishing call * sequences into the auth code */ @@ -265,15 +269,17 @@ ACLChecklist::matchAclList(const acl_list * head, bool const fast) changeState(NullState::Instance()); if (!nodeMatched || state_ != NullState::Instance()) { - debug(28, 3) ("aclmatchAclList: %p returning false (AND list entry failed to match)\n", this); + debugs(28, 3, "aclmatchAclList: " << this << " returning false (AND list entry failed to match)"); + bool async = state_ != NullState::Instance(); checkForAsync(); bool async_in_progress = asyncInProgress(); - debug(28,3)("aclmatchAclList: async=%d nodeMatched=%d async_in_progress=%d lastACLResult() = %d\n", - async ? 1 : 0, nodeMatched ? 1 : 0, async_in_progress ? 1 : 0, - lastACLResult() ? 1 : 0); + debugs(28, 3, "aclmatchAclList: async=" << (async ? 1 : 0) << + " nodeMatched=" << (nodeMatched ? 1 : 0) << + " async_in_progress=" << (async_in_progress ? 1 : 0) << + " lastACLResult() = " << (lastACLResult() ? 1 : 0)); if (async && nodeMatched && !asyncInProgress() && lastACLResult()) { // async acl, but using cached response, and it was a match @@ -292,7 +298,8 @@ ACLChecklist::matchAclList(const acl_list * head, bool const fast) node = node->next; } - debug(28, 3) ("aclmatchAclList: %p returning true (AND list satisfied)\n", this); + debugs(28, 3, "aclmatchAclList: " << this << " returning true (AND list satisfied)"); + markFinished(); PROF_stop(aclMatchAclList); } @@ -358,7 +365,7 @@ ACLChecklist::~ACLChecklist() cbdataReferenceDone(accessList); - debug (28,4)("ACLChecklist::~ACLChecklist: destroyed %p\n", this); + debugs(28, 4, "ACLChecklist::~ACLChecklist: destroyed " << this); } @@ -427,7 +434,7 @@ ACLChecklist::fastCheck() { PROF_start(aclCheckFast); currentAnswer(ACCESS_DENIED); - debug(28, 5) ("aclCheckFast: list: %p\n", accessList); + debugs(28, 5, "aclCheckFast: list: " << accessList); while (accessList) { preCheck(); @@ -451,7 +458,8 @@ ACLChecklist::fastCheck() cbdataReferenceDone(A); } - debug(28, 5) ("aclCheckFast: no matches, returning: %d\n", currentAnswer() == ACCESS_DENIED); + debugs(28, 5, "aclCheckFast: no matches, returning: " << (currentAnswer() == ACCESS_DENIED)); + PROF_stop(aclCheckFast); return currentAnswer() == ACCESS_DENIED; } diff --git a/src/ACLDestinationDomain.cc b/src/ACLDestinationDomain.cc index 8b90f7df8c..ccce7500ff 100644 --- a/src/ACLDestinationDomain.cc +++ b/src/ACLDestinationDomain.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLDestinationDomain.cc,v 1.12 2005/07/07 21:22:52 wessels Exp $ + * $Id: ACLDestinationDomain.cc,v 1.13 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -92,8 +92,7 @@ ACLDestinationDomainStrategy::match (ACLData * &data, ACLChecklist *c return data->match(fqdn); } else if (!checklist->destinationDomainChecked()) { /* FIXME: Using AclMatchedName here is not OO correct. Should find a way to the current acl */ - debug(28, 3) ("aclMatchAcl: Can't yet compare '%s' ACL for '%s'\n", - AclMatchedName, checklist->request->host); + debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << checklist->request->host << "'"); checklist->changeState(DestinationDomainLookup::Instance()); return 0; } diff --git a/src/ACLDestinationIP.cc b/src/ACLDestinationIP.cc index a5db7a20a2..e16a70ae2a 100644 --- a/src/ACLDestinationIP.cc +++ b/src/ACLDestinationIP.cc @@ -60,8 +60,7 @@ ACLDestinationIP::match(ACLChecklist *checklist) return 0; } else if (!checklist->request->flags.destinationIPLookedUp()) { /* No entry in cache, lookup not attempted */ - debug(28, 3) ("aclMatchAcl: Can't yet compare '%s' ACL for '%s'\n", - name, checklist->request->host); + debugs(28, 3, "aclMatchAcl: Can't yet compare '" << name << "' ACL for '" << checklist->request->host << "'"); checklist->changeState (DestinationIPLookup::Instance()); return 0; } else { diff --git a/src/ACLDomainData.cc b/src/ACLDomainData.cc index f2be463379..fb173eb20b 100644 --- a/src/ACLDomainData.cc +++ b/src/ACLDomainData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLDomainData.cc,v 1.12 2006/04/23 11:10:31 robertc Exp $ + * $Id: ACLDomainData.cc,v 1.13 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -100,9 +100,9 @@ aclDomainCompare(T const &a, T const &b) /* FIXME this warning may display d1 and d2 when it should display d3 and d4 */ if (ret == 0) { - debug(28, 0) ("WARNING: '%s' is a subdomain of '%s'\n", d1, d2); - debug(28, 0) ("WARNING: because of this '%s' is ignored to keep splay tree searching predictable\n", (char *) a); - debug(28, 0) ("WARNING: You should probably remove '%s' from the ACL named '%s'\n", d1, AclMatchedName); + debugs(28, 0, "WARNING: '" << d1 << "' is a subdomain of '" << d2 << "'"); + debugs(28, 0, "WARNING: because of this '" << (char *) a << "' is ignored to keep splay tree searching predictable"); + debugs(28, 0, "WARNING: You should probably remove '" << d1 << "' from the ACL named '" << AclMatchedName << "'"); } return ret; @@ -114,12 +114,11 @@ ACLDomainData::match(char const *host) if (host == NULL) return 0; - debug(28, 3) ("aclMatchDomainList: checking '%s'\n", host); + debugs(28, 3, "aclMatchDomainList: checking '" << host << "'"); domains = domains->splay((char *)host, aclHostDomainCompare); - debug(28, 3) ("aclMatchDomainList: '%s' %s\n", - host, splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchDomainList: '" << host << "' " << (splayLastResult ? "NOT found" : "found")); return !splayLastResult; } diff --git a/src/ACLExtUser.cc b/src/ACLExtUser.cc index 341f46b0b8..818d2cae4b 100644 --- a/src/ACLExtUser.cc +++ b/src/ACLExtUser.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLExtUser.cc,v 1.8 2005/05/08 06:53:58 hno Exp $ + * $Id: ACLExtUser.cc,v 1.9 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -70,7 +70,7 @@ ACLExtUser::typeString() const void ACLExtUser::parse() { - debug(28, 3) ("aclParseUserList: current is null. Creating\n"); + debugs(28, 3, "aclParseUserList: current is null. Creating"); data = new ACLUserData; data->parse(); } diff --git a/src/ACLHTTPHeaderData.cc b/src/ACLHTTPHeaderData.cc index 509681c84c..18bc4ec9f8 100644 --- a/src/ACLHTTPHeaderData.cc +++ b/src/ACLHTTPHeaderData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLHTTPHeaderData.cc,v 1.2 2006/08/05 12:05:35 robertc Exp $ + * $Id: ACLHTTPHeaderData.cc,v 1.3 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -63,7 +63,7 @@ ACLHTTPHeaderData::match(HttpHeader* hdr) if (hdr == NULL) return false; - debug(28, 3) ("aclHeaderData::match: checking '%s'\n", hdrName.buf()); + debugs(28, 3, "aclHeaderData::match: checking '" << hdrName.buf() << "'"); String value = hdrId != HDR_BAD_HDR ? hdr->getStrOrList(hdrId) : hdr->getByName(hdrName.buf()); diff --git a/src/ACLHTTPStatus.cc b/src/ACLHTTPStatus.cc index 6f67d4674c..4040f80a89 100644 --- a/src/ACLHTTPStatus.cc +++ b/src/ACLHTTPStatus.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLHTTPStatus.cc,v 1.2 2006/04/23 11:10:31 robertc Exp $ + * $Id: ACLHTTPStatus.cc,v 1.3 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -75,11 +75,9 @@ int acl_httpstatus_data::compare(acl_httpstatus_data* const& a, acl_httpstatus_d char bufb[8]; a->toStr(bufa, sizeof(bufa)); b->toStr(bufb, sizeof(bufb)); - debug(28, 0) ("WARNING: '%s' is a subrange of '%s'\n", bufa, bufb); - debug(28, 0) ("WARNING: because of this '%s' is ignored " - "to keep splay tree searching predictable\n", bufa); - debug(28, 0) ("WARNING: You should probably remove '%s' " - "from the ACL named '%s'\n", bufb, AclMatchedName); + debugs(28, 0, "WARNING: '" << bufa << "' is a subrange of '" << bufb << "'"); + debugs(28, 0, "WARNING: because of this '" << bufa << "' is ignored to keep splay tree searching predictable"); + debugs(28, 0, "WARNING: You should probably remove '" << bufb << "' from the ACL named '" << AclMatchedName << "'"); } return ret; @@ -174,8 +172,7 @@ aclMatchHTTPStatus(SplayNode **dataptr, http_status status SplayNode **Top = dataptr; *Top = Top[0]->splay(&X, aclHTTPStatusCompare); - debug(28, 3) ("aclMatchHTTPStatus: '%d' %s\n", status, - splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchHTTPStatus: '" << status << "' " << (splayLastResult ? "NOT found" : "found")); return (0 == splayLastResult); } diff --git a/src/ACLIP.cc b/src/ACLIP.cc index 0350e730a8..8f3743e54e 100644 --- a/src/ACLIP.cc +++ b/src/ACLIP.cc @@ -165,12 +165,12 @@ acl_ip_data::NetworkCompare(acl_ip_data * const & a, acl_ip_data * const &b) a->toStr(buf_n2, 60); a->toStr(buf_a, 60); /* TODO: this warning may display the wrong way around */ - debug(28, 0) ("WARNING: '%s' is a subnetwork of " - "'%s'\n", buf_n1, buf_n2); - debug(28, 0) ("WARNING: because of this '%s' is ignored " - "to keep splay tree searching predictable\n", buf_a); - debug(28, 0) ("WARNING: You should probably remove '%s' " - "from the ACL named '%s'\n", buf_n1, AclMatchedName); + debugs(28, 0, "WARNING: '" << buf_n1 << + "' is a subnetwork of '" << buf_n2 << "'"); + debugs(28, 0, "WARNING: because of this '" << buf_a << + "' is ignored to keep splay tree searching predictable"); + debugs(28, 0, "WARNING: You should probably remove '" << buf_n1 << + "' from the ACL named '" << AclMatchedName << "'"); } return ret; @@ -220,7 +220,7 @@ acl_ip_data::FactoryParse(const char *t) acl_ip_data **Q; char **x; char c; - debug(28, 5) ("aclParseIpData: %s\n", t); + debugs(28, 5, "aclParseIpData: " << t); acl_ip_data *q = new acl_ip_data; if (!strcasecmp(t, "all")) { @@ -254,7 +254,7 @@ acl_ip_data::FactoryParse(const char *t) struct hostent *hp; if ((hp = gethostbyname(addr1)) == NULL) { - debug(28, 0) ("aclParseIpData: Bad host/IP: '%s'\n", t); + debugs(28, 0, "aclParseIpData: Bad host/IP: '" << t << "'"); self_destruct(); } @@ -269,7 +269,7 @@ acl_ip_data::FactoryParse(const char *t) r->addr2.s_addr = 0; if (!DecodeMask(mask, &r->mask)) { - debug(28, 0) ("aclParseIpData: unknown netmask '%s' in '%s'\n", mask, t); + debugs(28, 0, "aclParseIpData: unknown netmask '" << mask << "' in '" << t << "'"); delete r; *Q = NULL; self_destruct(); @@ -279,11 +279,11 @@ acl_ip_data::FactoryParse(const char *t) Q = &r->next; - debug(28, 3) ("%s --> %s\n", addr1, inet_ntoa(r->addr1)); + debugs(28, 3, "" << addr1 << " --> " << inet_ntoa(r->addr1)); } if (*Q != NULL) { - debug(28, 0) ("aclParseIpData: Bad host/IP: '%s'\n", t); + debugs(28, 0, "aclParseIpData: Bad host/IP: '" << t << "'"); self_destruct(); } @@ -292,7 +292,7 @@ acl_ip_data::FactoryParse(const char *t) /* Decode addr1 */ if (!safe_inet_addr(addr1, &q->addr1)) { - debug(28, 0) ("aclParseIpData: unknown first address in '%s'\n", t); + debugs(28, 0, "aclParseIpData: unknown first address in '" << t << "'"); delete q; self_destruct(); return NULL; @@ -300,7 +300,7 @@ acl_ip_data::FactoryParse(const char *t) /* Decode addr2 */ if (!safe_inet_addr(addr2, &q->addr2)) { - debug(28, 0) ("aclParseIpData: unknown second address in '%s'\n", t); + debugs(28, 0, "aclParseIpData: unknown second address in '" << t << "'"); delete q; self_destruct(); return NULL; @@ -308,7 +308,7 @@ acl_ip_data::FactoryParse(const char *t) /* Decode mask */ if (!DecodeMask(mask, &q->mask)) { - debug(28, 0) ("aclParseIpData: unknown netmask '%s' in '%s'\n", mask, t); + debugs(28, 0, "aclParseIpData: unknown netmask '" << mask << "' in '" << t << "'"); delete q; self_destruct(); return NULL; @@ -316,7 +316,7 @@ acl_ip_data::FactoryParse(const char *t) if ((q->addr1.s_addr & q->mask.s_addr) != q->addr1.s_addr || (q->addr2.s_addr & q->mask.s_addr) != q->addr2.s_addr) - debug(28, 0) ("aclParseIpData: WARNING: Netmask masks away part of the specified IP in '%s'\n", t); + debugs(28, 0, "aclParseIpData: WARNING: Netmask masks away part of the specified IP in '" << t << "'"); q->addr1.s_addr &= q->mask.s_addr; @@ -376,8 +376,7 @@ ACLIP::match(struct IN_ADDR &clientip) ClientAddress.addr1 = clientip; acl_ip_data *ClientAddressPointer = &ClientAddress; data = data->splay(ClientAddressPointer, aclIpAddrNetworkCompare); - debug(28, 3) ("aclMatchIp: '%s' %s\n", - inet_ntoa(clientip), splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchIp: '" << inet_ntoa(clientip) << "' " << (splayLastResult ? "NOT found" : "found")); return !splayLastResult; } diff --git a/src/ACLIdent.cc b/src/ACLIdent.cc index 18a5e4583f..e9c2ad1a3b 100644 --- a/src/ACLIdent.cc +++ b/src/ACLIdent.cc @@ -70,7 +70,7 @@ void ACLIdent::parse() { if (!data) { - debug(28, 3) ("aclParseUserList: current is null. Creating\n"); + debugs(28, 3, "aclParseUserList: current is null. Creating"); data = new ACLUserData; } @@ -85,7 +85,7 @@ ACLIdent::match(ACLChecklist *checklist) } else if (checklist->conn() != NULL && checklist->conn()->rfc931[0]) { return data->match(checklist->conn()->rfc931); } else { - debug(28, 3) ("ACLIdent::match() - switching to ident lookup state\n"); + debugs(28, 3, "ACLIdent::match() - switching to ident lookup state"); checklist->changeState(IdentLookup::Instance()); return 0; } @@ -126,12 +126,12 @@ void IdentLookup::checkForAsync(ACLChecklist *checklist)const { if (checklist->conn() != NULL) { - debug(28, 3) ("IdentLookup::checkForAsync: Doing ident lookup\n"); + debugs(28, 3, "IdentLookup::checkForAsync: Doing ident lookup" ); checklist->asyncInProgress(true); identStart(&checklist->conn()->me, &checklist->conn()->peer, LookupDone, checklist); } else { - debug(28, 1) ("IdentLookup::checkForAsync: Can't start ident lookup. No client connection\n"); + debugs(28, 1, "IdentLookup::checkForAsync: Can't start ident lookup. No client connection" ); checklist->currentAnswer(ACCESS_DENIED); checklist->markFinished(); } diff --git a/src/ACLIntRange.cc b/src/ACLIntRange.cc index 60efec9d37..d8b385d2d2 100644 --- a/src/ACLIntRange.cc +++ b/src/ACLIntRange.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLIntRange.cc,v 1.9 2006/10/08 13:10:34 serassio Exp $ + * $Id: ACLIntRange.cc,v 1.10 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Robert Collins @@ -69,7 +69,7 @@ ACLIntRange::parse() temp.end = port2+1; ranges.push_back(temp); } else { - debug(28, 0) ("ACLIntRange::parse: Invalid port value\n"); + debugs(28, 0, "ACLIntRange::parse: Invalid port value"); self_destruct(); } } diff --git a/src/ACLMaxConnection.cc b/src/ACLMaxConnection.cc index 3cc3041630..a3f2a0b3ff 100644 --- a/src/ACLMaxConnection.cc +++ b/src/ACLMaxConnection.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLMaxConnection.cc,v 1.6 2006/04/23 11:10:31 robertc Exp $ + * $Id: ACLMaxConnection.cc,v 1.7 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -121,5 +121,5 @@ ACLMaxConnection::prepareForUse() if (0 != Config.onoff.client_db) return; - debug(22, 0) ("WARNING: 'maxconn' ACL (%s) won't work with client_db disabled\n", name); + debugs(22, 0, "WARNING: 'maxconn' ACL (" << name << ") won't work with client_db disabled"); } diff --git a/src/ACLMaxUserIP.cc b/src/ACLMaxUserIP.cc index e02c1a9729..1cb109acad 100644 --- a/src/ACLMaxUserIP.cc +++ b/src/ACLMaxUserIP.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLMaxUserIP.cc,v 1.11 2006/10/08 13:10:34 serassio Exp $ + * $Id: ACLMaxUserIP.cc,v 1.12 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -82,7 +82,7 @@ void ACLMaxUserIP::parse() { if (maximum) { - debug(28, 1) ("Attempting to alter already set User max IP acl\n"); + debugs(28, 1, "Attempting to alter already set User max IP acl"); return; } @@ -91,10 +91,10 @@ ACLMaxUserIP::parse() if (!t) return; - debug(28, 5) ("aclParseUserMaxIP: First token is %s\n", t); + debugs(28, 5, "aclParseUserMaxIP: First token is " << t); if (strcmp("-s", t) == 0) { - debug(28, 5) ("aclParseUserMaxIP: Going strict\n"); + debugs(28, 5, "aclParseUserMaxIP: Going strict"); flags.strict = 1; t = ConfigParser::strtokFile(); } @@ -104,7 +104,7 @@ ACLMaxUserIP::parse() maximum = xatoi(t); - debug(28, 5) ("aclParseUserMaxIP: Max IP address's %d\n", (int) maximum); + debugs(28, 5, "aclParseUserMaxIP: Max IP address's " << (int) maximum); return; } @@ -128,7 +128,7 @@ ACLMaxUserIP::match(auth_user_request_t * auth_user_request, if (authenticateAuthUserRequestIPCount(auth_user_request) <= maximum) return 0; - debug(28, 1) ("aclMatchUserMaxIP: user '%s' tries to use too many IP addresses (max %d allowed)!\n", auth_user_request->username(), maximum); + debugs(28, 1, "aclMatchUserMaxIP: user '" << auth_user_request->username() << "' tries to use too many IP addresses (max " << maximum << " allowed)!"); /* this is a match */ if (flags.strict) @@ -139,7 +139,7 @@ ACLMaxUserIP::match(auth_user_request_t * auth_user_request, */ /* remove _this_ ip, as it is the culprit for going over the limit */ authenticateAuthUserRequestRemoveIp(auth_user_request, src_addr); - debug(28, 4) ("aclMatchUserMaxIP: Denying access in strict mode\n"); + debugs(28, 4, "aclMatchUserMaxIP: Denying access in strict mode"); } else { /* @@ -147,7 +147,7 @@ ACLMaxUserIP::match(auth_user_request_t * auth_user_request, * ie to allow the user to move machines easily */ authenticateAuthUserRequestClearIp(auth_user_request); - debug(28, 4) ("aclMatchUserMaxIP: Denying access in non-strict mode - flushing the user ip cache\n"); + debugs(28, 4, "aclMatchUserMaxIP: Denying access in non-strict mode - flushing the user ip cache"); } return 1; diff --git a/src/ACLProxyAuth.cc b/src/ACLProxyAuth.cc index efba6a5311..8a18842a63 100644 --- a/src/ACLProxyAuth.cc +++ b/src/ACLProxyAuth.cc @@ -104,12 +104,12 @@ bool ACLProxyAuth::valid () const { if (authenticateSchemeCount() == 0) { - debug(28, 0) ("Can't use proxy auth because no authentication schemes were compiled.\n"); + debugs(28, 0, "Can't use proxy auth because no authentication schemes were compiled."); return false; } if (authenticateActiveSchemeCount() == 0) { - debug(28, 0) ("Can't use proxy auth because no authentication schemes are fully configured.\n"); + debugs(28, 0, "Can't use proxy auth because no authentication schemes are fully configured."); return false; } @@ -136,8 +136,7 @@ void ProxyAuthLookup::checkForAsync(ACLChecklist *checklist)const { checklist->asyncInProgress(true); - debug(28, 3) - ("ACLChecklist::checkForAsync: checking password via authenticator\n"); + debugs(28, 3, "ACLChecklist::checkForAsync: checking password via authenticator"); auth_user_request_t *auth_user_request; /* make sure someone created auth_user_request for us */ @@ -183,7 +182,7 @@ ProxyAuthNeeded::checkForAsync(ACLChecklist *checklist) const * credentials. (This may be part of a stateful auth protocol.) * The request is denied. */ - debug(28, 6) ("ACLChecklist::checkForAsync: requiring Proxy Auth header.\n"); + debugs(28, 6, "ACLChecklist::checkForAsync: requiring Proxy Auth header."); checklist->currentAnswer(ACCESS_REQ_PROXY_AUTH); checklist->changeState (ACLChecklist::NullState::Instance()); checklist->markFinished(); diff --git a/src/ACLRegexData.cc b/src/ACLRegexData.cc index d738ebd7ae..28d3021ce5 100644 --- a/src/ACLRegexData.cc +++ b/src/ACLRegexData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLRegexData.cc,v 1.10 2006/05/29 19:05:26 serassio Exp $ + * $Id: ACLRegexData.cc,v 1.11 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -67,7 +67,7 @@ ACLRegexData::match(char const *word) if (word == NULL) return 0; - debug(28, 3) ("aclRegexData::match: checking '%s'\n", word); + debugs(28, 3, "aclRegexData::match: checking '" << word << "'"); relist *first, *prev; @@ -78,7 +78,7 @@ ACLRegexData::match(char const *word) relist *current = first; while (current) { - debug(28, 3) ("aclRegexData::match: looking for '%s'\n", current->pattern); + debugs(28, 3, "aclRegexData::match: looking for '" << current->pattern << "'"); if (regexec(¤t->regex, word, 0, 0, 0) == 0) { if (prev != NULL) { @@ -89,7 +89,7 @@ ACLRegexData::match(char const *word) first->next = current; } - debug(28, 2) ("aclRegexData::match: match '%s' found in '%s'\n", current->pattern, word); + debugs(28, 2, "aclRegexData::match: match '" << current->pattern << "' found in '" << word << "'"); return 1; } @@ -142,10 +142,8 @@ aclParseRegexList(relist **curlist) if ((errcode = regcomp(&comp, t, flags)) != 0) { char errbuf[256]; regerror(errcode, &comp, errbuf, sizeof errbuf); - debug(28, 0) ("%s line %d: %s\n", - cfg_filename, config_lineno, config_input_line); - debug(28, 0) ("aclParseRegexList: Invalid regular expression '%s': %s\n", - t, errbuf); + debugs(28, 0, "" << cfg_filename << " line " << config_lineno << ": " << config_input_line); + debugs(28, 0, "aclParseRegexList: Invalid regular expression '" << t << "': " << errbuf); continue; } diff --git a/src/ACLSourceDomain.cc b/src/ACLSourceDomain.cc index ed71ac4517..bbc830a3fa 100644 --- a/src/ACLSourceDomain.cc +++ b/src/ACLSourceDomain.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLSourceDomain.cc,v 1.4 2005/05/09 01:41:25 hno Exp $ + * $Id: ACLSourceDomain.cc,v 1.5 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -82,8 +82,7 @@ ACLSourceDomainStrategy::match (ACLData * &data, ACLChecklist *checkl return data->match(fqdn); } else if (!checklist->sourceDomainChecked()) { /* FIXME: Using AclMatchedName here is not OO correct. Should find a way to the current acl */ - debug(28, 3) ("aclMatchAcl: Can't yet compare '%s' ACL for '%s'\n", - AclMatchedName, inet_ntoa(checklist->src_addr)); + debugs(28, 3, "aclMatchAcl: Can't yet compare '" << AclMatchedName << "' ACL for '" << inet_ntoa(checklist->src_addr) << "'"); checklist->changeState(SourceDomainLookup::Instance()); return 0; } diff --git a/src/ACLStringData.cc b/src/ACLStringData.cc index 27a079bf12..4fa85ae779 100644 --- a/src/ACLStringData.cc +++ b/src/ACLStringData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLStringData.cc,v 1.8 2006/04/23 11:10:31 robertc Exp $ + * $Id: ACLStringData.cc,v 1.9 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -73,12 +73,11 @@ ACLStringData::match(char const *toFind) if (!values || !toFind) return 0; - debug(28, 3) ("aclMatchStringList: checking '%s'\n", toFind); + debugs(28, 3, "aclMatchStringList: checking '" << toFind << "'"); values = values->splay((char *)toFind, splaystrcmp); - debug(28, 3) ("aclMatchStringList: '%s' %s\n", - toFind, splayLastResult ? "NOT found" : "found"); + debugs(28, 3, "aclMatchStringList: '" << toFind << "' " << (splayLastResult ? "NOT found" : "found")); return !splayLastResult; } diff --git a/src/ACLTimeData.cc b/src/ACLTimeData.cc index 1093bc3def..57c344463e 100644 --- a/src/ACLTimeData.cc +++ b/src/ACLTimeData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLTimeData.cc,v 1.13 2006/10/09 12:43:02 hno Exp $ + * $Id: ACLTimeData.cc,v 1.14 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -86,8 +86,9 @@ ACLTimeData::match(time_t when) ACLTimeData *data = this; while (data) { - debug(28, 3) ("aclMatchTime: checking %d in %d-%d, weekbits=%x\n", - (int) t, (int) data->start, (int) data->stop, data->weekbits); + debugs(28, 3, "aclMatchTime: checking " << (int) t << " in " << + (int) data->start << "-" << (int) data->stop << ", weekbits=" << + std::hex << data->weekbits); if (t >= data->start && t <= data->stop && (data->weekbits & (1 << tm.tm_wday))) return 1; @@ -181,9 +182,9 @@ ACLTimeData::parse() break; default: - debug(28, 0) ("%s line %d: %s\n", - cfg_filename, config_lineno, config_input_line); - debug(28, 0) ("aclParseTimeSpec: Bad Day '%c'\n", *t); + debugs(28, 0, "" << cfg_filename << " line " << config_lineno << + ": " << config_input_line); + debugs(28, 0, "aclParseTimeSpec: Bad Day '" << *t << "'" ); break; } } @@ -191,7 +192,7 @@ ACLTimeData::parse() /* assume its time-of-day spec */ if ((sscanf(t, "%d:%d-%d:%d", &h1, &m1, &h2, &m2) < 4) || (!((h1 >= 0 && h1 < 24) && ((h2 >= 0 && h2 < 24) || (h2 == 24 && m2 == 0)) && (m1 >= 0 && m1 < 60) && (m2 >= 0 && m2 < 60)))) { - debug(28, 0) ("aclParseTimeSpec: Bad time range '%s'\n", t); + debugs(28, 0, "aclParseTimeSpec: Bad time range '" << t << "'"); self_destruct(); if (q != this) @@ -214,7 +215,7 @@ ACLTimeData::parse() weekbits = 0; if (q->start > q->stop) { - debug(28, 0) ("aclParseTimeSpec: Reversed time range\n"); + debugs(28, 0, "aclParseTimeSpec: Reversed time range"); self_destruct(); if (q != this) diff --git a/src/ACLUserData.cc b/src/ACLUserData.cc index 4d1226d856..65f0012154 100644 --- a/src/ACLUserData.cc +++ b/src/ACLUserData.cc @@ -71,16 +71,14 @@ ACLUserData::match(char const *user) { SplayNode *Top = names; - debug(28, 7) ("aclMatchUser: user is %s, case_insensitive is %d\n", - user, flags.case_insensitive); - debug(28, 8) ("Top is %p, Top->data is %s\n", Top, - (char *) (Top != NULL ? (Top)->data : "Unavailable")); + debugs(28, 7, "aclMatchUser: user is " << user << ", case_insensitive is " << flags.case_insensitive); + debugs(28, 8, "Top is " << Top << ", Top->data is " << ((char *) (Top != NULL ? (Top)->data : "Unavailable"))); if (user == NULL || strcmp(user, "-") == 0) return 0; if (flags.required) { - debug(28, 7) ("aclMatchUser: user REQUIRED and auth-info present.\n"); + debugs(28, 7, "aclMatchUser: user REQUIRED and auth-info present."); return 1; } @@ -90,8 +88,8 @@ ACLUserData::match(char const *user) Top = Top->splay((char *)user, splaystrcmp); /* Top=splay_splay(user,Top,(splayNode::SPLAYCMP *)dumping_strcmp); */ - debug(28, 7) ("aclMatchUser: returning %d,Top is %p, Top->data is %s\n", - !splayLastResult, Top, (char *) (Top ? Top->data : "Unavailable")); + debugs(28, 7, "aclMatchUser: returning " << !splayLastResult << ",Top is " << + Top << ", Top->data is " << ((char *) (Top ? Top->data : "Unavailable"))); names = Top; @@ -128,17 +126,17 @@ ACLUserData::dump() void ACLUserData::parse() { - debug(28, 2) ("aclParseUserList: parsing user list\n"); + debugs(28, 2, "aclParseUserList: parsing user list"); char *t = NULL; if ((t = ConfigParser::strtokFile())) { - debug(28, 5) ("aclParseUserList: First token is %s\n", t); + debugs(28, 5, "aclParseUserList: First token is " << t); if (strcmp("-i", t) == 0) { - debug(28, 5) ("aclParseUserList: Going case-insensitive\n"); + debugs(28, 5, "aclParseUserList: Going case-insensitive"); flags.case_insensitive = 1; } else if (strcmp("REQUIRED", t) == 0) { - debug(28, 5) ("aclParseUserList: REQUIRED-type enabled\n"); + debugs(28, 5, "aclParseUserList: REQUIRED-type enabled"); flags.required = 1; } else { if (flags.case_insensitive) @@ -148,14 +146,13 @@ ACLUserData::parse() } } - debug(28, 3) ("aclParseUserList: Case-insensitive-switch is %d\n", - flags.case_insensitive); + debugs(28, 3, "aclParseUserList: Case-insensitive-switch is " << flags.case_insensitive); /* we might inherit from a previous declaration */ - debug(28, 4) ("aclParseUserList: parsing user list\n"); + debugs(28, 4, "aclParseUserList: parsing user list"); while ((t = ConfigParser::strtokFile())) { - debug(28, 6) ("aclParseUserList: Got token: %s\n", t); + debugs(28, 6, "aclParseUserList: Got token: " << t); if (flags.case_insensitive) Tolower(t); diff --git a/src/AuthConfig.cc b/src/AuthConfig.cc index 361c1b14e2..74a0b2c3f2 100644 --- a/src/AuthConfig.cc +++ b/src/AuthConfig.cc @@ -1,6 +1,6 @@ /* - * $Id: AuthConfig.cc,v 1.2 2006/05/29 00:14:59 robertc Exp $ + * $Id: AuthConfig.cc,v 1.3 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -46,12 +46,12 @@ AuthUserRequest * AuthConfig::CreateAuthUser(const char *proxy_auth) { assert(proxy_auth != NULL); - debug(29, 9) ("AuthConfig::CreateAuthUser: header = '%s'\n", proxy_auth); + debugs(29, 9, "AuthConfig::CreateAuthUser: header = '" << proxy_auth << "'"); AuthConfig *config = Find(proxy_auth); if (config == NULL || !config->active()) { - debug(29, 1) ("AuthConfig::CreateAuthUser: Unsupported or unconfigured/inactive proxy-auth scheme, '%s'\n", proxy_auth); + debugs(29, 1, "AuthConfig::CreateAuthUser: Unsupported or unconfigured/inactive proxy-auth scheme, '" << proxy_auth << "'"); return NULL; } diff --git a/src/AuthUser.cc b/src/AuthUser.cc index 05e333bcd5..058b95ec5b 100644 --- a/src/AuthUser.cc +++ b/src/AuthUser.cc @@ -1,6 +1,6 @@ /* - * $Id: AuthUser.cc,v 1.3 2007/01/03 12:40:41 hno Exp $ + * $Id: AuthUser.cc,v 1.4 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -58,7 +58,7 @@ AuthUser::AuthUser (AuthConfig *aConfig) : proxy_match_cache.head = proxy_match_cache.tail = NULL; ip_list.head = ip_list.tail = NULL; requests.head = requests.tail = NULL; - debug(29, 5) ("AuthUser::AuthUser: Initialised auth_user '%p' with refcount '%ld'.\n", this, (long int) references); + debugs(29, 5, "AuthUser::AuthUser: Initialised auth_user '" << this << "' with refcount '" << (long int) references << "'."); } /* Combine two user structs. ONLY to be called from within a scheme @@ -76,7 +76,7 @@ AuthUser::absorb (AuthUser *from) * in hash references too and ask the module to merge in scheme * data */ - debug(29, 5) ("authenticateAuthUserMerge auth_user '%p' into auth_user '%p'.\n", from, this); + debugs(29, 5, "authenticateAuthUserMerge auth_user '" << from << "' into auth_user '" << this << "'."); dlink_node *link = from->requests.head; while (link) { @@ -97,13 +97,13 @@ AuthUser::~AuthUser() { auth_user_request_t *auth_user_request; dlink_node *link, *tmplink; - debug(29, 5) ("AuthUser::~AuthUser: Freeing auth_user '%p' with refcount '%ld'.\n", this, (long int) references); + debugs(29, 5, "AuthUser::~AuthUser: Freeing auth_user '" << this << "' with refcount '" << (long int) references << "'."); assert(references == 0); /* were they linked in by username ? */ if (usernamehash) { assert(usernamehash->user() == this); - debug(29, 5) ("AuthUser::~AuthUser: removing usernamehash entry '%p'\n", usernamehash); + debugs(29, 5, "AuthUser::~AuthUser: removing usernamehash entry '" << usernamehash << "'"); hash_remove_link(proxy_auth_username_cache, (hash_link *) usernamehash); /* don't free the key as we use the same user string as the auth_user @@ -115,7 +115,7 @@ AuthUser::~AuthUser() link = requests.head; while (link) { - debug(29, 5) ("AuthUser::~AuthUser: removing request entry '%p'\n", link->data); + debugs(29, 5, "AuthUser::~AuthUser: removing request entry '" << link->data << "'"); auth_user_request = static_cast(link->data); tmplink = link; link = link->next; @@ -159,7 +159,7 @@ AuthUser::CachedACLsReset() AuthUserHashPointer *usernamehash; auth_user_t *auth_user; char const *username = NULL; - debug(29, 3) ("AuthUser::CachedACLsReset: Flushing the ACL caches for all users.\n"); + debugs(29, 3, "AuthUser::CachedACLsReset: Flushing the ACL caches for all users."); hash_first(proxy_auth_username_cache); while ((usernamehash = ((AuthUserHashPointer *) hash_next(proxy_auth_username_cache)))) { @@ -170,7 +170,7 @@ AuthUser::CachedACLsReset() } - debug(29, 3) ("AuthUser::CachedACLsReset: Finished.\n"); + debugs(29, 3, "AuthUser::CachedACLsReset: Finished."); } void @@ -184,8 +184,8 @@ AuthUser::cacheCleanup(void *datanotused) AuthUserHashPointer *usernamehash; auth_user_t *auth_user; char const *username = NULL; - debug(29, 3) ("AuthUser::cacheCleanup: Cleaning the user cache now\n"); - debug(29, 3) ("AuthUser::cacheCleanup: Current time: %ld\n", (long int) current_time.tv_sec); + debugs(29, 3, "AuthUser::cacheCleanup: Cleaning the user cache now"); + debugs(29, 3, "AuthUser::cacheCleanup: Current time: " << (long int) current_time.tv_sec); hash_first(proxy_auth_username_cache); while ((usernamehash = ((AuthUserHashPointer *) hash_next(proxy_auth_username_cache)))) { @@ -194,10 +194,14 @@ AuthUser::cacheCleanup(void *datanotused) /* if we need to have inpedendent expiry clauses, insert a module call * here */ - debug(29, 4) ("AuthUser::cacheCleanup: Cache entry:\n\tType: %d\n\tUsername: %s\n\texpires: %ld\n\treferences: %ld\n", auth_user->auth_type, username, (long int) (auth_user->expiretime + Config.authenticateTTL), (long int) auth_user->references); + debugs(29, 4, "AuthUser::cacheCleanup: Cache entry:\n\tType: " << + auth_user->auth_type << "\n\tUsername: " << username << + "\n\texpires: " << + (long int) (auth_user->expiretime + Config.authenticateTTL) << + "\n\treferences: " << (long int) auth_user->references); if (auth_user->expiretime + Config.authenticateTTL <= current_time.tv_sec) { - debug(29, 5) ("AuthUser::cacheCleanup: Removing user %s from cache due to timeout.\n", username); + debugs(29, 5, "AuthUser::cacheCleanup: Removing user " << username << " from cache due to timeout."); /* the minus 1 accounts for the cache lock */ if (!(authenticateAuthUserInuse(auth_user) - 1)) @@ -209,7 +213,7 @@ AuthUser::cacheCleanup(void *datanotused) } } - debug(29, 3) ("AuthUser::cacheCleanup: Finished cleaning the user cache.\n"); + debugs(29, 3, "AuthUser::cacheCleanup: Finished cleaning the user cache."); eventAdd("User Cache Maintenance", cacheCleanup, NULL, Config.authenticateGCInterval, 1); } @@ -311,7 +315,7 @@ AuthUser::addIp(struct IN_ADDR ipaddr) ip1 = xstrdup(inet_ntoa(ipaddr)); - debug(29, 2) ("authenticateAuthUserAddIp: user '%s' has been seen at a new IP address (%s)\n", username(), ip1); + debugs(29, 2, "authenticateAuthUserAddIp: user '" << username() << "' has been seen at a new IP address (" << ip1 << ")"); safe_free(ip1); } @@ -320,25 +324,25 @@ AuthUser::addIp(struct IN_ADDR ipaddr) void AuthUser::lock() { - debug(29, 9) ("authenticateAuthUserLock auth_user '%p'.\n", this); + debugs(29, 9, "authenticateAuthUserLock auth_user '" << this << "'."); assert(this != NULL); references++; - debug(29, 9) ("authenticateAuthUserLock auth_user '%p' now at '%ld'.\n", this, (long int) references); + debugs(29, 9, "authenticateAuthUserLock auth_user '" << this << "' now at '" << (long int) references << "'."); } void AuthUser::unlock() { - debug(29, 9) ("authenticateAuthUserUnlock auth_user '%p'.\n", this); + debugs(29, 9, "authenticateAuthUserUnlock auth_user '" << this << "'."); assert(this != NULL); if (references > 0) { references--; } else { - debug(29, 1) ("Attempt to lower Auth User %p refcount below 0!\n", this); + debugs(29, 1, "Attempt to lower Auth User " << this << " refcount below 0!"); } - debug(29, 9) ("authenticateAuthUserUnlock auth_user '%p' now at '%ld'.\n", this, (long int) references); + debugs(29, 9, "authenticateAuthUserUnlock auth_user '" << this << "' now at '" << (long int) references << "'."); if (references == 0) delete this; diff --git a/src/AuthUserRequest.cc b/src/AuthUserRequest.cc index 357d25d650..f908dbd634 100644 --- a/src/AuthUserRequest.cc +++ b/src/AuthUserRequest.cc @@ -1,6 +1,6 @@ /* - * $Id: AuthUserRequest.cc,v 1.12 2007/04/20 22:24:07 wessels Exp $ + * $Id: AuthUserRequest.cc,v 1.13 2007/04/28 22:26:37 hno Exp $ * * DO NOT MODIFY NEXT 2 LINES: * arch-tag: 6803fde1-d5a2-4c29-9034-1c0c9f650eb4 @@ -82,7 +82,7 @@ void AuthUserRequest::start(RH * handler, void *data) { assert(handler); - debug(29, 9) ("authenticateStart: auth_user_request '%p'\n", this); + debugs(29, 9, "authenticateStart: auth_user_request '" << this << "'"); module_start(handler, data); } @@ -94,25 +94,25 @@ AuthUserRequest::start(RH * handler, void *data) int authenticateValidateUser(auth_user_request_t * auth_user_request) { - debug(29, 9) ("authenticateValidateUser: Validating Auth_user request '%p'.\n", auth_user_request); + debugs(29, 9, "authenticateValidateUser: Validating Auth_user request '" << auth_user_request << "'."); if (auth_user_request == NULL) { - debug(29, 4) ("authenticateValidateUser: Auth_user_request was NULL!\n"); + debugs(29, 4, "authenticateValidateUser: Auth_user_request was NULL!"); return 0; } if (auth_user_request->user() == NULL) { - debug(29, 4) ("authenticateValidateUser: No associated auth_user structure\n"); + debugs(29, 4, "authenticateValidateUser: No associated auth_user structure"); return 0; } if (auth_user_request->user()->auth_type == AUTH_UNKNOWN) { - debug(29, 4) ("authenticateValidateUser: Auth_user '%p' uses unknown scheme.\n", auth_user_request->user()); + debugs(29, 4, "authenticateValidateUser: Auth_user '" << auth_user_request->user() << "' uses unknown scheme."); return 0; } if (auth_user_request->user()->auth_type == AUTH_BROKEN) { - debug(29, 4) ("authenticateValidateUser: Auth_user '%p' is broken for it's scheme.\n", auth_user_request->user()); + debugs(29, 4, "authenticateValidateUser: Auth_user '" << auth_user_request->user() << "' is broken for it's scheme."); return 0; } @@ -121,7 +121,7 @@ authenticateValidateUser(auth_user_request_t * auth_user_request) /* Thus should a module call to something like authValidate */ /* finally return ok */ - debug(29, 5) ("authenticateValidateUser: Validated Auth_user request '%p'.\n", auth_user_request); + debugs(29, 5, "authenticateValidateUser: Validated Auth_user request '" << auth_user_request << "'."); return 1; @@ -143,13 +143,15 @@ AuthUserRequest::operator delete (void *address) AuthUserRequest::AuthUserRequest():_auth_user(NULL), message(NULL), references (0), lastReply (AUTH_ACL_CANNOT_AUTHENTICATE) { - debug(29, 5) ("AuthUserRequest::AuthUserRequest: initialised request %p\n", this); + debugs(29, 5, "AuthUserRequest::AuthUserRequest: initialised request " << + this); } AuthUserRequest::~AuthUserRequest() { dlink_node *link; - debug(29, 5) ("AuthUserRequest::~AuthUserRequest: freeing request %p\n", this); + debugs(29, 5, "AuthUserRequest::~AuthUserRequest: freeing request " << + this); assert(references == 0); if (user()) { @@ -343,7 +345,7 @@ AuthUserRequest::authenticate(auth_user_request_t ** auth_user_request, http_hdr || (conn != NULL && conn->auth_type == AUTH_BROKEN)) { /* no header or authentication failed/got corrupted - restart */ - debug(29, 4) ("authenticateAuthenticate: broken auth or no proxy_auth header. Requesting auth header.\n"); + debugs(29, 4, "authenticateAuthenticate: broken auth or no proxy_auth header. Requesting auth header."); /* something wrong with the AUTH credentials. Force a new attempt */ if (conn != NULL) { @@ -374,7 +376,11 @@ AuthUserRequest::authenticate(auth_user_request_t ** auth_user_request, http_hdr conn->auth_user_request->connLastHeader() != NULL && strcmp(proxy_auth, conn->auth_user_request->connLastHeader())) { - debug(29, 2) ("authenticateAuthenticate: DUPLICATE AUTH - authentication header on already authenticated connection!. AU %p, Current user '%s' proxy_auth %s\n", conn->auth_user_request, conn->auth_user_request->username(), proxy_auth); + debugs(29, 2, "authenticateAuthenticate: DUPLICATE AUTH - authentication header on already authenticated connection!. AU " << + conn->auth_user_request << ", Current user '" << + conn->auth_user_request->username() << "' proxy_auth " << + proxy_auth); + /* remove this request struct - the link is already authed and it can't be to * reauth. */ @@ -393,19 +399,21 @@ AuthUserRequest::authenticate(auth_user_request_t ** auth_user_request, http_hdr /* we have a proxy auth header and as far as we know this connection has * not had bungled connection oriented authentication happen on it. */ - debug(29, 9) ("authenticateAuthenticate: header %s.\n", proxy_auth ? proxy_auth : "-"); + debugs(29, 9, "authenticateAuthenticate: header " << (proxy_auth ? proxy_auth : "-") << "."); if (*auth_user_request == NULL) { - debug(29, 9) ("authenticateAuthenticate: This is a new checklist test on FD:%d\n", - conn != NULL ? conn->fd : -1); + debugs(29, 9, "authenticateAuthenticate: This is a new checklist test on FD:" << (conn != NULL ? conn->fd : -1) ); if (proxy_auth && !request->auth_user_request && conn != NULL && conn->auth_user_request) { AuthConfig * scheme = AuthConfig::Find(proxy_auth); if (!conn->auth_user_request->user() || conn->auth_user_request->user()->config != scheme) { - debug(29, 1) ("authenticateAuthenticate: Unexpected change of authentication scheme from '%s' to '%s' (client %s)\n", - conn->auth_user_request->user()->config->type(), proxy_auth, inet_ntoa(src_addr)); + debugs(29, 1, "authenticateAuthenticate: Unexpected change of authentication scheme from '" << + conn->auth_user_request->user()->config->type() << + "' to '" << proxy_auth << "' (client " << + inet_ntoa(src_addr) << ")"); + conn->auth_user_request->unlock(); conn->auth_user_request = NULL; conn->auth_type = AUTH_UNKNOWN; @@ -415,7 +423,7 @@ AuthUserRequest::authenticate(auth_user_request_t ** auth_user_request, http_hdr if ((!request->auth_user_request) && (conn == NULL || conn->auth_type == AUTH_UNKNOWN)) { /* beginning of a new request check */ - debug(29, 4) ("authenticateAuthenticate: no connection authentication type\n"); + debugs(29, 4, "authenticateAuthenticate: no connection authentication type"); if (!authenticateValidateUser(*auth_user_request = AuthConfig::CreateAuthUser(proxy_auth))) { @@ -462,8 +470,11 @@ AuthUserRequest::authenticate(auth_user_request_t ** auth_user_request, http_hdr ; } else { /* failed connection based authentication */ - debug(29, 4) ("authenticateAuthenticate: Auth user request %p conn-auth user request %p conn type %d authentication failed.\n", - *auth_user_request, conn->auth_user_request, conn->auth_type); + debugs(29, 4, "authenticateAuthenticate: Auth user request " << + *auth_user_request << " conn-auth user request " << + conn->auth_user_request << " conn type " << + conn->auth_type << " authentication failed."); + (*auth_user_request)->unlock(); *auth_user_request = NULL; return AUTH_ACL_CHALLENGE; @@ -622,7 +633,7 @@ AuthUserRequest::addReplyAuthHeader(HttpReply * rep, auth_user_request_t * auth_ break; } - debug(29, 9) ("authenticateFixHeader: headertype:%d authuser:%p\n", type, auth_user_request); + debugs(29, 9, "authenticateFixHeader: headertype:" << type << " authuser:" << auth_user_request); if (((rep->sline.status == HTTP_PROXY_AUTHENTICATION_REQUIRED) || (rep->sline.status == HTTP_UNAUTHORIZED)) && internal) @@ -642,7 +653,7 @@ AuthUserRequest::addReplyAuthHeader(HttpReply * rep, auth_user_request_t * auth_ if (scheme->active()) scheme->fixHeader(NULL, rep, type, request); else - debug(29, 4) ("authenticateFixHeader: Configured scheme %s not Active\n", scheme->type()); + debugs(29, 4, "authenticateFixHeader: Configured scheme " << scheme->type() << " not Active"); } } @@ -679,7 +690,7 @@ void AuthUserRequest::lock() { - debug(29, 9) ("AuthUserRequest::lock: auth_user request '%p' (%ld references).\n", this, (long int) references); + debugs(29, 9, "AuthUserRequest::lock: auth_user request '" << this << "' (" << (long int) references << " references)."); assert(this); ++references; } @@ -687,17 +698,17 @@ AuthUserRequest::lock() void AuthUserRequest::unlock() { - debug(29, 9) ("AuthUserRequest::unlock: auth_user request '%p' (%ld references) .\n", this, (long int) references); + debugs(29, 9, "AuthUserRequest::unlock: auth_user request '" << this << "' (" << (long int) references << " references) ."); assert(this != NULL); if (references > 0) { --references; } else { - debug(29, 1) ("Attempt to lower Auth User request %p refcount below 0!\n", this); + debugs(29, 1, "Attempt to lower Auth User request " << this << " refcount below 0!"); } if (references == 0) { - debug(29, 9) ("AuthUserRequest::unlock: deleting auth_user_request '%p'.\n", this); + debugs(29, 9, "AuthUserRequest::unlock: deleting auth_user_request '" << this << "'."); /* not locked anymore */ delete this; } diff --git a/src/CacheDigest.cc b/src/CacheDigest.cc index e3699db39b..bbd43a775a 100644 --- a/src/CacheDigest.cc +++ b/src/CacheDigest.cc @@ -1,6 +1,6 @@ /* - * $Id: CacheDigest.cc,v 1.38 2003/07/07 22:48:22 robertc Exp $ + * $Id: CacheDigest.cc,v 1.39 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 70 Cache Digest * AUTHOR: Alex Rousskov @@ -340,9 +340,9 @@ cacheDigestHashKey(const CacheDigest * cd, const cache_key * key) hashed_keys[1] = htonl(tmp_keys[1]) % bit_count; hashed_keys[2] = htonl(tmp_keys[2]) % bit_count; hashed_keys[3] = htonl(tmp_keys[3]) % bit_count; - debug(70, 9) ("cacheDigestHashKey: %s -(%d)-> %d %d %d %d\n", - storeKeyText(key), bit_count, - hashed_keys[0], hashed_keys[1], hashed_keys[2], hashed_keys[3]); + debugs(70, 9, "cacheDigestHashKey: " << storeKeyText(key) << " -(" << + bit_count << ")-> " << hashed_keys[0] << " " << hashed_keys[1] << + " " << hashed_keys[2] << " " << hashed_keys[3]); } #endif diff --git a/src/ConfigParser.cc b/src/ConfigParser.cc index 4fa83386d0..d1f2e3879c 100644 --- a/src/ConfigParser.cc +++ b/src/ConfigParser.cc @@ -1,6 +1,6 @@ /* - * $Id: ConfigParser.cc,v 1.2 2006/04/25 12:00:29 robertc Exp $ + * $Id: ConfigParser.cc,v 1.3 2007/04/28 22:26:37 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -70,7 +70,7 @@ strtok_again: *t = '\0'; if ((wordFile = fopen(fn, "r")) == NULL) { - debug(28, 0) ("strtokFile: %s not found\n", fn); + debugs(28, 0, "strtokFile: " << fn << " not found"); return (NULL); } diff --git a/src/Debug.h b/src/Debug.h index 9ef1448805..1753c41206 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -1,6 +1,6 @@ /* - * $Id: Debug.h,v 1.8 2005/12/19 22:00:47 wessels Exp $ + * $Id: Debug.h,v 1.9 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -39,6 +39,7 @@ #include #undef assert #include +#include #if defined assert #undef assert #endif diff --git a/src/DelayConfig.cc b/src/DelayConfig.cc index 924bae499c..b5ebfa46cb 100644 --- a/src/DelayConfig.cc +++ b/src/DelayConfig.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayConfig.cc,v 1.7 2006/04/25 12:00:29 robertc Exp $ + * $Id: DelayConfig.cc,v 1.8 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -64,7 +64,7 @@ DelayConfig::parsePoolClass() ConfigParser::ParseUShort(&pool); if (pool < 1 || pool > DelayPools::pools()) { - debug(3, 0) ("parse_delay_pool_class: Ignoring pool %d not in 1 .. %d\n", pool, DelayPools::pools()); + debugs(3, 0, "parse_delay_pool_class: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools()); return; } @@ -72,7 +72,7 @@ DelayConfig::parsePoolClass() ConfigParser::ParseUShort(&delay_class_); if (delay_class_ < 1 || delay_class_ > 5) { - debug(3, 0) ("parse_delay_pool_class: Ignoring pool %d class %d not in 1 .. 5\n", pool, delay_class_); + debugs(3, 0, "parse_delay_pool_class: Ignoring pool " << pool << " class " << delay_class_ << " not in 1 .. 5"); return; } @@ -88,14 +88,14 @@ DelayConfig::parsePoolRates() ConfigParser::ParseUShort(&pool); if (pool < 1 || pool > DelayPools::pools()) { - debug(3, 0) ("parse_delay_pool_rates: Ignoring pool %d not in 1 .. %d\n", pool, DelayPools::pools()); + debugs(3, 0, "parse_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools()); return; } pool--; if (!DelayPools::delay_data[pool].theComposite().getRaw()) { - debug(3, 0) ("parse_delay_pool_rates: Ignoring pool %d attempt to set rates with class not set\n", pool + 1); + debugs(3, 0, "parse_delay_pool_rates: Ignoring pool " << pool + 1 << " attempt to set rates with class not set"); return; } @@ -110,7 +110,7 @@ DelayConfig::parsePoolAccess(ConfigParser &parser) ConfigParser::ParseUShort(&pool); if (pool < 1 || pool > DelayPools::pools()) { - debug(3, 0) ("parse_delay_pool_rates: Ignoring pool %d not in 1 .. %d\n", pool, DelayPools::pools()); + debugs(3, 0, "parse_delay_pool_rates: Ignoring pool " << pool << " not in 1 .. " << DelayPools::pools()); return; } diff --git a/src/DelayId.cc b/src/DelayId.cc index 28fc96146e..a5f51ec07a 100644 --- a/src/DelayId.cc +++ b/src/DelayId.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayId.cc,v 1.20 2007/04/20 22:24:07 wessels Exp $ + * $Id: DelayId.cc,v 1.21 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -57,7 +57,7 @@ DelayId::DelayId () : pool_ (0), compositeId(NULL), markedAsNoDelay(false) DelayId::DelayId (unsigned short aPool) : pool_ (aPool), compositeId (NULL), markedAsNoDelay (false) { - debug (77,3)("DelayId::DelayId: Pool %du\n", aPool); + debugs(77, 3, "DelayId::DelayId: Pool " << aPool << "u"); } DelayId::~DelayId () @@ -99,7 +99,7 @@ DelayId::DelayClient(ClientHttpRequest * http) r = http->request; if (r->client_addr.s_addr == INADDR_BROADCAST) { - debug(77, 2) ("delayClient: WARNING: Called with 'allones' address, ignoring\n"); + debugs(77, 2, "delayClient: WARNING: Called with 'allones' address, ignoring"); return DelayId(); } diff --git a/src/DelayTagged.cc b/src/DelayTagged.cc index 8b3bc8243f..071feae159 100644 --- a/src/DelayTagged.cc +++ b/src/DelayTagged.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayTagged.cc,v 1.4 2003/08/04 22:14:40 robertc Exp $ + * $Id: DelayTagged.cc,v 1.5 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -185,12 +185,12 @@ DelayTaggedBucket::operator delete (void *address) DelayTaggedBucket::DelayTaggedBucket(String &aTag) : tag (aTag) { - debug (77,3) ("DelayTaggedBucket::DelayTaggedBucket\n"); + debugs(77, 3, "DelayTaggedBucket::DelayTaggedBucket"); } DelayTaggedBucket::~DelayTaggedBucket() { - debug (77,3) ("DelayTaggedBucket::~DelayTaggedBucket\n"); + debugs(77, 3, "DelayTaggedBucket::~DelayTaggedBucket"); } void @@ -216,7 +216,7 @@ DelayTagged::Id::Id(DelayTagged::Pointer aDelayTagged, String &aTag) : theTagged DelayTagged::Id::~Id() { - debug (77,3) ("DelayTagged::Id::~Id\n"); + debugs(77, 3, "DelayTagged::Id::~Id"); } int diff --git a/src/DelayUser.cc b/src/DelayUser.cc index 5b52613767..4e6a101536 100644 --- a/src/DelayUser.cc +++ b/src/DelayUser.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayUser.cc,v 1.7 2004/08/30 03:28:56 robertc Exp $ + * $Id: DelayUser.cc,v 1.8 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -184,7 +184,7 @@ DelayUserBucket::operator delete (void *address) DelayUserBucket::DelayUserBucket(AuthUser *aUser) : authUser (aUser) { - debug (77,3) ("DelayUserBucket::DelayUserBucket\n"); + debugs(77, 3, "DelayUserBucket::DelayUserBucket"); authUser->lock() @@ -194,7 +194,7 @@ DelayUserBucket::DelayUserBucket(AuthUser *aUser) : authUser (aUser) DelayUserBucket::~DelayUserBucket() { authUser->unlock(); - debug (77,3) ("DelayUserBucket::~DelayUserBucket\n"); + debugs(77, 3, "DelayUserBucket::~DelayUserBucket"); } void @@ -220,7 +220,7 @@ DelayUser::Id::Id(DelayUser::Pointer aDelayUser,AuthUser *aUser) : theUser(aDela DelayUser::Id::~Id() { - debug (77,3) ("DelayUser::Id::~Id\n"); + debugs(77, 3, "DelayUser::Id::~Id"); } int diff --git a/src/DelayVector.cc b/src/DelayVector.cc index 311d256fd7..b9b5b61ea9 100644 --- a/src/DelayVector.cc +++ b/src/DelayVector.cc @@ -1,6 +1,6 @@ /* - * $Id: DelayVector.cc,v 1.9 2003/08/04 22:14:40 robertc Exp $ + * $Id: DelayVector.cc,v 1.10 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -140,7 +140,7 @@ DelayVector::Id::operator delete (void *address) DelayVector::Id::Id(DelayVector::Pointer aDelayVector, CompositeSelectionDetails &details) : theVector(aDelayVector) { - debug(77,3)("DelayVector::Id::Id\n"); + debugs(77, 3, "DelayVector::Id::Id"); DelayVector::iterator pos = theVector->pools.begin(); while (pos != theVector->pools.end()) { @@ -151,7 +151,7 @@ DelayVector::Id::Id(DelayVector::Pointer aDelayVector, CompositeSelectionDetails DelayVector::Id::~Id() { - debug(77,3)("DelayVector::Id::~Id\n"); + debugs(77, 3, "DelayVector::Id::~Id"); } int diff --git a/src/DiskIO/AIO/AIODiskFile.cc b/src/DiskIO/AIO/AIODiskFile.cc index b9de96d41a..e04e112f96 100644 --- a/src/DiskIO/AIO/AIODiskFile.cc +++ b/src/DiskIO/AIO/AIODiskFile.cc @@ -1,6 +1,6 @@ /* - * $Id: AIODiskFile.cc,v 1.3 2006/09/04 20:15:22 serassio Exp $ + * $Id: AIODiskFile.cc,v 1.4 2007/04/28 22:26:40 hno Exp $ * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- @@ -68,7 +68,7 @@ AIODiskFile::AIODiskFile (char const *aPath, AIODiskIOStrategy *aStrategy) : fd( assert (aPath); path = aPath; strategy = aStrategy; - debug (79,3)("AIODiskFile::AIODiskFile: %s\n", aPath); + debugs(79, 3, "AIODiskFile::AIODiskFile: " << aPath); } AIODiskFile::~AIODiskFile() @@ -94,12 +94,12 @@ AIODiskFile::open (int flags, mode_t mode, IORequestor::Pointer callback) ioRequestor = callback; if (fd < 0) { - debug(79, 3) ("BlockingFile::open: got failure (%d)\n", errno); + debugs(79, 3, "BlockingFile::open: got failure (" << errno << ")"); error(true); } else { closed = false; store_open_disk_fd++; - debug(79, 3) ("BlockingFile::open: opened FD %d\n", fd); + debugs(79, 3, "BlockingFile::open: opened FD " << fd); } callback->ioCompletedNotification(); @@ -126,7 +126,7 @@ AIODiskFile::read(ReadRequest *request) if (slot < 0) { /* No free slot? Callback error, and return */ fatal("Aiee! out of aiocb slots! - FIXME and wrap file_read\n"); - debug(79, 1) ("WARNING: out of aiocb slots!\n"); + debugs(79, 1, "WARNING: out of aiocb slots!"); /* fall back to blocking method */ // file_read(fd, request->buf, request->len, request->offset, callback, data); return; @@ -163,7 +163,7 @@ AIODiskFile::read(ReadRequest *request) /* Initiate aio */ if (aio_read(&qe->aq_e_aiocb) < 0) { fatalf("Aiee! aio_read() returned error (%d) FIXME and wrap file_read !\n", errno); - debug(79, 1) ("WARNING: aio_read() returned error: %s\n", xstrerror()); + debugs(79, 1, "WARNING: aio_read() returned error: " << xstrerror()); /* fall back to blocking method */ // file_read(fd, request->buf, request->len, request->offset, callback, data); } @@ -184,7 +184,7 @@ AIODiskFile::write(WriteRequest *request) if (slot < 0) { /* No free slot? Callback error, and return */ fatal("Aiee! out of aiocb slots FIXME and wrap file_write !\n"); - debug(79, 1) ("WARNING: out of aiocb slots!\n"); + debugs(79, 1, "WARNING: out of aiocb slots!"); /* fall back to blocking method */ // file_write(fd, offset, buf, len, callback, data, freefunc); return; @@ -221,7 +221,7 @@ AIODiskFile::write(WriteRequest *request) /* Initiate aio */ if (aio_write(&qe->aq_e_aiocb) < 0) { fatalf("Aiee! aio_write() returned error (%d) FIXME and wrap file_write !\n", errno); - debug(79, 1) ("WARNING: aio_write() returned error: %s\n", xstrerror()); + debugs(79, 1, "WARNING: aio_write() returned error: " << xstrerror()); /* fall back to blocking method */ // file_write(fd, offset, buf, len, callback, data, freefunc); } diff --git a/src/DiskIO/AIO/aio_win32.cc b/src/DiskIO/AIO/aio_win32.cc index 8cb3cb623b..f1f95d2a2f 100755 --- a/src/DiskIO/AIO/aio_win32.cc +++ b/src/DiskIO/AIO/aio_win32.cc @@ -1,6 +1,6 @@ /* - * $Id: aio_win32.cc,v 1.2 2006/09/09 15:29:59 serassio Exp $ + * $Id: aio_win32.cc,v 1.3 2007/04/28 22:26:40 hno Exp $ * * DEBUG: section 81 aio_xxx() POSIX emulation on Windows * AUTHOR: Guido Serassio @@ -46,7 +46,7 @@ VOID CALLBACK IoCompletionRoutine(DWORD dwErrorCode, aiocbp->aio_sigevent.sigev_notify = dwErrorCode; aiocbp->aio_sigevent.sigev_signo = dwNumberOfBytesTransfered; - debug(81,7) ("AIO operation complete: errorcode=%ld nbytes=%ld\n", dwErrorCode, dwNumberOfBytesTransfered); + debugs(81, 7, "AIO operation complete: errorcode=" << dwErrorCode << " nbytes=" << dwNumberOfBytesTransfered); xfree(lpOverlapped); } @@ -102,7 +102,7 @@ int aio_read(struct aiocb *aiocbp) if (!IoOperationStatus) { errno = GetLastError(); - debug(81,1) ("aio_read: GetLastError=%i\n", errno); + debugs(81,1, "aio_read: GetLastError=" << errno ); return -1; } @@ -156,7 +156,7 @@ int aio_read64(struct aiocb64 *aiocbp) if (!IoOperationStatus) { errno = GetLastError(); - debug(81,1) ("aio_read: GetLastError=%i\n", errno); + debugs(81, 1, "aio_read: GetLastError=" << errno ); return -1; } @@ -218,7 +218,7 @@ int aio_write(struct aiocb *aiocbp) if (!IoOperationStatus) { errno = GetLastError(); - debug(81,1) ("aio_write: GetLastError=%i\n", errno); + debugs(81, 1, "aio_write: GetLastError=" << errno ); return -1; } @@ -272,7 +272,7 @@ int aio_write64(struct aiocb64 *aiocbp) if (!IoOperationStatus) { errno = GetLastError(); - debug(81,1) ("aio_write: GetLastError=%i\n", errno); + debugs(81, 1, "aio_write: GetLastError=" << errno ); return -1; } diff --git a/src/DiskIO/Blocking/BlockingFile.cc b/src/DiskIO/Blocking/BlockingFile.cc index 66d2ca483d..68d0a5e2da 100644 --- a/src/DiskIO/Blocking/BlockingFile.cc +++ b/src/DiskIO/Blocking/BlockingFile.cc @@ -1,6 +1,6 @@ /* - * $Id: BlockingFile.cc,v 1.2 2004/12/21 17:28:29 robertc Exp $ + * $Id: BlockingFile.cc,v 1.3 2007/04/28 22:26:44 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Robert Collins @@ -60,7 +60,7 @@ BlockingFile::operator delete (void *address) BlockingFile::BlockingFile (char const *aPath) : fd (-1), closed (true), error_(false) { assert (aPath); - debug (79,3)("BlockingFile::BlockingFile: %s\n", aPath); + debugs(79, 3, "BlockingFile::BlockingFile: " << aPath); path_ = xstrdup (aPath); } @@ -78,12 +78,12 @@ BlockingFile::open (int flags, mode_t mode, IORequestor::Pointer callback) ioRequestor = callback; if (fd < 0) { - debug(79, 3) ("BlockingFile::open: got failure (%d)\n", errno); + debugs(79, 3, "BlockingFile::open: got failure (" << errno << ")"); error(true); } else { closed = false; store_open_disk_fd++; - debug(79, 3) ("BlockingFile::open: opened FD %d\n", fd); + debugs(79, 3, "BlockingFile::open: opened FD " << fd); } callback->ioCompletedNotification(); @@ -110,7 +110,7 @@ void BlockingFile::doClose() void BlockingFile::close () { - debug (79,3)("BlockingFile::close: %p closing for %p\n", this, ioRequestor.getRaw()); + debugs(79, 3, "BlockingFile::close: " << this << " closing for " << ioRequestor.getRaw()); doClose(); assert (ioRequestor.getRaw()); ioRequestor->closeCompleted(); @@ -156,7 +156,7 @@ BlockingFile::ReadDone(int fd, const char *buf, int len, int errflag, void *my_d void BlockingFile::write(WriteRequest *aRequest) { - debug(79, 3) ("storeUfsWrite: FD %d\n",fd); + debugs(79, 3, "storeUfsWrite: FD " << fd); writeRequest = aRequest; file_write(fd, aRequest->offset, @@ -179,13 +179,13 @@ BlockingFile::ioInProgress()const void BlockingFile::readDone(int rvfd, const char *buf, int len, int errflag) { - debug (79,3)("BlockingFile::readDone: FD %d\n",rvfd); + debugs(79, 3, "BlockingFile::readDone: FD " << rvfd); assert (fd == rvfd); ssize_t rlen; if (errflag) { - debug(79, 3) ("BlockingFile::readDone: got failure (%d)\n", errflag); + debugs(79, 3, "BlockingFile::readDone: got failure (" << errflag << ")"); rlen = -1; } else { rlen = (ssize_t) len; @@ -212,14 +212,13 @@ void BlockingFile::writeDone(int rvfd, int errflag, size_t len) { assert (rvfd == fd); - debug(79, 3) ("storeUfsWriteDone: FD %d, len %ld\n", - fd, (long int) len); + debugs(79, 3, "storeUfsWriteDone: FD " << fd << ", len " << (long int) len); WriteRequest::Pointer result = writeRequest; writeRequest = NULL; if (errflag) { - debug(79, 0) ("storeUfsWriteDone: got failure (%d)\n", errflag); + debugs(79, 0, "storeUfsWriteDone: got failure (" << errflag << ")"); doClose(); ioRequestor->writeCompleted (DISK_ERROR,0, result); return; diff --git a/src/DiskIO/DiskDaemon/DiskdFile.cc b/src/DiskIO/DiskDaemon/DiskdFile.cc index 27e847a8b5..ffc69cdd14 100644 --- a/src/DiskIO/DiskDaemon/DiskdFile.cc +++ b/src/DiskIO/DiskDaemon/DiskdFile.cc @@ -1,6 +1,6 @@ /* - * $Id: DiskdFile.cc,v 1.2 2004/12/21 17:28:29 robertc Exp $ + * $Id: DiskdFile.cc,v 1.3 2007/04/28 22:26:45 hno Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -57,7 +57,7 @@ DiskdFile::operator new (size_t) DiskdFile *result = cbdataAlloc(DiskdFile); /* Mark result as being owned - we want the refcounter to do the delete * call */ - debug (79,3)("diskdFile with base %p allocating\n", result); + debugs(79, 3, "diskdFile with base " << result << " allocating"); return result; } @@ -65,7 +65,7 @@ void DiskdFile::operator delete (void *address) { DiskdFile *t = static_cast(address); - debug (79,3)("diskdFile with base %p deleting\n",t); + debugs(79, 3, "diskdFile with base " << t << " deleting"); cbdataFree(t); } @@ -73,7 +73,7 @@ DiskdFile::DiskdFile (char const *aPath, DiskdIOStrategy *anIO) : errorOccured ( inProgressIOs (0) { assert (aPath); - debug (79,3)("DiskdFile::DiskdFile: %s\n", aPath); + debugs(79, 3, "DiskdFile::DiskdFile: " << aPath); path_ = xstrdup (aPath); id = diskd_stats.sio_id++; } @@ -87,7 +87,7 @@ DiskdFile::~DiskdFile() void DiskdFile::open (int flags, mode_t aMode, IORequestor::Pointer callback) { - debug (79,3)("DiskdFile::open: %p opening for %p\n", this, callback.getRaw()); + debugs(79, 3, "DiskdFile::open: " << this << " opening for " << callback.getRaw()); assert (ioRequestor.getRaw() == NULL); ioRequestor = callback; assert (callback.getRaw()); @@ -118,7 +118,7 @@ DiskdFile::open (int flags, mode_t aMode, IORequestor::Pointer callback) void DiskdFile::create (int flags, mode_t aMode, IORequestor::Pointer callback) { - debug (79,3)("DiskdFile::create: %p creating for %p\n", this, callback.getRaw()); + debugs(79, 3, "DiskdFile::create: " << this << " creating for " << callback.getRaw()); assert (ioRequestor.getRaw() == NULL); ioRequestor = callback; assert (callback.getRaw()); @@ -139,7 +139,7 @@ DiskdFile::create (int flags, mode_t aMode, IORequestor::Pointer callback) ioCompleted(); errorOccured = true; // IO->shm.put (shm_offset); - debug(79, 1) ("storeDiskdSend CREATE: %s\n", xstrerror()); + debugs(79, 1, "storeDiskdSend CREATE: " << xstrerror()); notifyClient(); ioRequestor = NULL; return; @@ -168,7 +168,7 @@ DiskdFile::read(ReadRequest *aRead) ioCompleted(); errorOccured = true; // IO->shm.put (shm_offset); - debug(79, 1) ("storeDiskdSend READ: %s\n", xstrerror()); + debugs(79, 1, "storeDiskdSend READ: " << xstrerror()); notifyClient(); ioRequestor = NULL; return; @@ -180,7 +180,7 @@ DiskdFile::read(ReadRequest *aRead) void DiskdFile::close() { - debug (79,3)("DiskdFile::close: %p closing for %p\n", this, ioRequestor.getRaw()); + debugs(79, 3, "DiskdFile::close: " << this << " closing for " << ioRequestor.getRaw()); assert (ioRequestor.getRaw()); ioAway(); int x = IO->send(_MQD_CLOSE, @@ -194,7 +194,7 @@ DiskdFile::close() if (x < 0) { ioCompleted(); errorOccured = true; - debug(79, 1) ("storeDiskdSend CLOSE: %s\n", xstrerror()); + debugs(79, 1, "storeDiskdSend CLOSE: " << xstrerror()); notifyClient(); ioRequestor = NULL; return; @@ -219,7 +219,7 @@ bool DiskdFile::canNotifyClient() const { if (!ioRequestor.getRaw()) { - debug (79,3)("DiskdFile::canNotifyClient: No ioRequestor to notify\n"); + debugs(79, 3, "DiskdFile::canNotifyClient: No ioRequestor to notify"); return false; } @@ -277,7 +277,7 @@ void DiskdFile::openDone(diomsg *M) { statCounter.syscalls.disk.opens++; - debug(79, 3) ("storeDiskdOpenDone: status %d\n", M->status); + debugs(79, 3, "storeDiskdOpenDone: status " << M->status); if (M->status < 0) { diskd_stats.open.fail++; @@ -294,7 +294,7 @@ void DiskdFile::createDone(diomsg *M) { statCounter.syscalls.disk.opens++; - debug(79, 3) ("storeDiskdCreateDone: status %d\n", M->status); + debugs(79, 3, "storeDiskdCreateDone: status " << M->status); if (M->status < 0) { diskd_stats.create.fail++; @@ -332,7 +332,7 @@ DiskdFile::write(WriteRequest *aRequest) ioCompleted() ; errorOccured = true; - debug(79, 1) ("storeDiskdSend WRITE: %s\n", xstrerror()); + debugs(79, 1, "storeDiskdSend WRITE: " << xstrerror()); // IO->shm.put (shm_offset); notifyClient(); ioRequestor = NULL; @@ -358,7 +358,7 @@ void DiskdFile::closeDone(diomsg * M) { statCounter.syscalls.disk.closes++; - debug(79, 3) ("DiskdFile::closeDone: status %d\n", M->status); + debugs(79, 3, "DiskdFile::closeDone: status " << M->status); if (M->status < 0) { diskd_stats.close.fail++; @@ -379,7 +379,7 @@ void DiskdFile::readDone(diomsg * M) { statCounter.syscalls.disk.reads++; - debug(79, 3) ("DiskdFile::readDone: status %d\n", M->status); + debugs(79, 3, "DiskdFile::readDone: status " << M->status); assert (M->requestor); ReadRequest::Pointer readRequest = dynamic_cast(M->requestor); /* remove the free protection */ @@ -403,7 +403,7 @@ void DiskdFile::writeDone(diomsg *M) { statCounter.syscalls.disk.writes++; - debug(79, 3) ("storeDiskdWriteDone: status %d\n", M->status); + debugs(79, 3, "storeDiskdWriteDone: status " << M->status); assert (M->requestor); WriteRequest::Pointer writeRequest = dynamic_cast(M->requestor); /* remove the free protection */ diff --git a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc index 2f620217b7..432d3425be 100644 --- a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc +++ b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc @@ -1,6 +1,6 @@ /* - * $Id: DiskdIOStrategy.cc,v 1.9 2007/04/12 23:51:57 wessels Exp $ + * $Id: DiskdIOStrategy.cc,v 1.10 2007/04/28 22:26:45 hno Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -67,7 +67,7 @@ DiskdIOStrategy::shedLoad() */ if (away > magic1) { - debug(79, 3) ("storeDiskdIO::shedLoad: Shedding, too many requests away\n"); + debugs(79, 3, "storeDiskdIO::shedLoad: Shedding, too many requests away"); return true; } @@ -108,7 +108,7 @@ DiskdIOStrategy::unlinkFile(char const *path) { if (shedLoad()) { /* Damn, we need to issue a sync unlink here :( */ - debug(79, 2) ("storeDiskUnlink: Out of queue space, sync unlink\n"); + debugs(79, 2, "storeDiskUnlink: Out of queue space, sync unlink"); #if USE_UNLINKD unlinkdUnlink(path); @@ -139,7 +139,7 @@ DiskdIOStrategy::unlinkFile(char const *path) shm_offset); if (x < 0) { - debug(79, 1) ("storeDiskdSend UNLINK: %s\n", xstrerror()); + debugs(79, 1, "storeDiskdSend UNLINK: " << xstrerror()); ::unlink(buf); /* XXX EWW! */ // shm.put (shm_offset); } @@ -164,14 +164,14 @@ DiskdIOStrategy::init() smsgid = msgget((key_t) ikey, 0700 | IPC_CREAT); if (smsgid < 0) { - debug(50, 0) ("storeDiskdInit: msgget: %s\n", xstrerror()); + debugs(50, 0, "storeDiskdInit: msgget: " << xstrerror()); fatal("msgget failed"); } rmsgid = msgget((key_t) (ikey + 1), 0700 | IPC_CREAT); if (rmsgid < 0) { - debug(50, 0) ("storeDiskdInit: msgget: %s\n", xstrerror()); + debugs(50, 0, "storeDiskdInit: msgget: " << xstrerror()); fatal("msgget failed"); } @@ -263,14 +263,14 @@ SharedMemory::init(int ikey, int magic2) nbufs * SHMBUF_BLKSZ, 0600 | IPC_CREAT); if (id < 0) { - debug(50, 0) ("storeDiskdInit: shmget: %s\n", xstrerror()); + debugs(50, 0, "storeDiskdInit: shmget: " << xstrerror()); fatal("shmget failed"); } buf = (char *)shmat(id, NULL, 0); if (buf == (void *) -1) { - debug(50, 0) ("storeDiskdInit: shmat: %s\n", xstrerror()); + debugs(50, 0, "storeDiskdInit: shmat: " << xstrerror()); fatal("shmat failed"); } @@ -286,8 +286,7 @@ SharedMemory::init(int ikey, int magic2) void DiskdIOStrategy::unlinkDone(diomsg * M) { - debug(79, 3) ("storeDiskdUnlinkDone: file %s status %d\n",shm.buf + M->shm_offset, - M->status); + debugs(79, 3, "storeDiskdUnlinkDone: file " << shm.buf + M->shm_offset << " status " << M->status); statCounter.syscalls.disk.unlinks++; if (M->status < 0) @@ -304,8 +303,7 @@ DiskdIOStrategy::handle(diomsg * M) * - say when we have a error opening after * a read was already queued */ - debug(79, 3) ("storeDiskdHandle: Invalid callback_data %p\n", - M->callback_data); + debugs(79, 3, "storeDiskdHandle: Invalid callback_data " << M->callback_data); cbdataReferenceDone (M->callback_data); return; } @@ -388,7 +386,7 @@ DiskdIOStrategy::SEND(diomsg *M, int mtype, int id, int size, int offset, off_t M->seq_no = ++seq_no; if (M->seq_no < last_seq_no) - debug(79, 1) ("WARNING: sequencing out of order\n"); + debugs(79, 1, "WARNING: sequencing out of order"); x = msgsnd(smsgid, M, diomsg::msg_snd_rcv_sz, IPC_NOWAIT); @@ -398,7 +396,7 @@ DiskdIOStrategy::SEND(diomsg *M, int mtype, int id, int size, int offset, off_t diskd_stats.sent_count++; away++; } else { - debug(79, 1) ("storeDiskdSend: msgsnd: %s\n", xstrerror()); + debugs(79, 1, "storeDiskdSend: msgsnd: " << xstrerror()); cbdataReferenceDone(M->callback_data); assert(++send_errors < 100); if (shm_offset > -1) @@ -461,14 +459,13 @@ DiskdIOStrategy::optionQ1Parse(const char *name, const char *value, int reconfig * will cause an assertion in storeDiskdShmGet(). */ /* TODO: have DiskdIO hold a link to the swapdir, to allow detailed reporting again */ - debug(3, 1) ("WARNING: cannot increase cache_dir Q1 value while Squid is running.\n"); + debugs(3, 1, "WARNING: cannot increase cache_dir Q1 value while Squid is running."); magic1 = old_magic1; return true; } if (old_magic1 != magic1) - debug(3, 1) ("cache_dir new Q1 value '%d'\n", - magic1); + debugs(3, 1, "cache_dir new Q1 value '" << magic1 << "'"); return true; } @@ -494,14 +491,13 @@ DiskdIOStrategy::optionQ2Parse(const char *name, const char *value, int reconfig if (old_magic2 < magic2) { /* See comments in Q1 function above */ - debug(3, 1) ("WARNING: cannot increase cache_dir Q2 value while Squid is running.\n"); + debugs(3, 1, "WARNING: cannot increase cache_dir Q2 value while Squid is running."); magic2 = old_magic2; return true; } if (old_magic2 != magic2) - debug(3, 1) ("cache_dir new Q2 value '%d'\n", - magic2); + debugs(3, 1, "cache_dir new Q2 value '" << magic2 << "'"); return true; } @@ -523,8 +519,7 @@ DiskdIOStrategy::sync() while (away > 0) { if (squid_curtime > lastmsg) { - debug(47, 1) ("storeDiskdDirSync: %d messages away\n", - away); + debugs(47, 1, "storeDiskdDirSync: " << away << " messages away"); lastmsg = squid_curtime; } @@ -568,8 +563,7 @@ DiskdIOStrategy::callback() if (x < 0) break; else if (x != diomsg::msg_snd_rcv_sz) { - debug(47, 1) ("storeDiskdDirCallback: msgget returns %d\n", - x); + debugs(47, 1, "storeDiskdDirCallback: msgget returns " << x); break; } diff --git a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc index 89487a687f..e3a25cc113 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc @@ -1,6 +1,6 @@ /* - * $Id: DiskThreadsDiskFile.cc,v 1.8 2006/06/17 16:36:15 serassio Exp $ + * $Id: DiskThreadsDiskFile.cc,v 1.9 2007/04/28 22:26:47 hno Exp $ * * DEBUG: section 79 Disk IO Routines * AUTHOR: Robert Collins @@ -71,7 +71,7 @@ DiskThreadsDiskFile::DiskThreadsDiskFile (char const *aPath, DiskThreadsIOStrate inProgressIOs (0) { assert (aPath); - debug (79,3)("UFSFile::UFSFile: %s\n", aPath); + debugs(79, 3, "UFSFile::UFSFile: " << aPath); path_ = xstrdup (aPath); } @@ -90,7 +90,7 @@ DiskThreadsDiskFile::open (int flags, mode_t mode, IORequestor::Pointer callback fd = file_open(path_, flags); if (fd < 0) { - debug(79, 3) ("DiskThreadsDiskFile::open: got failure (%d)\n", errno); + debugs(79, 3, "DiskThreadsDiskFile::open: got failure (" << errno << ")"); errorOccured = true; return; } @@ -139,7 +139,7 @@ DiskThreadsDiskFile::create (int flags, mode_t mode, IORequestor::Pointer callba int fd = file_open(path_, flags); if (fd < 0) { - debug(79, 3) ("DiskThreadsDiskFile::create: got failure (%d)\n", errno); + debugs(79, 3, "DiskThreadsDiskFile::create: got failure (" << errno << ")"); errorOccured = true; return; } @@ -178,15 +178,15 @@ DiskThreadsDiskFile::OpenDone(int fd, void *cbdata, const char *buf, int aio_ret void DiskThreadsDiskFile::openDone(int unused, const char *unused2, int anFD, int errflag) { - debug(79, 3) ("DiskThreadsDiskFile::openDone: FD %d, errflag %d\n", anFD, errflag); + debugs(79, 3, "DiskThreadsDiskFile::openDone: FD " << anFD << ", errflag " << errflag); Opening_FD--; fd = anFD; if (errflag || fd < 0) { errno = errflag; - debug(79, 0) ("DiskThreadsDiskFile::openDone: %s\n", xstrerror()); - debug(79, 1) ("\t%s\n", path_); + debugs(79, 0, "DiskThreadsDiskFile::openDone: " << xstrerror()); + debugs(79, 1, "\t" << path_); errorOccured = true; } else { store_open_disk_fd++; @@ -198,7 +198,7 @@ DiskThreadsDiskFile::openDone(int unused, const char *unused2, int anFD, int err --inProgressIOs; t->ioCompletedNotification(); - debug(79, 3) ("DiskThreadsDiskFile::openDone: exiting\n"); + debugs(79, 3, "DiskThreadsDiskFile::openDone: exiting"); } void DiskThreadsDiskFile::doClose() @@ -223,7 +223,7 @@ void DiskThreadsDiskFile::doClose() void DiskThreadsDiskFile::close () { - debug (79,3)("DiskThreadsDiskFile::close: %p closing for %p\n", this, ioRequestor.getRaw()); + debugs(79, 3, "DiskThreadsDiskFile::close: " << this << " closing for " << ioRequestor.getRaw()); if (!ioInProgress()) { doClose(); @@ -239,14 +239,14 @@ DiskThreadsDiskFile::close () bool DiskThreadsDiskFile::canRead() const { - debug (79,3)("DiskThreadsDiskFile::canRead: fd is %d\n",fd); + debugs(79, 3, "DiskThreadsDiskFile::canRead: fd is " << fd); return fd > -1; } void DiskThreadsDiskFile::write(WriteRequest * writeRequest) { - debug(79, 3) ("DiskThreadsDiskFile::write: FD %d\n", fd); + debugs(79, 3, "DiskThreadsDiskFile::write: FD " << fd); statCounter.syscalls.disk.writes++; ++inProgressIOs; #if ASYNC_WRITE @@ -291,13 +291,13 @@ DiskThreadsDiskFile::ReadDone(int fd, const char *buf, int len, int errflag, voi void DiskThreadsDiskFile::readDone(int rvfd, const char *buf, int len, int errflag, ReadRequest::Pointer request) { - debug (79,3)("DiskThreadsDiskFile::readDone: FD %d\n",rvfd); + debugs(79, 3, "DiskThreadsDiskFile::readDone: FD " << rvfd); assert (fd == rvfd); ssize_t rlen; if (errflag) { - debug(79, 3) ("DiskThreadsDiskFile::readDone: got failure (%d)\n", errflag); + debugs(79, 3, "DiskThreadsDiskFile::readDone: got failure (" << errflag << ")"); rlen = -1; } else { rlen = (ssize_t) len; @@ -354,8 +354,7 @@ DiskThreadsDiskFile::writeDone (int rvfd, int errflag, size_t len, WriteRequest: #endif - debug(79, 3) ("DiskThreadsDiskFile::writeDone: FD %d, len %ld, err=%d\n", - fd, (long int) len, errflag); + debugs(79, 3, "DiskThreadsDiskFile::writeDone: FD " << fd << ", len " << (long int) len << ", err=" << errflag); assert(++loop_detect < 10); diff --git a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc index d69cefec48..39343f7fcc 100644 --- a/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc +++ b/src/DiskIO/DiskThreads/DiskThreadsIOStrategy.cc @@ -1,6 +1,6 @@ /* - * $Id: DiskThreadsIOStrategy.cc,v 1.11 2007/04/12 23:51:57 wessels Exp $ + * $Id: DiskThreadsIOStrategy.cc,v 1.12 2007/04/28 22:26:47 hno Exp $ * * DEBUG: section 79 Squid-side Disk I/O functions. * AUTHOR: Robert Collins @@ -177,13 +177,13 @@ DiskThreadsIOStrategy::sync() return; /* nothing to do then */ /* Flush all pending operations */ - debug(32, 1) ("aioSync: flushing pending I/O operations\n"); + debugs(32, 1, "aioSync: flushing pending I/O operations"); do { callback(); } while (squidaio_sync()); - debug(32, 1) ("aioSync: done\n"); + debugs(32, 1, "aioSync: done"); } DiskThreadsIOStrategy::DiskThreadsIOStrategy() : initialised (false) {} @@ -236,7 +236,7 @@ DiskThreadsIOStrategy::load() loadav = ql * 1000 / MAGIC1; - debug(47, 9) ("DiskThreadsIOStrategy::load: load=%d\n", loadav); + debugs(47, 9, "DiskThreadsIOStrategy::load: load=" << loadav); return loadav; } diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index 55d111b2a5..fbe7a50ed3 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -1,5 +1,5 @@ /* - * $Id: aiops.cc,v 1.13 2007/04/12 23:51:57 wessels Exp $ + * $Id: aiops.cc,v 1.14 2007/04/28 22:26:47 hno Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -493,8 +493,7 @@ static void squidaio_queue_request(squidaio_request_t * request) { static int high_start = 0; - debug(43, 9) ("squidaio_queue_request: %p type=%d result=%p\n", - request, request->request_type, request->resultp); + debugs(43, 9, "squidaio_queue_request: " << request << " type=" << request->request_type << " result=" << request->resultp); /* Mark it as not executed (failing result, no error) */ request->ret = -1; request->err = 0; @@ -538,7 +537,7 @@ squidaio_queue_request(squidaio_request_t * request) if (++filter >= filter_limit) { filter_limit += filter; filter = 0; - debug(43, 1) ("squidaio_queue_request: WARNING - Queue congestion\n"); + debugs(43, 1, "squidaio_queue_request: WARNING - Queue congestion"); } } @@ -561,11 +560,13 @@ squidaio_queue_request(squidaio_request_t * request) if (squid_curtime >= (last_warn + 15) && squid_curtime >= (high_start + 5)) { - debug(43, 1) ("squidaio_queue_request: WARNING - Disk I/O overloading\n"); + debugs(43, 1, "squidaio_queue_request: WARNING - Disk I/O overloading"); if (squid_curtime >= (high_start + 15)) - debug(43, 1) ("squidaio_queue_request: Queue Length: current=%d, high=%d, low=%d, duration=%ld\n", - request_queue_len, queue_high, queue_low, (long int) (squid_curtime - high_start)); + debugs(43, 1, "squidaio_queue_request: Queue Length: current=" << + request_queue_len << ", high=" << queue_high << + ", low=" << queue_low << ", duration=" << + (long int) (squid_curtime - high_start)); last_warn = squid_curtime; } @@ -575,10 +576,10 @@ squidaio_queue_request(squidaio_request_t * request) /* Warn if seriously overloaded */ if (request_queue_len > RIDICULOUS_LENGTH) { - debug(43, 0) ("squidaio_queue_request: Async request queue growing uncontrollably!\n"); - debug(43, 0) ("squidaio_queue_request: Syncing pending I/O operations.. (blocking)\n"); + debugs(43, 0, "squidaio_queue_request: Async request queue growing uncontrollably!"); + debugs(43, 0, "squidaio_queue_request: Syncing pending I/O operations.. (blocking)"); squidaio_sync(); - debug(43, 0) ("squidaio_queue_request: Synced\n"); + debugs(43, 0, "squidaio_queue_request: Synced"); } } /* squidaio_queue_request */ @@ -653,8 +654,7 @@ squidaio_cancel(squidaio_result_t * resultp) squidaio_request_t *request = (squidaio_request_t *)resultp->_data; if (request && request->resultp == resultp) { - debug(43, 9) ("squidaio_cancel: %p type=%d result=%p\n", - request, request->request_type, request->resultp); + debugs(43, 9, "squidaio_cancel: " << request << " type=" << request->request_type << " result=" << request->resultp); request->cancelled = 1; request->resultp = NULL; resultp->_data = NULL; @@ -960,8 +960,7 @@ AIO_REPOLL: return NULL; } - debug(43, 9) ("squidaio_poll_done: %p type=%d result=%p\n", - request, request->request_type, request->resultp); + debugs(43, 9, "squidaio_poll_done: " << request << " type=" << request->request_type << " result=" << request->resultp); done_requests.head = request->next; if (!done_requests.head) @@ -973,7 +972,7 @@ AIO_REPOLL: squidaio_debug(request); - debug(43, 5) ("DONE: %d -> %d\n", request->ret, request->err); + debugs(43, 5, "DONE: " << request->ret << " -> " << request->err); squidaio_cleanup_request(request); @@ -1013,23 +1012,23 @@ squidaio_debug(squidaio_request_t * request) switch (request->request_type) { case _AIO_OP_OPEN: - debug(43, 5) ("OPEN of %s to FD %d\n", request->path, request->ret); + debugs(43, 5, "OPEN of " << request->path << " to FD " << request->ret); break; case _AIO_OP_READ: - debug(43, 5) ("READ on fd: %d\n", request->fd); + debugs(43, 5, "READ on fd: " << request->fd); break; case _AIO_OP_WRITE: - debug(43, 5) ("WRITE on fd: %d\n", request->fd); + debugs(43, 5, "WRITE on fd: " << request->fd); break; case _AIO_OP_CLOSE: - debug(43, 5) ("CLOSE of fd: %d\n", request->fd); + debugs(43, 5, "CLOSE of fd: " << request->fd); break; case _AIO_OP_UNLINK: - debug(43, 5) ("UNLINK of %s\n", request->path); + debugs(43, 5, "UNLINK of " << request->path); break; default: diff --git a/src/DiskIO/DiskThreads/aiops_win32.cc b/src/DiskIO/DiskThreads/aiops_win32.cc index 6b70f009bd..c26ed91ada 100755 --- a/src/DiskIO/DiskThreads/aiops_win32.cc +++ b/src/DiskIO/DiskThreads/aiops_win32.cc @@ -1,5 +1,5 @@ /* - * $Id: aiops_win32.cc,v 1.3 2007/04/12 23:51:57 wessels Exp $ + * $Id: aiops_win32.cc,v 1.4 2007/04/28 22:26:47 hno Exp $ * * DEBUG: section 43 Windows AIOPS * AUTHOR: Stewart Forster @@ -572,8 +572,7 @@ static void squidaio_queue_request(squidaio_request_t * request) { static int high_start = 0; - debug(43, 9) ("squidaio_queue_request: %p type=%d result=%p\n", - request, request->request_type, request->resultp); + debugs(43, 9, "squidaio_queue_request: " << request << " type=" << request->request_type << " result=" << request->resultp); /* Mark it as not executed (failing result, no error) */ request->ret = -1; request->err = 0; @@ -623,7 +622,7 @@ squidaio_queue_request(squidaio_request_t * request) if (++filter >= filter_limit) { filter_limit += filter; filter = 0; - debug(43, 1) ("squidaio_queue_request: WARNING - Queue congestion\n"); + debugs(43, 1, "squidaio_queue_request: WARNING - Queue congestion"); } } @@ -646,11 +645,13 @@ squidaio_queue_request(squidaio_request_t * request) if (squid_curtime >= (last_warn + 15) && squid_curtime >= (high_start + 5)) { - debug(43, 1) ("squidaio_queue_request: WARNING - Disk I/O overloading\n"); + debugs(43, 1, "squidaio_queue_request: WARNING - Disk I/O overloading"); if (squid_curtime >= (high_start + 15)) - debug(43, 1) ("squidaio_queue_request: Queue Length: current=%d, high=%d, low=%d, duration=%ld\n", - request_queue_len, queue_high, queue_low, (long int) (squid_curtime - high_start)); + debugs(43, 1, "squidaio_queue_request: Queue Length: current=" << + request_queue_len << ", high=" << queue_high << + ", low=" << queue_low << ", duration=" << + (long int) (squid_curtime - high_start)); last_warn = (int)squid_curtime; } @@ -660,10 +661,10 @@ squidaio_queue_request(squidaio_request_t * request) /* Warn if seriously overloaded */ if (request_queue_len > RIDICULOUS_LENGTH) { - debug(43, 0) ("squidaio_queue_request: Async request queue growing uncontrollably!\n"); - debug(43, 0) ("squidaio_queue_request: Syncing pending I/O operations.. (blocking)\n"); + debugs(43, 0, "squidaio_queue_request: Async request queue growing uncontrollably!"); + debugs(43, 0, "squidaio_queue_request: Syncing pending I/O operations.. (blocking)"); squidaio_sync(); - debug(43, 0) ("squidaio_queue_request: Synced\n"); + debugs(43, 0, "squidaio_queue_request: Synced"); } } /* squidaio_queue_request */ @@ -738,8 +739,7 @@ squidaio_cancel(squidaio_result_t * resultp) squidaio_request_t *request = (squidaio_request_t *)resultp->_data; if (request && request->resultp == resultp) { - debug(43, 9) ("squidaio_cancel: %p type=%d result=%p\n", - request, request->request_type, request->resultp); + debugs(43, 9, "squidaio_cancel: " << request << " type=" << request->request_type << " result=" << request->resultp); request->cancelled = 1; request->resultp = NULL; resultp->_data = NULL; @@ -904,7 +904,7 @@ static void squidaio_do_close(squidaio_request_t * requestp) { if((requestp->ret = close(requestp->fd)) < 0) { - debug(43, 0) ("squidaio_do_close: FD %d, errno %d\n", requestp->fd, errno); + debugs(43, 0, "squidaio_do_close: FD " << requestp->fd << ", errno " << errno); close(requestp->fd); } @@ -1073,8 +1073,7 @@ AIO_REPOLL: return NULL; } - debug(43, 9) ("squidaio_poll_done: %p type=%d result=%p\n", - request, request->request_type, request->resultp); + debugs(43, 9, "squidaio_poll_done: " << request << " type=" << request->request_type << " result=" << request->resultp); done_requests.head = request->next; if (!done_requests.head) @@ -1086,7 +1085,7 @@ AIO_REPOLL: squidaio_debug(request); - debug(43, 5) ("DONE: %d -> %d\n", request->ret, request->err); + debugs(43, 5, "DONE: " << request->ret << " -> " << request->err); squidaio_cleanup_request(request); @@ -1126,23 +1125,23 @@ squidaio_debug(squidaio_request_t * request) switch (request->request_type) { case _AIO_OP_OPEN: - debug(43, 5) ("OPEN of %s to FD %d\n", request->path, request->ret); + debugs(43, 5, "OPEN of " << request->path << " to FD " << request->ret); break; case _AIO_OP_READ: - debug(43, 5) ("READ on fd: %d\n", request->fd); + debugs(43, 5, "READ on fd: " << request->fd); break; case _AIO_OP_WRITE: - debug(43, 5) ("WRITE on fd: %d\n", request->fd); + debugs(43, 5, "WRITE on fd: " << request->fd); break; case _AIO_OP_CLOSE: - debug(43, 5) ("CLOSE of fd: %d\n", request->fd); + debugs(43, 5, "CLOSE of fd: " << request->fd); break; case _AIO_OP_UNLINK: - debug(43, 5) ("UNLINK of %s\n", request->path); + debugs(43, 5, "UNLINK of " << request->path); break; default: diff --git a/src/DiskIO/DiskThreads/async_io.cc b/src/DiskIO/DiskThreads/async_io.cc index e504327838..debd24f1d2 100644 --- a/src/DiskIO/DiskThreads/async_io.cc +++ b/src/DiskIO/DiskThreads/async_io.cc @@ -1,6 +1,6 @@ /* - * $Id: async_io.cc,v 1.3 2007/04/12 23:51:57 wessels Exp $ + * $Id: async_io.cc,v 1.4 2007/04/28 22:26:47 hno Exp $ * * DEBUG: section 32 Asynchronous Disk I/O * AUTHOR: Pete Bentley @@ -113,7 +113,7 @@ aioCancel(int fd) AIOCB *callback = ctrlp->done_handler; void *cbdata; ctrlp->done_handler = NULL; - debug(32, 1) ("this be aioCancel. Danger ahead!\n"); + debugs(32, 1, "this be aioCancel. Danger ahead!"); if (cbdataReferenceValidDone(ctrlp->done_handler_data, &cbdata)) callback(fd, cbdata, NULL, -2, -2); diff --git a/src/ESI.cc b/src/ESI.cc index 5eda8b8133..51fc9f3e92 100644 --- a/src/ESI.cc +++ b/src/ESI.cc @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.22 2006/08/21 00:50:40 robertc Exp $ + * $Id: ESI.cc,v 1.23 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -325,13 +325,13 @@ ESIContext::appendOutboundData(ESISegment::Pointer theData) } fixupOutboundTail(); - debug (86,9)("ESIContext::appendOutboundData: outbound %p\n", outbound.getRaw()); + debugs(86, 9, "ESIContext::appendOutboundData: outbound " << outbound.getRaw()); } void ESIContext::provideData (ESISegment::Pointer theData, ESIElement * source) { - debug (86,5)("ESIContext::provideData: %p %p %p\n",this, theData.getRaw(), source); + debugs(86, 5, "ESIContext::provideData: " << this << " " << theData.getRaw() << " " << source); /* No callbacks permitted after finish() called on the tree */ assert (tree.getRaw()); assert (source == tree); @@ -366,7 +366,7 @@ ESIContext::kick () assert (this); if (flags.kicked) { - debug (86,5)("esiKick: Re-entered whilst in progress\n"); + debugs(86, 5, "esiKick: Re-entered whilst in progress"); // return ESI_KICK_INPROGRESS; } else ++flags.kicked; @@ -381,19 +381,19 @@ ESIContext::kick () switch (process ()) { case ESI_PROCESS_COMPLETE: - debug (86,5)("esiKick: esiProcess OK\n"); + debugs(86, 5, "esiKick: esiProcess OK"); break; case ESI_PROCESS_PENDING_WONTFAIL: - debug (86,5)("esiKick: esiProcess PENDING OK\n"); + debugs(86, 5, "esiKick: esiProcess PENDING OK"); break; case ESI_PROCESS_PENDING_MAYFAIL: - debug (86,5)("esiKick: esiProcess PENDING UNKNOWN\n"); + debugs(86, 5, "esiKick: esiProcess PENDING UNKNOWN"); break; case ESI_PROCESS_FAILED: - debug (86,2)("esiKick: esiProcess %p FAILED\n", this); + debugs(86, 2, "esiKick: esiProcess " << this << " FAILED"); /* this can not happen - processing can't fail until we have data, * and when we come here we have sent data to the client */ @@ -456,7 +456,7 @@ esiStreamRead (clientStreamNode *thisNode, ClientHttpRequest *http) } context->flags.clientwantsdata = 1; - debug (86,5)("esiStreamRead: Client now wants data\n"); + debugs(86, 5, "esiStreamRead: Client now wants data"); /* Ok, not passing through */ @@ -485,12 +485,12 @@ esiStreamRead (clientStreamNode *thisNode, ClientHttpRequest *http) * processing. stop here, a callback will resume the stream * flow */ - debug (86,5) ("esiStreamRead: Waiting for async resume of esi processing\n"); + debugs(86, 5, "esiStreamRead: Waiting for async resume of esi processing"); return; } if (context->flags.oktosend && context->flags.finished && context->outbound.getRaw()) { - debug (86,5)("all processing complete, but outbound data still buffered\n"); + debugs(86, 5, "all processing complete, but outbound data still buffered"); assert (!context->flags.clientwantsdata); /* client MUST be processing the last reply */ return; @@ -501,7 +501,7 @@ esiStreamRead (clientStreamNode *thisNode, ClientHttpRequest *http) StoreIOBuffer tempBuffer; assert (!context->outbound.getRaw()); /* We've finished processing, and there is no more data buffered */ - debug (86,5)("Telling recipient EOF on READ\n"); + debugs(86, 5, "Telling recipient EOF on READ"); clientStreamCallback (thisNode, http, NULL, tempBuffer); return; } @@ -546,7 +546,7 @@ esiStreamStatus (clientStreamNode *thisNode, ClientHttpRequest *http) if (context->flags.oktosend && context->flags.finished && !(context->outbound.getRaw() && context->outbound_offset < context->outbound->len)) { - debug (86,5) ("Telling recipient EOF on STATUS\n"); + debugs(86, 5, "Telling recipient EOF on STATUS"); return STREAM_UNPLANNED_COMPLETE; /* we don't know lengths in advance */ } @@ -587,7 +587,8 @@ ESIContext::trimBlanks() /* trim leading empty buffers ? */ while (outbound.getRaw() && outbound->next.getRaw() && !outbound->len) { - debug(86,5)("ESIContext::trimBlanks: %p skipping segment %p\n", this, outbound.getRaw()); + debugs(86, 5, "ESIContext::trimBlanks: " << this << + " skipping segment " << outbound.getRaw()); outbound = outbound->next; } @@ -601,18 +602,18 @@ ESIContext::trimBlanks() size_t ESIContext::send () { - debug (86,5)("ESIContext::send: this=%p\n",this); + debugs(86, 5, "ESIContext::send: this=" << this); /* send any processed data */ trimBlanks(); if (!flags.clientwantsdata) { - debug (86,5)("ESIContext::send: Client does not want data - not sending anything\n"); + debugs(86, 5, "ESIContext::send: Client does not want data - not sending anything"); return 0; } if (tree.getRaw() && tree->mayFail()) { - debug (86, 5)("ESIContext::send: Tree may fail. Not sending.\n"); + debugs(86, 5, "ESIContext::send: Tree may fail. Not sending."); return 0; } else flags.oktosend = 1; @@ -629,11 +630,11 @@ ESIContext::send () if (!(rep || (outbound.getRaw() && outbound->len && (outbound_offset <= outbound->len)))) { - debug (86,5)("ESIContext::send: Nothing to send.\n"); + debugs(86, 5, "ESIContext::send: Nothing to send."); return 0; } - debug (86,5)("ESIContext::send: Sending something...\n"); + debugs(86, 5, "ESIContext::send: Sending something..."); /* Yes! Send it without asking for more upstream */ /* memcopying because the client provided the buffer */ /* TODO: skip data until pos == next->readoff; */ @@ -670,7 +671,7 @@ ESIContext::send () } flags.clientwantsdata = 0; - debug (86,5)("ESIContext::send: this=%p Client no longer wants data \n",this); + debugs(86, 5, "ESIContext::send: this=" << this << " Client no longer wants data "); /* Deal with re-entrancy */ HttpReply *temprep = rep; rep = NULL; /* freed downstream */ @@ -777,7 +778,10 @@ esiProcessStream (clientStreamNode *thisNode, ClientHttpRequest *http, HttpReply return; } - debug (86, 3)("esiProcessStream: Processing thisNode %p context %p offset %d length %u\n",thisNode, context.getRaw(), (int) recievedData.offset, (unsigned int)recievedData.length); + debugs(86, 3, "esiProcessStream: Processing thisNode " << thisNode << + " context " << context.getRaw() << " offset " << + (int) recievedData.offset << " length " << + (unsigned int)recievedData.length); /* once we finish the template, we *cannot* return here */ assert (!context->flags.finishedtemplate); @@ -794,7 +798,7 @@ esiProcessStream (clientStreamNode *thisNode, ClientHttpRequest *http, HttpReply if (!context->incoming.getRaw()) { /* create a new buffer segment */ - debug (86,5) ("esiProcessStream: Setting up incoming buffer\n"); + debugs(86, 5, "esiProcessStream: Setting up incoming buffer"); context->buffered = new ESISegment; context->incoming = context->buffered; } @@ -803,8 +807,10 @@ esiProcessStream (clientStreamNode *thisNode, ClientHttpRequest *http, HttpReply /* We have to copy the data out because we didn't supply thisNode buffer */ size_t space = HTTP_REQBUF_SZ - context->incoming->len; size_t len = min (space, recievedData.length); - debug (86,5)("Copying data from %p to %p because our buffer was not used\n", recievedData.data, - &context->incoming->buf[context->incoming->len]); + debugs(86, 5, "Copying data from " << recievedData.data << " to " << + &context->incoming->buf[context->incoming->len] << + " because our buffer was not used"); + xmemcpy (&context->incoming->buf[context->incoming->len], recievedData.data, len); context->incoming->len += len; @@ -841,7 +847,7 @@ esiProcessStream (clientStreamNode *thisNode, ClientHttpRequest *http, HttpReply if (rep == NULL && recievedData.data == NULL && recievedData.length == 0 && !context->flags.finishedtemplate) { /* TODO: get stream status to test the entry for aborts */ /* else flush the esi processor */ - debug (86,5)("esiProcess: %p Finished reading upstream data\n", context.getRaw()); + debugs(86, 5, "esiProcess: " << context.getRaw() << " Finished reading upstream data"); /* This is correct */ context->flags.finishedtemplate = 1; } @@ -878,7 +884,7 @@ esiProcessStream (clientStreamNode *thisNode, ClientHttpRequest *http, HttpReply return; } - debug (86,3)("esiProcessStream: no data to send, no data to read, awaiting a callback\n"); + debugs(86, 3, "esiProcessStream: no data to send, no data to read, awaiting a callback"); } ESIContext::~ESIContext() @@ -886,7 +892,7 @@ ESIContext::~ESIContext() freeResources (); /* Not freed by freeresources because esi::fail needs it */ safe_free (errormessage); - debug (86,3)("ESIContext::~ESIContext: Freed %p\n", this); + debugs(86, 3, "ESIContext::~ESIContext: Freed " << this); } ESIContext * @@ -912,10 +918,10 @@ ESIContextNew (HttpReply *rep, clientStreamNode *thisNode, ClientHttpRequest *ht rv->http = http; rv->flags.clientwantsdata = 1; rv->varState = new ESIVarState (&http->request->header, http->uri); - debug (86,5)("ESIContextNew: Client wants data (always created during reply cycle\n"); + debugs(86, 5, "ESIContextNew: Client wants data (always created during reply cycle"); } - debug (86,5)("ESIContextNew: Create context %p\n",rv); + debugs(86, 5, "ESIContextNew: Create context " << rv); return rv; } @@ -992,10 +998,10 @@ ESIContext::addStackElement (ESIElement::Pointer element) /* Put on the stack to allow skipping of 'invalid' markup */ assert (parserState.stackdepth <11); assert (!failed()); - debug (86,5)("ESIContext::addStackElement: About to add ESI Node %p\n", element.getRaw()); + debugs(86, 5, "ESIContext::addStackElement: About to add ESI Node " << element.getRaw()); if (!parserState.top()->addElement(element)) { - debug (86,1)("ESIContext::addStackElement: failed to add esi node, probable error in ESI template\n"); + debugs(86, 1, "ESIContext::addStackElement: failed to add esi node, probable error in ESI template"); flags.error = 1; } else { /* added ok, push onto the stack */ @@ -1014,7 +1020,7 @@ ESIContext::start(const char *el, const char **attr, size_t attrCount) char *pos; assert (ellen < sizeof (localbuf)); /* prevent unexpected overruns. */ - debug (86, 5)("ESIContext::Start: element '%s' with %d tags\n", el, specifiedattcount); + debugs(86, 5, "ESIContext::Start: element '" << el << "' with " << specifiedattcount << " tags"); if (failed()) /* waiting for expat to finish the buffer we gave it */ @@ -1045,7 +1051,7 @@ ESIContext::start(const char *el, const char **attr, size_t attrCount) *pos = '\0'; addLiteral (localbuf, pos - localbuf); - debug (86,5)("esi stack depth %d\n",parserState.stackdepth); + debugs(86, 5, "esi stack depth " << parserState.stackdepth); return; break; @@ -1107,7 +1113,7 @@ ESIContext::start(const char *el, const char **attr, size_t attrCount) addStackElement(element); - debug (86,5)("esi stack depth %d\n",parserState.stackdepth); + debugs(86, 5, "esi stack depth " << parserState.stackdepth); } /* End of start handler */ @@ -1180,7 +1186,7 @@ ESIContext::parserComment (const char *s) return; if (!strncmp(s, "esi",3)) { - debug (86,5)("ESIContext::parserComment: ESI %s\n", F->desc); - debug(5, 0) ("tmout:%p read:%p write:%p\n", - F->timeout_handler, - F->read_handler, - F->write_handler); + debugs(5, 0, "WARNING: FD " << fd << " has handlers, but it's invalid."); + debugs(5, 0, "FD " << fd << " is a " << fdTypeStr[F->type]); + debugs(5, 0, "--> " << F->desc); + debugs(5, 0, "tmout:" << F->timeout_handler << " read:" << + F->read_handler << " write:" << F->write_handler); for (ch = F->closeHandler; ch; ch = ch->next) - debug(5, 0) (" close handler: %p\n", ch->handler); + debugs(5, 0, " close handler: " << ch->handler); if (F->closeHandler) { commCallCloseHandlers(fd); } else if (F->timeout_handler) { - debug(5, 0) ("comm_poll: Calling Timeout Handler\n"); + debugs(5, 0, "comm_poll: Calling Timeout Handler"); F->timeout_handler(fd, F->timeout_data); } @@ -607,7 +603,7 @@ comm_select(int msec) while ((fd = commGetSlowFd()) != -1) { fde *F = &fd_table[fd]; - debug(5, 6) ("comm_select: slow FD %d selected for reading\n", fd); + debugs(5, 6, "comm_select: slow FD " << fd << " selected for reading"); if ((hdl = F->read_handler)) { F->read_handler = NULL; @@ -633,7 +629,7 @@ comm_select(int msec) return COMM_OK; } while (timeout > current_dtime); - debug(5, 8) ("comm_poll: time out: %ld.\n", (long int) squid_curtime); + debugs(5, 8, "comm_poll: time out: " << (long int) squid_curtime << "."); return COMM_TIMEOUT; } diff --git a/src/comm_select.cc b/src/comm_select.cc index 5cb1a9ab2a..dac549407f 100644 --- a/src/comm_select.cc +++ b/src/comm_select.cc @@ -1,6 +1,6 @@ /* - * $Id: comm_select.cc,v 1.77 2006/09/02 10:39:53 adrian Exp $ + * $Id: comm_select.cc,v 1.78 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 5 Socket Functions * @@ -138,7 +138,7 @@ commSetSelect(int fd, unsigned int type, PF * handler, void *client_data, fde *F = &fd_table[fd]; assert(fd >= 0); assert(F->flags.open); - debug(5, 5) ("commSetSelect: FD %d type %d\n", fd, type); + debugs(5, 5, "commSetSelect: FD " << fd << " type " << type); if (type & COMM_SELECT_READ) { F->read_handler = handler; @@ -271,8 +271,7 @@ comm_check_incoming_select_handlers(int nfds, int *fds) commUpdateReadBits(fd, NULL); hdl(fd, fd_table[fd].read_data); } else { - debug(5, 1) ("comm_select_incoming: FD %d NULL read handler\n", - fd); + debugs(5, 1, "comm_select_incoming: FD " << fd << " NULL read handler"); } } @@ -282,8 +281,7 @@ comm_check_incoming_select_handlers(int nfds, int *fds) commUpdateWriteBits(fd, NULL); hdl(fd, fd_table[fd].write_data); } else { - debug(5, 1) ("comm_select_incoming: FD %d NULL write handler\n", - fd); + debugs(5, 1, "comm_select_incoming: FD " << fd << " NULL write handler"); } } } @@ -488,8 +486,7 @@ comm_select(int msec) if (ignoreErrno(errno)) break; - debug(5, 0) ("comm_select: select failure: %s\n", - xstrerror()); + debugs(5, 0, "comm_select: select failure: " << xstrerror()); examine_select(&readfds, &writefds); @@ -503,8 +500,7 @@ comm_select(int msec) getCurrentTime(); - debug(5, num ? 5 : 8) ("comm_select: %d+%d FDs ready\n", - num, pending); + debugs(5, num ? 5 : 8, "comm_select: " << num << "+" << pending << " FDs ready"); statHistCount(&statCounter.select_fds_hist, num); @@ -536,7 +532,7 @@ comm_select(int msec) #if DEBUG_FDBITS - debug(5, 9) ("FD %d bit set for reading\n", fd); + debugs(5, 9, "FD " << fd << " bit set for reading"); assert(FD_ISSET(fd, &readfds)); @@ -558,7 +554,7 @@ comm_select(int msec) } F = &fd_table[fd]; - debug(5, 6) ("comm_select: FD %d ready for reading\n", fd); + debugs(5, 6, "comm_select: FD " << fd << " ready for reading"); if (NULL == (hdl = F->read_handler)) (void) 0; @@ -608,7 +604,7 @@ comm_select(int msec) #if DEBUG_FDBITS - debug(5, 9) ("FD %d bit set for writing\n", fd); + debugs(5, 9, "FD " << fd << " bit set for writing"); assert(FD_ISSET(fd, &writefds)); @@ -630,7 +626,7 @@ comm_select(int msec) } F = &fd_table[fd]; - debug(5, 5) ("comm_select: FD %d ready for writing\n", fd); + debugs(5, 5, "comm_select: FD " << fd << " ready for writing"); if ((hdl = F->write_handler)) { F->write_handler = NULL; @@ -663,7 +659,7 @@ comm_select(int msec) while ((fd = commGetSlowFd()) != -1) { F = &fd_table[fd]; - debug(5, 6) ("comm_select: slow FD %d selected for reading\n", fd); + debugs(5, 6, "comm_select: slow FD " << fd << " selected for reading"); if ((hdl = F->read_handler)) { F->read_handler = NULL; @@ -691,7 +687,7 @@ comm_select(int msec) } while (timeout > current_dtime) ; - debug(5, 8) ("comm_select: time out: %d\n", (int) squid_curtime); + debugs(5, 8, "comm_select: time out: " << (int) squid_curtime); return COMM_TIMEOUT; } @@ -768,7 +764,7 @@ examine_select(fd_set * readfds, fd_set * writefds) fde *F = NULL; struct stat sb; - debug(5, 0) ("examine_select: Examining open file descriptors...\n"); + debugs(5, 0, "examine_select: Examining open file descriptors..."); for (fd = 0; fd < Squid_MaxFD; fd++) { FD_ZERO(&read_x); @@ -787,29 +783,23 @@ examine_select(fd_set * readfds, fd_set * writefds) errno = 0; if (!fstat(fd, &sb)) { - debug(5, 5) ("FD %d is valid.\n", fd); + debugs(5, 5, "FD " << fd << " is valid."); continue; } F = &fd_table[fd]; - debug(5, 0) ("FD %d: %s\n", fd, xstrerror()); - debug(5, 0) ("WARNING: FD %d has handlers, but it's invalid.\n", fd); - debug(5, 0) ("FD %d is a %s called '%s'\n", - fd, - fdTypeStr[F->type], - F->desc); - debug(5, 0) ("tmout:%p read:%p write:%p\n", - F->timeout_handler, - F->read_handler, - F->write_handler); + debugs(5, 0, "FD " << fd << ": " << xstrerror()); + debugs(5, 0, "WARNING: FD " << fd << " has handlers, but it's invalid."); + debugs(5, 0, "FD " << fd << " is a " << fdTypeStr[F->type] << " called '" << F->desc << "'"); + debugs(5, 0, "tmout:" << F->timeout_handler << " read:" << F->read_handler << " write:" << F->write_handler); for (ch = F->closeHandler; ch; ch = ch->next) - debug(5, 0) (" close handler: %p\n", ch->handler); + debugs(5, 0, " close handler: " << ch->handler); if (F->closeHandler) { commCallCloseHandlers(fd); } else if (F->timeout_handler) { - debug(5, 0) ("examine_select: Calling Timeout Handler\n"); + debugs(5, 0, "examine_select: Calling Timeout Handler"); F->timeout_handler(fd, F->timeout_data); } diff --git a/src/comm_select_win32.cc b/src/comm_select_win32.cc index 17052d0740..441429ae94 100644 --- a/src/comm_select_win32.cc +++ b/src/comm_select_win32.cc @@ -1,6 +1,6 @@ /* - * $Id: comm_select_win32.cc,v 1.2 2006/09/02 10:39:53 adrian Exp $ + * $Id: comm_select_win32.cc,v 1.3 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 5 Socket Functions * @@ -138,7 +138,7 @@ commSetSelect(int fd, unsigned int type, PF * handler, void *client_data, fde *F = &fd_table[fd]; assert(fd >= 0); assert(F->flags.open); - debug(5, 5) ("commSetSelect: FD %d type %d\n", fd, type); + debugs(5, 5, "commSetSelect: FD " << fd << " type " << type); if (type & COMM_SELECT_READ) { F->read_handler = handler; @@ -274,8 +274,7 @@ comm_check_incoming_select_handlers(int nfds, int *fds) commUpdateReadBits(fd, NULL); hdl(fd, fd_table[fd].read_data); } else { - debug(5, 1) ("comm_select_incoming: FD %d NULL read handler\n", - fd); + debugs(5, 1, "comm_select_incoming: FD " << fd << " NULL read handler"); } } @@ -285,8 +284,7 @@ comm_check_incoming_select_handlers(int nfds, int *fds) commUpdateWriteBits(fd, NULL); hdl(fd, fd_table[fd].write_data); } else { - debug(5, 1) ("comm_select_incoming: FD %d NULL write handler\n", - fd); + debugs(5, 1, "comm_select_incoming: FD " << fd << " NULL write handler"); } } } @@ -488,8 +486,7 @@ comm_select(int msec) if (ignoreErrno(errno)) break; - debug(5, 0) ("comm_select: select failure: %s\n", - xstrerror()); + debugs(5, 0, "comm_select: select failure: " << xstrerror()); examine_select(&readfds, &writefds); @@ -503,8 +500,7 @@ comm_select(int msec) getCurrentTime(); - debug(5, num ? 5 : 8) ("comm_select: %d+%d FDs ready\n", - num, pending); + debugs(5, num ? 5 : 8, "comm_select: " << num << "+" << pending << " FDs ready\n"); statHistCount(&statCounter.select_fds_hist, num); @@ -540,7 +536,7 @@ comm_select(int msec) #if DEBUG_FDBITS - debug(5, 9) ("FD %d bit set for reading\n", fd); + debugs(5, 9, "FD " << fd << " bit set for reading"); assert(FD_ISSET(fd, &readfds)); @@ -562,7 +558,7 @@ comm_select(int msec) } F = &fd_table[fd]; - debug(5, 6) ("comm_select: FD %d ready for reading\n", fd); + debugs(5, 6, "comm_select: FD " << fd << " ready for reading"); if (NULL == (hdl = F->read_handler)) (void) 0; @@ -633,7 +629,7 @@ comm_select(int msec) #if DEBUG_FDBITS - debug(5, 9) ("FD %d bit set for writing\n", fd); + debugs(5, 9, "FD " << fd << " bit set for writing"); assert(FD_ISSET(fd, &writefds)); @@ -655,7 +651,7 @@ comm_select(int msec) } F = &fd_table[fd]; - debug(5, 5) ("comm_select: FD %d ready for writing\n", fd); + debugs(5, 5, "comm_select: FD " << fd << " ready for writing"); if ((hdl = F->write_handler)) { F->write_handler = NULL; @@ -689,7 +685,7 @@ comm_select(int msec) while ((fd = commGetSlowFd()) != -1) { F = &fd_table[fd]; - debug(5, 6) ("comm_select: slow FD %d selected for reading\n", fd); + debugs(5, 6, "comm_select: slow FD " << fd << " selected for reading"); if ((hdl = F->read_handler)) { F->read_handler = NULL; @@ -717,7 +713,7 @@ comm_select(int msec) } while (timeout > current_dtime) ; - debug(5, 8) ("comm_select: time out: %d\n", (int) squid_curtime); + debugs(5, 8, "comm_select: time out: " << (int) squid_curtime); return COMM_TIMEOUT; } @@ -794,7 +790,7 @@ examine_select(fd_set * readfds, fd_set * writefds) fde *F = NULL; struct stat sb; - debug(5, 0) ("examine_select: Examining open file descriptors...\n"); + debugs(5, 0, "examine_select: Examining open file descriptors..."); for (fd = 0; fd < Squid_MaxFD; fd++) { FD_ZERO(&read_x); @@ -813,29 +809,23 @@ examine_select(fd_set * readfds, fd_set * writefds) errno = 0; if (!fstat(fd, &sb)) { - debug(5, 5) ("FD %d is valid.\n", fd); + debugs(5, 5, "FD " << fd << " is valid."); continue; } F = &fd_table[fd]; - debug(5, 0) ("FD %d: %s\n", fd, xstrerror()); - debug(5, 0) ("WARNING: FD %d has handlers, but it's invalid.\n", fd); - debug(5, 0) ("FD %d is a %s called '%s'\n", - fd, - fdTypeStr[F->type], - F->desc); - debug(5, 0) ("tmout:%p read:%p write:%p\n", - F->timeout_handler, - F->read_handler, - F->write_handler); + debugs(5, 0, "FD " << fd << ": " << xstrerror()); + debugs(5, 0, "WARNING: FD " << fd << " has handlers, but it's invalid."); + debugs(5, 0, "FD " << fd << " is a " << fdTypeStr[F->type] << " called '" << F->desc << "'"); + debugs(5, 0, "tmout:" << F->timeout_handler << " read:" << F->read_handler << " write:" << F->write_handler); for (ch = F->closeHandler; ch; ch = ch->next) - debug(5, 0) (" close handler: %p\n", ch->handler); + debugs(5, 0, " close handler: " << ch->handler); if (F->closeHandler) { commCallCloseHandlers(fd); } else if (F->timeout_handler) { - debug(5, 0) ("examine_select: Calling Timeout Handler\n"); + debugs(5, 0, "examine_select: Calling Timeout Handler"); F->timeout_handler(fd, F->timeout_data); } diff --git a/src/debug.cc b/src/debug.cc index a26079ba01..464bc5ad92 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -1,6 +1,6 @@ /* - * $Id: debug.cc,v 1.101 2007/04/11 22:58:32 wessels Exp $ + * $Id: debug.cc,v 1.102 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -563,7 +563,7 @@ debugLogTime(void) { void xassert(const char *msg, const char *file, int line) { - debug(0, 0) ("assertion failed: %s:%d: \"%s\"\n", file, line, msg); + debugs(0, 0, "assertion failed: " << file << ":" << line << ": \"" << msg << "\""); if (!shutting_down) abort(); @@ -603,7 +603,7 @@ xassert(const char *msg, const char *file, int line) { * // detect exceptional condition, and simply report it, the context * // information will be available somewhere close in the log file * if (status == STRANGE_STATUS) - * debug(13, 6) ("DOS attack detected, data: %p\n", data); + * debugs(13, 6, "DOS attack detected, data: " << data); * ... * } * @@ -671,7 +671,7 @@ ctx_enter(const char *descr) { Ctx_Descrs[Ctx_Current_Level] = descr; if (Ctx_Current_Level == Ctx_Warn_Level) { - debug(0, 0) ("# ctx: suspiciously deep (%d) nesting:\n", Ctx_Warn_Level); + debugs(0, 0, "# ctx: suspiciously deep (" << Ctx_Warn_Level << ") nesting:"); Ctx_Warn_Level *= 2; } diff --git a/src/delay_pools.cc b/src/delay_pools.cc index 7a8cbaca08..8e7f7e731c 100644 --- a/src/delay_pools.cc +++ b/src/delay_pools.cc @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.cc,v 1.47 2006/08/07 02:28:22 robertc Exp $ + * $Id: delay_pools.cc,v 1.48 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -662,7 +662,7 @@ void DelayPools::pools (u_short newPools) { if (pools()) { - debug(3, 0) ("parse_delay_pool_count: multiple delay_pools lines, aborting all previous delay_pools config\n"); + debugs(3, 0, "parse_delay_pool_count: multiple delay_pools lines, aborting all previous delay_pools config"); FreePools(); } diff --git a/src/disk.cc b/src/disk.cc index 2cc358a42a..32a27b431f 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,6 +1,6 @@ /* - * $Id: disk.cc,v 1.171 2005/09/17 05:50:08 wessels Exp $ + * $Id: disk.cc,v 1.172 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived @@ -75,11 +75,10 @@ file_open(const char *path, int mode) statCounter.syscalls.disk.opens++; if (fd < 0) { - debug(50, 3) ("file_open: error opening file %s: %s\n", path, - xstrerror()); + debugs(50, 3, "file_open: error opening file " << path << ": " << xstrerror()); fd = DISK_ERROR; } else { - debug(6, 5) ("file_open: FD %d\n", fd); + debugs(6, 5, "file_open: FD " << fd); commSetCloseOnExec(fd); fd_open(fd, FD_FILE, path); } @@ -118,7 +117,7 @@ file_close(int fd) F->flags.close_request = 1; - debug(6, 2) ("file_close: FD %d, delaying close\n", fd); + debugs(6, 2, "file_close: FD " << fd << ", delaying close"); PROF_stop(file_close); @@ -144,8 +143,7 @@ file_close(int fd) close(fd); - debug(6, F->flags.close_request ? 2 : 5) - ("file_close: FD %d, really closing\n", fd); + debugs(6, F->flags.close_request ? 2 : 5, "file_close: FD " << fd << " really closing\n"); fd_close(fd); @@ -235,7 +233,7 @@ diskHandleWrite(int fd, void *notused) PROF_start(diskHandleWrite); - debug(6, 3) ("diskHandleWrite: FD %d\n", fd); + debugs(6, 3, "diskHandleWrite: FD " << fd); F->flags.write_daemon = 0; @@ -243,8 +241,7 @@ diskHandleWrite(int fd, void *notused) assert(fdd->write_q->len > fdd->write_q->buf_offset); - debug(6, 3) ("diskHandleWrite: FD %d writing %d bytes\n", - fd, (int) (fdd->write_q->len - fdd->write_q->buf_offset)); + debugs(6, 3, "diskHandleWrite: FD " << fd << " writing " << (int) (fdd->write_q->len - fdd->write_q->buf_offset) << " bytes"); errno = 0; @@ -255,7 +252,7 @@ diskHandleWrite(int fd, void *notused) fdd->write_q->buf + fdd->write_q->buf_offset, fdd->write_q->len - fdd->write_q->buf_offset); - debug(6, 3) ("diskHandleWrite: FD %d len = %d\n", fd, len); + debugs(6, 3, "diskHandleWrite: FD " << fd << " len = " << len); statCounter.syscalls.disk.writes++; @@ -264,8 +261,8 @@ diskHandleWrite(int fd, void *notused) if (len < 0) { if (!ignoreErrno(errno)) { status = errno == ENOSPC ? DISK_NO_SPACE_LEFT : DISK_ERROR; - debug(50, 1) ("diskHandleWrite: FD %d: disk write error: %s\n", - fd, xstrerror()); + debugs(50, 1, "diskHandleWrite: FD " << fd << ": disk write error: " << xstrerror()); + /* * If there is no write callback, then this file is * most likely something important like a log file, or @@ -309,8 +306,10 @@ diskHandleWrite(int fd, void *notused) q->buf_offset += len; if (q->buf_offset > q->len) - debug(50, 1) ("diskHandleWriteComplete: q->buf_offset > q->len (%p,%d, %d, %d FD %d)\n", - q, (int) q->buf_offset, q->len, len, fd); + debugs(50, 1, "diskHandleWriteComplete: q->buf_offset > q->len (" << + q << "," << (int) q->buf_offset << ", " << q->len << ", " << + len << " FD " << fd << ")"); + assert(q->buf_offset <= q->len); @@ -445,8 +444,7 @@ diskHandleRead(int fd, void *data) PROF_start(diskHandleRead); if (F->disk.offset != ctrl_dat->offset) { - debug(6, 3) ("diskHandleRead: FD %d seeking to offset %d\n", - fd, (int) ctrl_dat->offset); + debugs(6, 3, "diskHandleRead: FD " << fd << " seeking to offset " << (int) ctrl_dat->offset); lseek(fd, ctrl_dat->offset, SEEK_SET); /* XXX ignore return? */ statCounter.syscalls.disk.seeks++; F->disk.offset = ctrl_dat->offset; @@ -469,7 +467,7 @@ diskHandleRead(int fd, void *data) return; } - debug(50, 1) ("diskHandleRead: FD %d: %s\n", fd, xstrerror()); + debugs(50, 1, "diskHandleRead: FD " << fd << ": " << xstrerror()); len = 0; rc = DISK_ERROR; } else if (len == 0) { @@ -515,7 +513,7 @@ safeunlink(const char *s, int quiet) statCounter.syscalls.disk.unlinks++; if (unlink(s) < 0 && !quiet) - debug(50, 1) ("safeunlink: Couldn't delete %s: %s\n", s, xstrerror()); + debugs(50, 1, "safeunlink: Couldn't delete " << s << ": " << xstrerror()); } /* @@ -526,7 +524,7 @@ safeunlink(const char *s, int quiet) int xrename(const char *from, const char *to) { - debug(21, 2) ("xrename: renaming %s to %s\n", from, to); + debugs(21, 2, "xrename: renaming " << from << " to " << to); #if defined (_SQUID_OS2_) || defined (_SQUID_WIN32_) remove @@ -537,8 +535,7 @@ xrename(const char *from, const char *to) if (0 == rename(from, to)) return 0; - debug(21, errno == ENOENT ? 2 : 1) ("xrename: Cannot rename %s to %s: %s\n", - from, to, xstrerror()); + debugs(21, errno == ENOENT ? 2 : 1, "xrename: Cannot rename " << from << " to " << to << ": " << xstrerror()); return -1; } diff --git a/src/dns.cc b/src/dns.cc index b1a18b074e..0df6d429d1 100644 --- a/src/dns.cc +++ b/src/dns.cc @@ -1,6 +1,6 @@ /* - * $Id: dns.cc,v 1.99 2006/10/20 05:34:20 wessels Exp $ + * $Id: dns.cc,v 1.100 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 34 Dnsserver interface * AUTHOR: Harvest Derived @@ -125,7 +125,7 @@ dnsSubmit(const char *lookup, HLPCB * callback, void *data) if (squid_curtime - first_warn > 3 * 60) fatal("DNS servers not responding for 3 minutes"); - debug(34, 1) ("dnsSubmit: queue overload, rejecting %s\n", lookup); + debugs(34, 1, "dnsSubmit: queue overload, rejecting " << lookup); callback(data, (char *)"$fail Temporary network problem, please retry later"); @@ -144,7 +144,7 @@ variable_list * snmp_netDnsFn(variable_list * Var, snint * ErrP) { variable_list *Answer = NULL; - debug(49, 5) ("snmp_netDnsFn: Processing request: %d\n", Var->name[LEN_SQ_NET + 1]); + debugs(49, 5, "snmp_netDnsFn: Processing request: " << Var->name[LEN_SQ_NET + 1]); snmpDebugOid(5, Var->name, Var->name_length); *ErrP = SNMP_ERR_NOERROR; diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 65c1f76f33..4d01c272a2 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -1,6 +1,6 @@ /* - * $Id: dns_internal.cc,v 1.96 2007/04/13 17:04:00 wessels Exp $ + * $Id: dns_internal.cc,v 1.97 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c * AUTHOR: Duane Wessels @@ -191,13 +191,13 @@ idnsAddNameserver(const char *buf) struct IN_ADDR A; if (!safe_inet_addr(buf, &A)) { - debug(78, 0) ("WARNING: rejecting '%s' as a name server, because it is not a numeric IP address\n", buf); + debugs(78, 0, "WARNING: rejecting '" << buf << "' as a name server, because it is not a numeric IP address"); return; } if (A.s_addr == 0) { - debug(78, 0) ("WARNING: Squid does not accept 0.0.0.0 in DNS server specifications.\n"); - debug(78, 0) ("Will be using 127.0.0.1 instead, assuming you meant that DNS is running on the same machine\n"); + debugs(78, 0, "WARNING: Squid does not accept 0.0.0.0 in DNS server specifications."); + debugs(78, 0, "Will be using 127.0.0.1 instead, assuming you meant that DNS is running on the same machine"); safe_inet_addr("127.0.0.1", &A); } @@ -223,8 +223,7 @@ idnsAddNameserver(const char *buf) nameservers[nns].S.sin_family = AF_INET; nameservers[nns].S.sin_port = htons(NS_DEFAULTPORT); nameservers[nns].S.sin_addr.s_addr = A.s_addr; - debug(78, 3) ("idnsAddNameserver: Added nameserver #%d: %s\n", - nns, inet_ntoa(nameservers[nns].S.sin_addr)); + debugs(78, 3, "idnsAddNameserver: Added nameserver #" << nns << ": " << inet_ntoa(nameservers[nns].S.sin_addr)); nns++; } @@ -251,8 +250,7 @@ idnsAddPathComponent(const char *buf) assert(npc < npc_alloc); strcpy(searchpath[npc].domain, buf); - debug(78, 3) ("idnsAddPathComponent: Added domain #%d: %s\n", - npc, searchpath[npc].domain); + debugs(78, 3, "idnsAddPathComponent: Added domain #" << npc << ": " << searchpath[npc].domain); npc++; } @@ -279,7 +277,7 @@ idnsParseNameservers(void) wordlist *w; for (w = Config.dns_nameservers; w; w = w->next) { - debug(78, 1) ("Adding nameserver %s from squid.conf\n", w->key); + debugs(78, 1, "Adding nameserver " << w->key << " from squid.conf"); idnsAddNameserver(w->key); } } @@ -294,7 +292,7 @@ idnsParseResolvConf(void) fp = fopen(_PATH_RESCONF, "r"); if (fp == NULL) { - debug(78, 1) ("%s: %s\n", _PATH_RESCONF, xstrerror()); + debugs(78, 1, "" << _PATH_RESCONF << ": " << xstrerror()); return; } @@ -314,7 +312,7 @@ idnsParseResolvConf(void) if (NULL == t) continue; - debug(78, 1) ("Adding nameserver %s from %s\n", t, _PATH_RESCONF); + debugs(78, 1, "Adding nameserver " << t << " from " << _PATH_RESCONF); idnsAddNameserver(t); } else if (strcasecmp(t, "search") == 0) { @@ -324,7 +322,7 @@ idnsParseResolvConf(void) if (NULL == t) continue; - debug(78, 1) ("Adding domain %s from %s\n", t, _PATH_RESCONF); + debugs(78, 1, "Adding domain " << t << " from " << _PATH_RESCONF); idnsAddPathComponent(t); } @@ -341,7 +339,7 @@ idnsParseResolvConf(void) if (ndots < 1) ndots = 1; - debug(78, 1) ("Adding ndots %d from %s\n", ndots, _PATH_RESCONF); + debugs(78, 1, "Adding ndots " << ndots << " from " << _PATH_RESCONF); } } } @@ -759,7 +757,7 @@ idnsSendQuery(idns_query * q) int ns; if (DnsSocket < 0) { - debug(78, 1) ("idnsSendQuery: Can't send query, no DNS socket!\n"); + debugs(78, 1, "idnsSendQuery: Can't send query, no DNS socket!"); return; } @@ -788,8 +786,7 @@ try_again: q->sent_t = current_time; if (x < 0) { - debug(50, 1) ("idnsSendQuery: FD %d: sendto: %s\n", - DnsSocket, xstrerror()); + debugs(50, 1, "idnsSendQuery: FD " << DnsSocket << ": sendto: " << xstrerror()); if (q->nsends % nns != 0) goto try_again; @@ -849,7 +846,7 @@ idnsQueryID(void) id++; if (id == first_id) { - debug(78, 1) ("idnsQueryID: Warning, too many pending DNS requests\n"); + debugs(78, 1, "idnsQueryID: Warning, too many pending DNS requests"); break; } } @@ -899,22 +896,22 @@ idnsGrokReply(const char *buf, size_t sz) &message); if (message == NULL) { - debug(78, 1) ("idnsGrokReply: Malformed DNS response\n"); + debugs(78, 1, "idnsGrokReply: Malformed DNS response"); return; } - debug(78, 3) ("idnsGrokReply: ID %#hx, %d answers\n", message->id, n); + debugs(78, 3, "idnsGrokReply: ID 0x" << std::hex << message->id << ", " << std::dec << n << "answers"); q = idnsFindQuery(message->id); if (q == NULL) { - debug(78, 3) ("idnsGrokReply: Late response\n"); + debugs(78, 3, "idnsGrokReply: Late response"); rfc1035MessageDestroy(message); return; } if (rfc1035QueryCompare(&q->query, message->query) != 0) { - debug(78, 3) ("idnsGrokReply: Query mismatch (%s != %s)\n", q->query.name, message->query->name); + debugs(78, 3, "idnsGrokReply: Query mismatch (" << q->query.name << " != " << message->query->name << ")"); rfc1035MessageDestroy(message); return; } @@ -937,7 +934,7 @@ idnsGrokReply(const char *buf, size_t sz) q->error = NULL; if (n < 0) { - debug(78, 3) ("idnsGrokReply: error %s (%d)\n", rfc1035_error_message, rfc1035_errno); + debugs(78, 3, "idnsGrokReply: error " << rfc1035_error_message << " (" << rfc1035_errno << ")"); q->error = rfc1035_error_message; q->rcode = -n; @@ -963,8 +960,7 @@ idnsGrokReply(const char *buf, size_t sz) if (q->domain < npc) { strcat(q->name, "."); strcat(q->name, searchpath[q->domain].domain); - debug(78, 3) ("idnsGrokReply: searchpath used for %s\n", - q->name); + debugs(78, 3, "idnsGrokReply: searchpath used for " << q->name); q->domain++; } else { q->attempt++; @@ -1022,8 +1018,7 @@ idnsRead(int fd, void *data) if (errno != ECONNREFUSED && errno != EHOSTUNREACH) #endif - debug(50, 1) ("idnsRead: FD %d recvfrom: %s\n", - fd, xstrerror()); + debugs(50, 1, "idnsRead: FD " << fd << " recvfrom: " << xstrerror()); break; } @@ -1031,10 +1026,7 @@ idnsRead(int fd, void *data) fd_bytes(DnsSocket, len, FD_READ); assert(N); (*N)++; - debug(78, 3) ("idnsRead: FD %d: received %d bytes from %s.\n", - fd, - (int) len, - inet_ntoa(from.sin_addr)); + debugs(78, 3, "idnsRead: FD " << fd << ": received " << (int) len << " bytes from " << inet_ntoa(from.sin_addr) << "."); ns = idnsFromKnownNameserver(&from); if (ns >= 0) { @@ -1043,8 +1035,7 @@ idnsRead(int fd, void *data) static time_t last_warning = 0; if (squid_curtime - last_warning > 60) { - debug(78, 1) ("WARNING: Reply from unknown nameserver [%s]\n", - inet_ntoa(from.sin_addr)); + debugs(78, 1, "WARNING: Reply from unknown nameserver [" << inet_ntoa(from.sin_addr) << "]"); last_warning = squid_curtime; } @@ -1076,8 +1067,7 @@ idnsCheckQueue(void *unused) if (tvSubDsec(q->sent_t, current_time) < Config.Timeout.idns_retransmit * (1 << (q->nsends - 1) % nns)) break; - debug(78, 3) ("idnsCheckQueue: ID %#04x timeout\n", - q->id); + debugs(78, 3, "idnsCheckQueue: ID 0x" << std::hex << std::setfill('0') << std::setw(4) << q->id << "timeout" ); p = n->prev; @@ -1086,9 +1076,9 @@ idnsCheckQueue(void *unused) if (tvSubDsec(q->start_t, current_time) < Config.Timeout.idns_query) { idnsSendQuery(q); } else { - debug(78, 2) ("idnsCheckQueue: ID %x: giving up after %d tries and %5.1f seconds\n", - (int) q->id, q->nsends, - tvSubDsec(q->start_t, current_time)); + debugs(78, 2, "idnsCheckQueue: ID " << std::hex << (int) q->id << + ": giving up after " << std::dec << q->nsends << " tries and " << + std::setw(5)<< std::setprecision(2) << tvSubDsec(q->start_t, current_time) << " seconds"); if (q->rcode != 0) idnsCallback(q, NULL, -q->rcode, q->error); @@ -1122,10 +1112,9 @@ idnsReadVC(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *dat return; } - debug(78, 3) ("idnsReadVC: FD %d: received %d bytes via tcp from %s.\n", - fd, - (int) vc->msg->contentSize(), - inet_ntoa(nameservers[vc->ns].S.sin_addr)); + debugs(78, 3, "idnsReadVC: FD " << fd << ": received " << + (int) vc->msg->contentSize() << " bytes via tcp from " << + inet_ntoa(nameservers[vc->ns].S.sin_addr) << "."); idnsGrokReply(vc->msg->buf, vc->msg->contentSize()); vc->msg->clean(); @@ -1213,9 +1202,8 @@ idnsInit(void) */ port = comm_local_port(DnsSocket); - debug(78, 1) ("DNS Socket created at %s, port %d, FD %d\n", - inet_ntoa(addr), - port, DnsSocket); + debugs(78, 1, "DNS Socket created at " << inet_ntoa(addr) << ", port " << + port << ", FD " << DnsSocket); } assert(0 == nns); @@ -1344,8 +1332,7 @@ idnsALookup(const char *name, IDNSCB * callback, void *data) q->domain = 0; strcat(q->name, "."); strcat(q->name, searchpath[q->domain].domain); - debug(78, 3) ("idnsALookup: searchpath used for %s\n", - q->name); + debugs(78, 3, "idnsALookup: searchpath used for " << q->name); } q->sz = rfc1035BuildAQuery(q->name, q->buf, sizeof(q->buf), q->id, @@ -1358,8 +1345,8 @@ idnsALookup(const char *name, IDNSCB * callback, void *data) return; } - debug(78, 3) ("idnsALookup: buf is %d bytes for %s, id = %#hx\n", - (int) q->sz, q->name, q->id); + debugs(78, 3, "idnsALookup: buf is " << (int) q->sz << " bytes for " << q->name << + ", id = 0x" << std::hex << q->id); q->callback = callback; @@ -1399,8 +1386,8 @@ idnsPTRLookup(const struct IN_ADDR addr, IDNSCB * callback, void *data) return; } - debug(78, 3) ("idnsPTRLookup: buf is %d bytes for %s, id = %#hx\n", - (int) q->sz, ip, q->id); + debugs(78, 3, "idnsPTRLookup: buf is " << (int) q->sz << " bytes for " << ip << + ", id = 0x" << std::hex << q->id); q->callback = callback; @@ -1422,7 +1409,7 @@ snmp_netIdnsFn(variable_list * Var, snint * ErrP) { int i, n = 0; variable_list *Answer = NULL; - debug(49, 5) ("snmp_netDnsFn: Processing request: \n"); + debugs(49, 5, "snmp_netDnsFn: Processing request: "); snmpDebugOid(5, Var->name, Var->name_length); *ErrP = SNMP_ERR_NOERROR; diff --git a/src/errorpage.cc b/src/errorpage.cc index f8a619d2a5..276e45ae02 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.222 2007/04/21 07:14:14 wessels Exp $ + * $Id: errorpage.cc,v 1.223 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -226,7 +226,7 @@ errorTryLoadText(const char *page_name, const char *dir) fd = file_open(path, O_RDONLY | O_TEXT); if (fd < 0) { - debug(4, 0) ("errorTryLoadText: '%s': %s\n", path, xstrerror()); + debugs(4, 0, "errorTryLoadText: '" << path << "': " << xstrerror()); return NULL; } @@ -237,8 +237,7 @@ errorTryLoadText(const char *page_name, const char *dir) } if (len < 0) { - debug(4, 0) ("errorTryLoadText: failed to fully read: '%s': %s\n", - path, xstrerror()); + debugs(4, 0, "errorTryLoadText: failed to fully read: '" << path << "': " << xstrerror()); } file_close(fd); @@ -376,7 +375,7 @@ errorAppendEntry(StoreEntry * entry, ErrorState * err) if (err->page_id == TCP_RESET) { if (err->request) { - debug(4, 2) ("RSTing this reply\n"); + debugs(4, 2, "RSTing this reply"); err->request->flags.setResetTCP(); } } @@ -424,7 +423,7 @@ void errorSend(int fd, ErrorState * err) { HttpReply *rep; - debug(4, 3) ("errorSend: FD %d, err=%p\n", fd, err); + debugs(4, 3, "errorSend: FD " << fd << ", err=" << err); assert(fd >= 0); /* * ugh, this is how we make sure error codes get back to @@ -457,15 +456,15 @@ static void errorSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, int xerrno, void *data) { ErrorState *err = static_cast(data); - debug(4, 3) ("errorSendComplete: FD %d, size=%ld\n", fd, (long int) size); + debugs(4, 3, "errorSendComplete: FD " << fd << ", size=" << (long int) size); if (errflag != COMM_ERR_CLOSING) { if (err->callback) { - debug(4, 3) ("errorSendComplete: callback\n"); + debugs(4, 3, "errorSendComplete: callback"); err->callback(fd, err->callback_data, size); } else { comm_close(fd); - debug(4, 3) ("errorSendComplete: comm_close\n"); + debugs(4, 3, "errorSendComplete: comm_close"); } } @@ -847,7 +846,7 @@ errorConvert(char token, ErrorState * err) assert(p); - debug(4, 3) ("errorConvert: %%%c --> '%s'\n", token, p); + debugs(4, 3, "errorConvert: %%" << token << " --> '" << p << "'" ); if (do_quote) p = html_quote(p); diff --git a/src/external_acl.cc b/src/external_acl.cc index 9fd8083599..9b319bbd61 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -1,6 +1,6 @@ /* - * $Id: external_acl.cc,v 1.76 2007/04/20 22:11:34 wessels Exp $ + * $Id: external_acl.cc,v 1.77 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -587,12 +587,12 @@ ACLExternal::valid () const { if (data->def->require_auth) { if (authenticateSchemeCount() == 0) { - debug(28, 0) ("Can't use proxy auth because no authentication schemes were compiled.\n"); + debugs(28, 0, "Can't use proxy auth because no authentication schemes were compiled."); return false; } if (authenticateActiveSchemeCount() == 0) { - debug(28, 0) ("Can't use proxy auth because no authentication schemes are fully configured.\n"); + debugs(28, 0, "Can't use proxy auth because no authentication schemes are fully configured."); return false; } } @@ -620,7 +620,7 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch) int result; external_acl_entry *entry; const char *key = ""; - debug(82, 9) ("aclMatchExternal: acl=\"%s\"\n", acl->def->name); + debugs(82, 9, "aclMatchExternal: acl=\"" << acl->def->name << "\""); entry = ch->extacl_entry; if (entry) { @@ -642,7 +642,7 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch) /* Make sure the user is authenticated */ if ((ti = ch->authenticated()) != 1) { - debug(82, 2) ("aclMatchExternal: %s user not authenticated (%d)\n", acl->def->name, ti); + debugs(82, 2, "aclMatchExternal: " << acl->def->name << " user not authenticated (" << ti << ")"); return ti; } } @@ -660,25 +660,27 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch) entry = static_cast(hash_lookup(acl->def->cache, key)); if (!entry || external_acl_grace_expired(acl->def, entry)) { - debug(82, 2) ("aclMatchExternal: %s(\"%s\") = lookup needed\n", acl->def->name, key); - debug(82, 2) ("aclMatchExternal: \"%s\": entry=@%p, age=%ld\n", key, entry, - entry ? (long int) squid_curtime - entry->date : 0); + debugs(82, 2, "aclMatchExternal: " << acl->def->name << "(\"" << key << "\") = lookup needed"); + debugs(82, 2, "aclMatchExternal: \"" << key << "\": entry=@" << + entry << ", age=" << (entry ? (long int) squid_curtime - entry->date : 0)); if (acl->def->theHelper->stats.queue_size <= acl->def->theHelper->n_running) { - debug(82, 2) ("aclMatchExternal: \"%s\": queueing a call.\n", key); + debugs(82, 2, "aclMatchExternal: \"" << key << "\": queueing a call."); ch->changeState (ExternalACLLookup::Instance()); if (entry == NULL) { - debug(82, 2) ("aclMatchExternal: \"%s\": return -1.\n", key); + debugs(82, 2, "aclMatchExternal: \"" << key << "\": return -1."); return -1; } } else { if (!entry) { - debug(82, 1) ("aclMatchExternal: '%s' queue overload. Request rejected '%s'.\n", acl->def->name, key); + debugs(82, 1, "aclMatchExternal: '" << acl->def->name << + "' queue overload. Request rejected '" << key << "'."); external_acl_message = "SYSTEM TOO BUSY, TRY AGAIN LATER"; return -1; } else { - debug(82, 1) ("aclMatchExternal: '%s' queue overload. Using stale result. '%s'.\n", acl->def->name, key); + debugs(82, 1, "aclMatchExternal: '" << acl->def->name << + "' queue overload. Using stale result. '" << key << "'."); /* Fall thru to processing below */ } } @@ -689,7 +691,7 @@ aclMatchExternal(external_acl_data *acl, ACLChecklist * ch) result = entry->result; external_acl_message = entry->message.buf(); - debug(82, 2) ("aclMatchExternal: %s = %d\n", acl->def->name, result); + debugs(82, 2, "aclMatchExternal: " << acl->def->name << " = " << result); if (ch->request) { if (entry->user.size()) @@ -959,10 +961,10 @@ static external_acl_entry * external_acl_cache_add(external_acl * def, const char *key, ExternalACLEntryData const & data) { ExternalACLEntry *entry = static_cast(hash_lookup(def->cache, key)); - debug(82, 2) ("external_acl_cache_add: Adding '%s' = %d\n", key, data.result); + debugs(82, 2, "external_acl_cache_add: Adding '" << key << "' = " << data.result); if (entry) { - debug(82, 3) ("ExternalACLEntry::update: updating existing entry\n"); + debugs(82, 3, "ExternalACLEntry::update: updating existing entry"); entry->update (data); external_acl_cache_touch(def, entry); @@ -1052,7 +1054,7 @@ externalAclHandleReply(void *data, char *reply) entryData.result = 0; external_acl_entry *entry = NULL; - debug(82, 2) ("externalAclHandleReply: reply=\"%s\"\n", reply); + debugs(82, 2, "externalAclHandleReply: reply=\"" << reply << "\""); if (reply) { status = strwordtok(reply, &t); @@ -1133,8 +1135,8 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba /* Make sure the user is authenticated */ if ((ti = ch->authenticated()) != 1) { - debug(82, 1) ("externalAclLookup: %s user authentication failure (%d, ch=%p)\n", - acl->def->name, ti, ch); + debugs(82, 1, "externalAclLookup: " << acl->def->name << + " user authentication failure (" << ti << ", ch=" << ch << ")"); callback(callback_data, NULL); return; } @@ -1143,12 +1145,14 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba const char *key = makeExternalAclKey(ch, acl); if (!key) { - debug(82, 1) ("externalAclLookup: lookup in '%s', prerequisit failure (ch=%p)\n", def->name, ch); + debugs(82, 1, "externalAclLookup: lookup in '" << def->name << + "', prerequisit failure (ch=" << ch << ")"); callback(callback_data, NULL); return; } - debug(82, 2) ("externalAclLookup: lookup in '%s' for '%s'\n", def->name, key); + debugs(82, 2, "externalAclLookup: lookup in '" << def->name << "' for '" << key << "'"); + external_acl_entry *entry = static_cast(hash_lookup(def->cache, key)); if (entry && external_acl_entry_expired(def, entry)) @@ -1166,8 +1170,7 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba if (entry && external_acl_grace_expired(def, entry)) { if (oldstate) { - debug(82, 4) ("externalAclLookup: in grace period, but already pending lookup ('%s', ch=%p)\n", - key, ch); + debugs(82, 4, "externalAclLookup: in grace period, but already pending lookup ('" << key << "', ch=" << ch << ")"); callback(callback_data, entry); return; } else { @@ -1179,8 +1182,8 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba if (!graceful && entry && !external_acl_grace_expired(def, entry)) { /* Should not really happen, but why not.. */ callback(callback_data, entry); - debug(82, 4) ("externalAclLookup: no lookup pending for '%s', and grace not expired\n", key); - debug(82, 4) ("externalAclLookup: (what tha' hell?)\n"); + debugs(82, 4, "externalAclLookup: no lookup pending for '" << key << "', and grace not expired"); + debugs(82, 4, "externalAclLookup: (what tha' hell?)"); return; } @@ -1204,7 +1207,7 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba /* Check for queue overload */ if (def->theHelper->stats.queue_size >= def->theHelper->n_running) { - debug(82, 1) ("externalAclLookup: '%s' queue overload (ch=%p)\n", def->name, ch); + debugs(82, 1, "externalAclLookup: '" << def->name << "' queue overload (ch=" << ch << ")"); cbdataFree(state); callback(callback_data, entry); return; @@ -1215,7 +1218,7 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba buf.Printf("%s\n", key); - debug(82, 4) ("externalAclLookup: looking up for '%s' in '%s'.\n", key, def->name); + debugs(82, 4, "externalAclLookup: looking up for '" << key << "' in '" << def->name << "'."); helperSubmit(def->theHelper, buf.buf, externalAclHandleReply, state); @@ -1226,22 +1229,24 @@ ACLExternal::ExternalAclLookup(ACLChecklist * ch, ACLExternal * me, EAH * callba if (graceful) { /* No need to wait during grace period */ - debug(82, 4) ("externalAclLookup: no need to wait for the result of '%s' in '%s' (ch=%p).\n", - key, def->name, ch); - debug(82, 4) ("externalAclLookup: using cached entry %p\n", entry); + debugs(82, 4, "externalAclLookup: no need to wait for the result of '" << + key << "' in '" << def->name << "' (ch=" << ch << ")."); + debugs(82, 4, "externalAclLookup: using cached entry " << entry); if (entry != NULL) { - debug(82,4) ("externalAclLookup: entry = { date=%lu, result=%d, user=%s tag=%s log=%s }\n", - (long unsigned int) entry->date, entry->result, entry->user.buf(), entry->tag.buf(), - entry->log.buf()); + debugs(82, 4, "externalAclLookup: entry = { date=" << + (long unsigned int) entry->date << ", result=" << + entry->result << ", user=" << entry->user.buf() << " tag=" << + entry->tag.buf() << " log=" << entry->log.buf() << " }"); + } callback(callback_data, entry); return; } - debug(82, 4) ("externalAclLookup: will wait for the result of '%s' in '%s' (ch=%p).\n", - key, def->name, ch); + debugs(82, 4, "externalAclLookup: will wait for the result of '" << key << + "' in '" << def->name << "' (ch=" << ch << ")."); } static void diff --git a/src/fd.cc b/src/fd.cc index 1b0c419a06..466a3ac0cc 100644 --- a/src/fd.cc +++ b/src/fd.cc @@ -1,6 +1,6 @@ /* - * $Id: fd.cc,v 1.56 2007/04/06 15:39:06 serassio Exp $ + * $Id: fd.cc,v 1.57 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 51 Filedescriptor Functions * AUTHOR: Duane Wessels @@ -97,7 +97,7 @@ fd_close(int fd) assert(F->write_handler == NULL); } - debug(51, 3) ("fd_close FD %d %s\n", fd, F->desc); + debugs(51, 3, "fd_close FD " << fd << " " << F->desc); commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0); F->flags.open = 0; @@ -176,12 +176,12 @@ fd_open(int fd, unsigned int type, const char *desc) F = &fd_table[fd]; if (F->flags.open) { - debug(51, 1) ("WARNING: Closing open FD %4d\n", fd); + debugs(51, 1, "WARNING: Closing open FD " << std::setw(4) << fd); fd_close(fd); } assert(!F->flags.open); - debug(51, 3) ("fd_open FD %d %s\n", fd, desc); + debugs(51, 3, "fd_open FD " << fd << " " << desc); F->type = type; F->flags.open = 1; F->epoll_state = 0; @@ -268,11 +268,11 @@ fdDumpOpen(void) if (i == fileno(debug_log)) continue; - debug(51, 1) ("Open FD %-10s %4d %s\n", - F->bytes_read && F->bytes_written ? "READ/WRITE" : - F->bytes_read ? "READING" : - F->bytes_written ? "WRITING" : null_string, - i, F->desc); + debugs(51, 1, "Open FD "<< std::left<< std::setw(10) << + (F->bytes_read && F->bytes_written ? "READ/WRITE" : + F->bytes_read ? "READING" : F->bytes_written ? "WRITING" : + null_string) << + " "<< std::right << std::setw(4) << i << " " << F->desc); } } @@ -322,11 +322,10 @@ fdAdjustReserved(void) if (newReserve > x) { /* perhaps this should be fatal()? -DW */ - debug(51, 0) ("WARNING: This machine has a serious shortage of filedescriptors.\n"); + debugs(51, 0, "WARNING: This machine has a serious shortage of filedescriptors."); newReserve = x; } - debug(51, 0) ("Reserved FD adjusted from %d to %d due to failures\n", - RESERVED_FD, newReserve); + debugs(51, 0, "Reserved FD adjusted from " << RESERVED_FD << " to " << newReserve << " due to failures"); RESERVED_FD = newReserve; } diff --git a/src/filemap.cc b/src/filemap.cc index df35446973..d8c621ca7a 100644 --- a/src/filemap.cc +++ b/src/filemap.cc @@ -1,6 +1,6 @@ /* - * $Id: filemap.cc,v 1.42 2003/02/21 22:50:08 robertc Exp $ + * $Id: filemap.cc,v 1.43 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 8 Swap File Bitmap * AUTHOR: Harvest Derived @@ -61,9 +61,8 @@ file_map_create(void) fileMap *fm = (fileMap *)xcalloc(1, sizeof(fileMap)); fm->max_n_files = FM_INITIAL_NUMBER; fm->nwords = fm->max_n_files >> LONG_BIT_SHIFT; - debug(8, 3) ("file_map_create: creating space for %d files\n", fm->max_n_files); - debug(8, 5) ("--> %d words of %d bytes each\n", - fm->nwords, (int) sizeof(*fm->file_map)); + debugs(8, 3, "file_map_create: creating space for " << fm->max_n_files << " files"); + debugs(8, 5, "--> " << fm->nwords << " words of " << (int) sizeof(*fm->file_map) << " bytes each"); fm->file_map = (unsigned long *)xcalloc(fm->nwords, sizeof(*fm->file_map)); /* XXX account fm->file_map */ return fm; @@ -77,9 +76,9 @@ file_map_grow(fileMap * fm) fm->max_n_files <<= 1; assert(fm->max_n_files <= (1 << 24)); /* swap_filen is 25 bits, signed */ fm->nwords = fm->max_n_files >> LONG_BIT_SHIFT; - debug(8, 3) ("file_map_grow: creating space for %d files\n", fm->max_n_files); + debugs(8, 3, "file_map_grow: creating space for " << fm->max_n_files << " files"); fm->file_map = (unsigned long *)xcalloc(fm->nwords, sizeof(*fm->file_map)); - debug(8, 3) ("copying %d old bytes\n", old_sz); + debugs(8, 3, "copying " << old_sz << " old bytes"); xmemcpy(fm->file_map, old_map, old_sz); xfree(old_map); /* XXX account fm->file_map */ @@ -156,7 +155,7 @@ file_map_allocate(fileMap * fm, int suggestion) } } - debug(8, 3) ("growing from file_map_allocate\n"); + debugs(8, 3, "growing from file_map_allocate"); file_map_grow(fm); return file_map_allocate(fm, fm->max_n_files >> 1); } diff --git a/src/forward.cc b/src/forward.cc index a31de87e5d..f85de0e47e 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.160 2007/04/21 07:14:14 wessels Exp $ + * $Id: forward.cc,v 1.161 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -185,7 +185,7 @@ FwdState::~FwdState() if (fd > -1) { server_fd = -1; comm_remove_close_handler(fd, fwdServerClosedWrapper, this); - debug(17, 3) ("fwdStateFree: closing FD %d\n", fd); + debugs(17, 3, "fwdStateFree: closing FD " << fd); comm_close(fd); } @@ -234,7 +234,7 @@ FwdState::fwdStart(int client_fd, StoreEntry *entry, HttpRequest *request) } } - debug(17, 3) ("FwdState::start() '%s'\n", entry->url()); + debugs(17, 3, "FwdState::start() '" << entry->url() << "'"); /* * This seems like an odd place to bind mem_obj and request. * Might want to assert that request is NULL at this point @@ -286,10 +286,7 @@ FwdState::fwdStart(int client_fd, StoreEntry *entry, HttpRequest *request) void FwdState::fail(ErrorState * errorState) { - debug(17, 3) ("fwdFail: %s \"%s\"\n\t%s\n", - err_type_str[errorState->type], - httpStatusString(errorState->httpStatus), - entry->url()); + debugs(17, 3, "fwdFail: " << err_type_str[errorState->type] << " \"" << httpStatusString(errorState->httpStatus) << "\"\n\t" << entry->url() ); if (err) errorStateFree(err); @@ -306,7 +303,7 @@ FwdState::fail(ErrorState * errorState) void FwdState::unregister(int fd) { - debug(17, 3) ("fwdUnregister: %s\n", entry->url()); + debugs(17, 3, "fwdUnregister: " << entry->url() ); assert(fd == server_fd); assert(fd > -1); comm_remove_close_handler(fd, fwdServerClosedWrapper, this); @@ -324,8 +321,7 @@ FwdState::complete() { StoreEntry *e = entry; assert(entry->store_status == STORE_PENDING); - debug(17, 3) ("fwdComplete: %s\n\tstatus %d\n", e->url(), - entry->getReply()->sline.status); + debugs(17, 3, "fwdComplete: " << e->url() << "\n\tstatus " << entry->getReply()->sline.status ); #if URL_CHECKSUM_DEBUG entry->mem_obj->checkUrlChecksum(); @@ -334,9 +330,7 @@ FwdState::complete() logReplyStatus(n_tries, entry->getReply()->sline.status); if (reforward()) { - debug(17, 3) ("fwdComplete: re-forwarding %d %s\n", - entry->getReply()->sline.status, - e->url()); + debugs(17, 3, "fwdComplete: re-forwarding " << entry->getReply()->sline.status << " " << e->url()); if (server_fd > -1) unregister(server_fd); @@ -345,8 +339,7 @@ FwdState::complete() startComplete(servers); } else { - debug(17, 3) ("fwdComplete: not re-forwarding status %d\n", - entry->getReply()->sline.status); + debugs(17, 3, "fwdComplete: not re-forwarding status " << entry->getReply()->sline.status); EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); entry->complete(); @@ -500,15 +493,13 @@ FwdState::checkRetriable() void FwdState::serverClosed(int fd) { - debug(17, 2) ("fwdServerClosed: FD %d %s\n", fd, entry->url()); + debugs(17, 2, "fwdServerClosed: FD " << fd << " " << entry->url()); assert(server_fd == fd); server_fd = -1; if (checkRetry()) { int originserver = (servers->_peer == NULL); - debug(17, 3) ("fwdServerClosed: re-forwarding (%d tries, %d secs)\n", - n_tries, - (int) (squid_curtime - start_t)); + debugs(17, 3, "fwdServerClosed: re-forwarding (" << n_tries << " tries, " << (int) (squid_curtime - start_t) << " secs)"); if (servers->next) { /* use next, or cycle if origin server isn't last */ @@ -566,7 +557,9 @@ FwdState::negotiateSSL(int fd) return; default: - debug(81, 1) ("fwdNegotiateSSL: Error negotiating SSL connection on FD %d: %s (%d/%d/%d)\n", fd, ERR_error_string(ERR_get_error(), NULL), ssl_error, ret, errno); + debugs(81, 1, "fwdNegotiateSSL: Error negotiating SSL connection on FD " << fd << + ": " << ERR_error_string(ERR_get_error(), NULL) << " (" << ssl_error << + "/" << ret << "/" << errno << ")"); ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request); #ifdef EPROTO @@ -617,8 +610,7 @@ FwdState::initiateSSL() assert(sslContext); if ((ssl = SSL_new(sslContext)) == NULL) { - debug(83, 1) ("fwdInitiateSSL: Error allocating handle: %s\n", - ERR_error_string(ERR_get_error(), NULL)); + debugs(83, 1, "fwdInitiateSSL: Error allocating handle: " << ERR_error_string(ERR_get_error(), NULL) ); ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request); anErr->xerrno = errno; fail(anErr); @@ -676,8 +668,7 @@ FwdState::connectDone(int aServerFD, comm_err_t status, int xerrno) if (NULL == fs->_peer) flags.dont_retry = 1; - debug(17, 4) ("fwdConnectDone: Unknown host: %s\n", - request->host); + debugs(17, 4, "fwdConnectDone: Unknown host: " << request->host); ErrorState *anErr = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, request); @@ -698,7 +689,7 @@ FwdState::connectDone(int aServerFD, comm_err_t status, int xerrno) comm_close(server_fd); } else { - debug(17, 3) ("fwdConnectDone: FD %d: '%s'\n", server_fd, entry->url()); + debugs(17, 3, "fwdConnectDone: FD " << server_fd << ": '" << entry->url() << "'" ); if (fs->_peer) peerConnectSucceded(fs->_peer); @@ -721,7 +712,7 @@ FwdState::connectTimeout(int fd) { FwdServer *fs = servers; - debug(17, 2) ("fwdConnectTimeout: FD %d: '%s'\n", fd, entry->url()); + debugs(17, 2, "fwdConnectTimeout: FD " << fd << ": '" << entry->url() << "'" ); assert(fd == server_fd); if (Config.onoff.log_ip_on_direct && fs->code == HIER_DIRECT && fd_table[fd].ipaddr[0]) @@ -765,7 +756,7 @@ FwdState::connectStart() struct IN_ADDR *client_addr = NULL; assert(fs); assert(server_fd == -1); - debug(17, 3) ("fwdConnectStart: %s\n", url); + debugs(17, 3, "fwdConnectStart: " << url); if (fs->_peer) { host = fs->_peer->host; @@ -795,7 +786,7 @@ FwdState::connectStart() if ((fd = fwdPconnPool->pop(host, port, domain, client_addr)) >= 0) { if (checkRetriable()) { - debug(17, 3) ("fwdConnectStart: reusing pconn FD %d\n", fd); + debugs(17, 3, "fwdConnectStart: reusing pconn FD " << fd); server_fd = fd; n_tries++; @@ -825,8 +816,7 @@ FwdState::connectStart() tos = getOutgoingTOS(request); - debug(17, 3) ("fwdConnectStart: got addr %s, tos %d\n", - inet_ntoa(outgoing), tos); + debugs(17, 3, "fwdConnectStart: got addr " << inet_ntoa(outgoing) << ", tos " << tos); fd = comm_openex(SOCK_STREAM, IPPROTO_TCP, @@ -837,7 +827,7 @@ FwdState::connectStart() url); if (fd < 0) { - debug(50, 4) ("fwdConnectStart: %s\n", xstrerror()); + debugs(50, 4, "fwdConnectStart: " << xstrerror()); ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request); anErr->xerrno = errno; fail(anErr); @@ -882,19 +872,20 @@ FwdState::connectStart() itp.op = TPROXY_ASSIGN; if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp, sizeof(itp)) == -1) { - debug(20, 1) ("tproxy ip=%s,0x%x,port=%d ERROR ASSIGN\n", - inet_ntoa(itp.v.addr.faddr), - itp.v.addr.faddr.s_addr, - itp.v.addr.fport); + debugs(20, 1, "tproxy ip=" << inet_ntoa(itp.v.addr.faddr) << + ",0x" << hex << itp.v.addr.faddr.s_addr << dec << + ",port=" << itp.v.addr.fport << " ERROR ASSIGN"); + request->flags.tproxy = 0; } else { itp.op = TPROXY_FLAGS; itp.v.flags = ITP_CONNECT; if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp, sizeof(itp)) == -1) { - debug(20, 1) ("tproxy ip=%x,port=%d ERROR CONNECT\n", - itp.v.addr.faddr.s_addr, - itp.v.addr.fport); + debugs(20, 1, "tproxy ip=" << hex << + itp.v.addr.faddr.s_addr << dec << ",port=" << + itp.v.addr.fport << " ERROR CONNECT"); + request->flags.tproxy = 0; } } @@ -910,7 +901,7 @@ FwdState::connectStart() void FwdState::startComplete(FwdServer * theServers) { - debug(17, 3) ("fwdStartComplete: %s\n", entry->url()); + debugs(17, 3, "fwdStartComplete: " << entry->url() ); if (theServers != NULL) { servers = theServers; @@ -923,7 +914,7 @@ FwdState::startComplete(FwdServer * theServers) void FwdState::startFail() { - debug(17, 3) ("fwdStartFail: %s\n", entry->url()); + debugs(17, 3, "fwdStartFail: " << entry->url() ); ErrorState *anErr = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request); anErr->xerrno = errno; fail(anErr); @@ -934,10 +925,7 @@ void FwdState::dispatch() { peer *p = NULL; - debug(17, 3) ("fwdDispatch: FD %d: Fetching '%s %s'\n", - client_fd, - RequestMethodStr[request->method], - entry->url()); + debugs(17, 3, "fwdDispatch: FD " << client_fd << ": Fetching '" << RequestMethodStr[request->method] << " " << entry->url() << "'" ); /* * Assert that server_fd is set. This is to guarantee that fwdState * is attached to something and will be deallocated when server_fd @@ -1002,8 +990,7 @@ FwdState::dispatch() case PROTO_WAIS: /* Not implemented */ default: - debug(17, 1) ("fwdDispatch: Cannot retrieve '%s'\n", - entry->url()); + debugs(17, 1, "fwdDispatch: Cannot retrieve '" << entry->url() << "'" ); ErrorState *anErr = errorCon(ERR_UNSUP_REQ, HTTP_BAD_REQUEST, request); fail(anErr); /* @@ -1044,10 +1031,10 @@ FwdState::reforward() e->mem_obj->checkUrlChecksum(); #endif - debug(17, 3) ("fwdReforward: %s?\n", e->url()); + debugs(17, 3, "fwdReforward: " << e->url() << "?" ); if (!EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT)) { - debug(17, 3) ("fwdReforward: No, ENTRY_FWD_HDR_WAIT isn't set\n"); + debugs(17, 3, "fwdReforward: No, ENTRY_FWD_HDR_WAIT isn't set"); return 0; } @@ -1067,12 +1054,12 @@ FwdState::reforward() fwdServerFree(fs); if (servers == NULL) { - debug(17, 3) ("fwdReforward: No forward-servers left\n"); + debugs(17, 3, "fwdReforward: No forward-servers left"); return 0; } s = e->getReply()->sline.status; - debug(17, 3) ("fwdReforward: status %d\n", (int) s); + debugs(17, 3, "fwdReforward: status " << (int) s); return reforwardableStatus(s); } diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 617ddff14a..cdb63fa8e6 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -1,6 +1,6 @@ /* - * $Id: fqdncache.cc,v 1.170 2006/08/21 00:50:41 robertc Exp $ + * $Id: fqdncache.cc,v 1.171 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 35 FQDN Cache * AUTHOR: Harvest Derived @@ -120,8 +120,7 @@ fqdncacheRelease(fqdncache_entry * f) for (k = 0; k < (int) f->name_count; k++) safe_free(f->names[k]); - debug(35, 5) ("fqdncacheRelease: Released FQDN record for '%s'.\n", - hashKeyStr(&f->hash)); + debugs(35, 5, "fqdncacheRelease: Released FQDN record for '" << hashKeyStr(&f->hash) << "'."); dlinkDelete(&f->lru, &lru_list); @@ -187,7 +186,7 @@ fqdncache_purgelru(void *notused) removed++; } - debug(35, 9) ("fqdncache_purgelru: removed %d entries\n", removed); + debugs(35, 9, "fqdncache_purgelru: removed " << removed << " entries"); } static void @@ -279,17 +278,17 @@ fqdncacheParse(fqdncache_entry *f, const char *inbuf) f->flags.negcached = 1; if (inbuf == NULL) { - debug(35, 1) ("fqdncacheParse: Got reply in response to '%s'\n", name); + debugs(35, 1, "fqdncacheParse: Got reply in response to '" << name << "'"); f->error_message = xstrdup("Internal Error"); return -1; } xstrncpy(buf, inbuf, DNS_INBUF_SZ); - debug(35, 5) ("fqdncacheParse: parsing: {%s}\n", buf); + debugs(35, 5, "fqdncacheParse: parsing: {" << buf << "}"); token = strtok(buf, w_space); if (NULL == token) { - debug(35, 1) ("fqdncacheParse: Got , expecting '$name' in response to '%s'\n", name); + debugs(35, 1, "fqdncacheParse: Got , expecting '$name' in response to '" << name << "'"); f->error_message = xstrdup("Internal Error"); return -1; } @@ -302,7 +301,7 @@ fqdncacheParse(fqdncache_entry *f, const char *inbuf) } if (0 != strcmp(token, "$name")) { - debug(35, 1) ("fqdncacheParse: Got '%s', expecting '$name' in response to '%s'\n", inbuf, name); + debugs(35, 1, "fqdncacheParse: Got '" << inbuf << "', expecting '$name' in response to '" << name << "'"); f->error_message = xstrdup("Internal Error"); return -1; } @@ -310,7 +309,7 @@ fqdncacheParse(fqdncache_entry *f, const char *inbuf) token = strtok(NULL, w_space); if (NULL == token) { - debug(35, 1) ("fqdncacheParse: Got '%s', expecting TTL in response to '%s'\n", inbuf, name); + debugs(35, 1, "fqdncacheParse: Got '" << inbuf << "', expecting TTL in response to '" << name << "'"); f->error_message = xstrdup("Internal Error"); return -1; } @@ -320,7 +319,7 @@ fqdncacheParse(fqdncache_entry *f, const char *inbuf) token = strtok(NULL, w_space); if (NULL == token) { - debug(35, 1) ("fqdncacheParse: Got '%s', expecting hostname in response to '%s'\n", inbuf, name); + debugs(35, 1, "fqdncacheParse: Got '" << inbuf << "', expecting hostname in response to '" << name << "'"); f->error_message = xstrdup("Internal Error"); return -1; } @@ -352,18 +351,18 @@ fqdncacheParse(fqdncache_entry *f, rfc1035_rr * answers, int nr, const char *err f->flags.negcached = 1; if (nr < 0) { - debug(35, 3) ("fqdncacheParse: Lookup of '%s' failed (%s)\n", name, error_message); + debugs(35, 3, "fqdncacheParse: Lookup of '" << name << "' failed (" << error_message << ")"); f->error_message = xstrdup(error_message); return -1; } if (nr == 0) { - debug(35, 3) ("fqdncacheParse: No DNS records for '%s'\n", name); + debugs(35, 3, "fqdncacheParse: No DNS records for '" << name << "'"); f->error_message = xstrdup("No DNS records"); return 0; } - debug(35, 3) ("fqdncacheParse: %d answers for '%s'\n", nr, name); + debugs(35, 3, "fqdncacheParse: " << nr << " answers for '" << name << "'"); assert(answers); for (k = 0; k < nr; k++) { @@ -372,12 +371,12 @@ fqdncacheParse(fqdncache_entry *f, rfc1035_rr * answers, int nr, const char *err if (answers[k].type == RFC1035_TYPE_PTR) { if (!answers[k].rdata[0]) { - debug(35, 2) ("fqdncacheParse: blank PTR record for '%s'\n", name); + debugs(35, 2, "fqdncacheParse: blank PTR record for '" << name << "'"); continue; } if (strchr(answers[k].rdata, ' ')) { - debug(35, 2) ("fqdncacheParse: invalid PTR record '%s' for '%s'\n", answers[k].rdata, name); + debugs(35, 2, "fqdncacheParse: invalid PTR record '" << answers[k].rdata << "' for '" << name << "'"); continue; } @@ -393,7 +392,7 @@ fqdncacheParse(fqdncache_entry *f, rfc1035_rr * answers, int nr, const char *err } if (f->name_count == 0) { - debug(35, 1) ("fqdncacheParse: No PTR record for '%s'\n", name); + debugs(35, 1, "fqdncacheParse: No PTR record for '" << name << "'"); return 0; } @@ -448,12 +447,12 @@ fqdncache_nbgethostbyaddr(struct IN_ADDR addr, FQDNH * handler, void *handlerDat char *name = inet_ntoa(addr); generic_cbdata *c; assert(handler); - debug(35, 4) ("fqdncache_nbgethostbyaddr: Name '%s'.\n", name); + debugs(35, 4, "fqdncache_nbgethostbyaddr: Name '" << name << "'."); FqdncacheStats.requests++; if (name == NULL || name[0] == '\0') { - debug(35, 4) ("fqdncache_nbgethostbyaddr: Invalid name!\n"); + debugs(35, 4, "fqdncache_nbgethostbyaddr: Invalid name!"); dns_error_message = "Invalid hostname"; handler(NULL, handlerData); return; @@ -473,7 +472,7 @@ fqdncache_nbgethostbyaddr(struct IN_ADDR addr, FQDNH * handler, void *handlerDat } else { /* hit */ - debug(35, 4) ("fqdncache_nbgethostbyaddr: HIT for '%s'\n", name); + debugs(35, 4, "fqdncache_nbgethostbyaddr: HIT for '" << name << "'"); if (f->flags.negcached) FqdncacheStats.negative_hits++; @@ -489,7 +488,7 @@ fqdncache_nbgethostbyaddr(struct IN_ADDR addr, FQDNH * handler, void *handlerDat return; } - debug(35, 5) ("fqdncache_nbgethostbyaddr: MISS for '%s'\n", name); + debugs(35, 5, "fqdncache_nbgethostbyaddr: MISS for '" << name << "'"); FqdncacheStats.misses++; f = fqdncacheCreateEntry(name); f->handler = handler; @@ -514,7 +513,7 @@ fqdncache_init(void) if (fqdn_table) return; - debug(35, 3) ("Initializing FQDN Cache...\n"); + debugs(35, 3, "Initializing FQDN Cache..."); memset(&FqdncacheStats, '\0', sizeof(FqdncacheStats)); @@ -731,7 +730,7 @@ fqdncacheAddEntryFromHosts(char *addr, wordlist * hostnames) if (1 == fce->flags.fromhosts) { fqdncacheUnlockEntry(fce); } else if (fce->locks > 0) { - debug(35, 1) ("fqdncacheAddEntryFromHosts: can't add static entry for locked address '%s'\n", addr); + debugs(35, 1, "fqdncacheAddEntryFromHosts: can't add static entry for locked address '" << addr << "'"); return; } else { fqdncacheRelease(fce); @@ -766,7 +765,7 @@ variable_list * snmp_netFqdnFn(variable_list * Var, snint * ErrP) { variable_list *Answer = NULL; - debug(49, 5) ("snmp_netFqdnFn: Processing request:\n"); + debugs(49, 5, "snmp_netFqdnFn: Processing request:"); snmpDebugOid(5, Var->name, Var->name_length); *ErrP = SNMP_ERR_NOERROR; diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 5a8453aa7c..be33a07bd4 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.71 2007/04/21 13:21:58 wessels Exp $ + * $Id: store_dir_coss.cc,v 1.72 2007/04/28 22:26:50 hno Exp $ * vim: set et : * * DEBUG: section 47 Store COSS Directory Routines @@ -140,11 +140,11 @@ CossSwapDir::openLog() swaplog_fd = file_open(logPath, O_WRONLY | O_CREAT | O_BINARY); if (swaplog_fd < 0) { - debug(47, 1) ("%s: %s\n", logPath, xstrerror()); + debugs(47, 1, "" << logPath << ": " << xstrerror()); fatal("storeCossDirOpenSwapLog: Failed to open swap log."); } - debug(47, 3) ("Cache COSS Dir #%d log opened on FD %d\n", index, swaplog_fd); + debugs(47, 3, "Cache COSS Dir #" << index << " log opened on FD " << swaplog_fd); } void @@ -155,8 +155,7 @@ CossSwapDir::closeLog() file_close(swaplog_fd); - debug(47, 3) ("Cache COSS Dir #%d log closed on FD %d\n", - index, swaplog_fd); + debugs(47, 3, "Cache COSS Dir #" << index << " log closed on FD " << swaplog_fd); swaplog_fd = -1; } @@ -165,7 +164,7 @@ void CossSwapDir::ioCompletedNotification() { if (theFile->error()) { - debug(47, 1) ("%s: %s\n", path, xstrerror()); + debugs(47, 1, "" << path << ": " << xstrerror()); fatal("storeCossDirInit: Failed to open a COSS file."); } } @@ -188,8 +187,7 @@ CossSwapDir::readCompleted(const char *buf, int len, int errflag, RefCount(sio.getRaw()); ssize_t rlen; - debug(79, 3) ("storeCossReadDone: fileno %d, len %d\n", - sio->swap_filen, len); + debugs(79, 3, "storeCossReadDone: fileno " << sio->swap_filen << ", len " << len); cstate->flags.reading = 0; if (errflag) { @@ -197,9 +195,9 @@ CossSwapDir::readCompleted(const char *buf, int len, int errflag, RefCount 0) { errno = errflag; - debug(79, 1) ("storeCossReadDone: error: %s\n", xstrerror()); + debugs(79, 1, "storeCossReadDone: error: " << xstrerror()); } else { - debug(79, 1) ("storeCossReadDone: got failure (%d)\n", errflag); + debugs(79, 1, "storeCossReadDone: got failure (" << errflag << ")"); } rlen = -1; @@ -232,12 +230,12 @@ CossSwapDir::writeCompleted(int errflag, size_t len, RefCount writ CossWrite* cossWrite= dynamic_cast(writeRequest.getRaw()); assert (cossWrite); - debug(79, 3) ("storeCossWriteMemBufDone: buf %p, len %ld\n", cossWrite->membuf, (long int) len); + debugs(79, 3, "storeCossWriteMemBufDone: buf " << cossWrite->membuf << ", len " << (long int) len); if (errflag) { StoreFScoss::GetInstance().stats.stripe_write.fail++; - debug(79, 1) ("storeCossWriteMemBufDone: got failure (%d)\n", errflag); + debugs(79, 1, "storeCossWriteMemBufDone: got failure (" << errflag << ")"); debugs(79, 1, "size=" << cossWrite->membuf->diskend - cossWrite->membuf->diskstart); } else { StoreFScoss::GetInstance().stats.stripe_write.success++; @@ -406,8 +404,7 @@ storeCossRebuildFromSwapLog(void *data) for (int aCount = 0; aCount < rb->speed; aCount++) { if (fread(&s, ss, 1, rb->log) != 1) { - debug(47, 1) ("Done reading %s swaplog (%d entries)\n", - rb->sd->path, rb->n_read); + debugs(47, 1, "Done reading " << rb->sd->path << " swaplog (" << rb->n_read << " entries)"); fclose(rb->log); rb->log = NULL; storeCossRebuildComplete(rb); @@ -422,10 +419,10 @@ storeCossRebuildFromSwapLog(void *data) if (s.op >= SWAP_LOG_MAX) continue; - debug(47, 3) ("storeCossRebuildFromSwapLog: %s %s %08X\n", - swap_log_op_str[(int) s.op], - storeKeyText(s.key), - s.swap_filen); + debugs(47, 3, "storeCossRebuildFromSwapLog: " << + swap_log_op_str[(int) s.op] << " " << storeKeyText(s.key) << + " "<< std::setfill('0') << std::hex << std::uppercase << + std::setw(8) << s.swap_filen); if (s.op == SWAP_LOG_ADD) { (void) 0; @@ -461,8 +458,7 @@ storeCossRebuildFromSwapLog(void *data) if (0.0 == x - (double) (int) x) - debug(47, 1) ("WARNING: %d invalid swap log entries found\n", - rb->counts.bad_log_op); + debugs(47, 1, "WARNING: " << rb->counts.bad_log_op << " invalid swap log entries found"); rb->counts.invalid++; @@ -528,7 +524,10 @@ storeCossAddDiskRestore(CossSwapDir * SD, const cache_key * key, int clean) { StoreEntry *e = NULL; - debug(47, 5) ("storeCossAddDiskRestore: %s, fileno=%08X\n", storeKeyText(key), file_number); + debugs(47, 5, "storeCossAddDiskRestore: " << storeKeyText(key) << + ", fileno="<< std::setfill('0') << std::hex << std::uppercase << + std::setw(8) << file_number); + /* if you call this you'd better be sure file_number is not * already in use! */ e = new StoreEntry(); @@ -574,8 +573,7 @@ storeCossDirRebuild(CossSwapDir * sd) * we'll use storeCossRebuildFromSwapLog(). */ fp = storeCossDirOpenTmpSwapLog(sd, &clean, &zero); - debug(47, 1) ("Rebuilding COSS storage in %s (%s)\n", - sd->path, clean ? "CLEAN" : "DIRTY"); + debugs(47, 1, "Rebuilding COSS storage in " << sd->path << " (" << (clean ? "CLEAN" : "DIRTY") << ")"); rb->log = fp; StoreController::store_dirs_rebuilding++; @@ -618,14 +616,14 @@ storeCossDirCloseTmpSwapLog(CossSwapDir * sd) anfd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY); if (anfd < 0) { - debug(50, 1) ("%s: %s\n", swaplog_path, xstrerror()); + debugs(50, 1, "" << swaplog_path << ": " << xstrerror()); fatal("storeCossDirCloseTmpSwapLog: Failed to open swap log."); } safe_free(swaplog_path); safe_free(new_path); sd->swaplog_fd = anfd; - debug(47, 3) ("Cache COSS Dir #%d log opened on FD %d\n", sd->index, anfd); + debugs(47, 3, "Cache COSS Dir #" << sd->index << " log opened on FD " << anfd); } static FILE * @@ -642,7 +640,7 @@ storeCossDirOpenTmpSwapLog(CossSwapDir * sd, int *clean_flag, int *zero_flag) int anfd; if (::stat(swaplog_path, &log_sb) < 0) { - debug(50, 1) ("Cache COSS Dir #%d: No log file\n", sd->index); + debugs(50, 1, "Cache COSS Dir #" << sd->index << ": No log file"); safe_free(swaplog_path); safe_free(clean_path); safe_free(new_path); @@ -659,7 +657,7 @@ storeCossDirOpenTmpSwapLog(CossSwapDir * sd, int *clean_flag, int *zero_flag) anfd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); if (anfd < 0) { - debug(50, 1) ("%s: %s\n", new_path, xstrerror()); + debugs(50, 1, "" << new_path << ": " << xstrerror()); fatal("storeDirOpenTmpSwapLog: Failed to open swap log."); } @@ -668,7 +666,7 @@ storeCossDirOpenTmpSwapLog(CossSwapDir * sd, int *clean_flag, int *zero_flag) fp = fopen(swaplog_path, "rb"); if (fp == NULL) { - debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); + debugs(50, 0, "" << swaplog_path << ": " << xstrerror()); fatal("Failed to open swap log for reading"); } @@ -745,8 +743,7 @@ CossSwapDir::writeCleanStart() state->outbuf_offset = 0; ::unlink(state->cln); state->current = cossindex.tail; - debug(50, 3) ("storeCOssDirWriteCleanLogs: opened %s, FD %d\n", - state->newLog, state->fd); + debugs(50, 3, "storeCOssDirWriteCleanLogs: opened " << state->newLog << ", FD " << state->fd); #if HAVE_FCHMOD if (::stat(state->cur, &sb) == 0) @@ -803,9 +800,8 @@ CossCleanLog::write(StoreEntry const &e) if (outbuf_offset + ss > CLEAN_BUF_SZ) { if (FD_WRITE_METHOD(fd, outbuf, outbuf_offset) < 0) { - debug(50, 0) ("storeCossDirWriteCleanLogs: %s: write: %s\n", - newLog, xstrerror()); - debug(50, 0) ("storeCossDirWriteCleanLogs: Current swap logfile not replaced.\n"); + debugs(50, 0, "storeCossDirWriteCleanLogs: " << newLog << ": write: " << xstrerror()); + debugs(50, 0, "storeCossDirWriteCleanLogs: Current swap logfile not replaced."); file_close(fd); fd = -1; unlink(newLog); @@ -830,10 +826,8 @@ CossSwapDir::writeCleanDone() return; if (FD_WRITE_METHOD(state->fd, state->outbuf, state->outbuf_offset) < 0) { - debug(50, 0) ("storeCossDirWriteCleanLogs: %s: write: %s\n", - state->newLog, xstrerror()); - debug(50, 0) ("storeCossDirWriteCleanLogs: Current swap logfile " - "not replaced.\n"); + debugs(50, 0, "storeCossDirWriteCleanLogs: " << state->newLog << ": write: " << xstrerror()); + debugs(50, 0, "storeCossDirWriteCleanLogs: Current swap logfile not replaced."); file_close(state->fd); state->fd = -1; ::unlink(state->newLog); @@ -1075,9 +1069,9 @@ CossSwapDir::parse(int anIndex, char *aPath) max_offset = (unsigned long) 0xFFFFFF << blksz_bits; if ((unsigned long)max_size > (unsigned long)(max_offset>>10)) { - debug(47,0)("COSS block-size = %d bytes\n", 1<diskend = current_offset; current_membuf->maybeWrite(this); current_offset = 0; /* wrap back to beginning */ - debug(79, 2) ("CossSwapDir::allocate: wrap to 0\n"); + debugs(79, 2, "CossSwapDir::allocate: wrap to 0"); newmb = createMemBuf(0, checkf, &coll); current_membuf = newmb; @@ -108,8 +108,7 @@ CossSwapDir::allocate(const StoreEntry * e, int which) current_membuf->flags.full = 1; current_offset = current_membuf->diskend; current_membuf->maybeWrite(this); - debug(79, 2) ("CossSwapDir::allocate: New offset - %ld\n", - (long int) current_offset); + debugs(79, 2, "CossSwapDir::allocate: New offset - " << (long int) current_offset); newmb = createMemBuf(current_offset, checkf, &coll); current_membuf = newmb; } @@ -126,7 +125,7 @@ CossSwapDir::allocate(const StoreEntry * e, int which) return storeCossDiskOffsetToFileno(retofs); } else { StoreFScoss::GetInstance().stats.alloc.collisions++; - debug(79, 3) ("CossSwapDir::allocate: Collision\n"); + debugs(79, 3, "CossSwapDir::allocate: Collision"); return -1; } } @@ -134,7 +133,7 @@ CossSwapDir::allocate(const StoreEntry * e, int which) void CossSwapDir::unlink(StoreEntry & e) { - debug(79, 3) ("storeCossUnlink: offset %d\n", e.swap_filen); + debugs(79, 3, "storeCossUnlink: offset " << e.swap_filen); StoreFScoss::GetInstance().stats.unlink.ops++; StoreFScoss::GetInstance().stats.unlink.success++; storeCossRemove(this, &e); @@ -163,10 +162,11 @@ CossSwapDir::createStoreIO(StoreEntry &e, StoreIOState::STFNCB * file_callback, cstate->st_size = e.objectLen() + e.mem_obj->swap_hdr_sz; sio->swap_dirn = index; sio->swap_filen = allocate(&e, COSS_ALLOC_ALLOCATE); - debug(79, 3) ("storeCossCreate: offset %ld, size %ld, end %ld\n", - (long int) storeCossFilenoToDiskOffset(sio->swap_filen), - (long int) cstate->st_size, - (long int) (sio->swap_filen + cstate->st_size)); + debugs(79, 3, "storeCossCreate: offset " << + (long int) storeCossFilenoToDiskOffset(sio->swap_filen) << + ", size " << (long int) cstate->st_size << ", end " << + (long int) (sio->swap_filen + cstate->st_size)); + /* assume allocate() always succeeds */ assert(-1 != sio->swap_filen); @@ -196,7 +196,7 @@ CossSwapDir::openStoreIO(StoreEntry & e, StoreIOState::STFNCB * file_callback, CossState *cstate; sfileno f = e.swap_filen; - debug(79, 3) ("storeCossOpen: offset %d\n", f); + debugs(79, 3, "storeCossOpen: offset " << f); StoreFScoss::GetInstance().stats.open.ops++; StoreIOState::Pointer sio = new CossState (this); @@ -243,7 +243,7 @@ CossSwapDir::openStoreIO(StoreEntry & e, StoreIOState::STFNCB * file_callback, /* We have to clean up neatly .. */ StoreFScoss::GetInstance().stats.open.fail++; numcollisions++; - debug(79, 2) ("storeCossOpen: Reallocation of %d/%d failed\n", e.swap_dirn, e.swap_filen); + debugs(79, 2, "storeCossOpen: Reallocation of " << e.swap_dirn << "/" << e.swap_filen << " failed"); /* XXX XXX XXX Will squid call storeUnlink for this object? */ return NULL; } @@ -278,7 +278,7 @@ CossSwapDir::openStoreIO(StoreEntry & e, StoreIOState::STFNCB * file_callback, void CossState::close() { - debug(79, 3) ("storeCossClose: offset %d\n", swap_filen); + debugs(79, 3, "storeCossClose: offset " << swap_filen); StoreFScoss::GetInstance().stats.close.ops++; StoreFScoss::GetInstance().stats.close.success++; @@ -297,7 +297,7 @@ CossState::read_(char *buf, size_t size, off_t offset, STRCB * callback, void *c assert(read.callback_data == NULL); read.callback = callback; read.callback_data = cbdataReference(callback_data); - debug(79, 3) ("storeCossRead: offset %ld\n", (long int) offset); + debugs(79, 3, "storeCossRead: offset " << (long int) offset); offset_ = offset; flags.reading = 1; @@ -339,7 +339,7 @@ CossState::write(char const *buf, size_t size, off_t offset, FREE * free_func) assert(e->mem_obj->object_sz != -1); StoreFScoss::GetInstance().stats.write.ops++; - debug(79, 3) ("storeCossWrite: offset %ld, len %lu\n", (long int) offset_, (unsigned long int) size); + debugs(79, 3, "storeCossWrite: offset " << (long int) offset_ << ", len " << (unsigned long int) size); diskoffset = SD->storeCossFilenoToDiskOffset(swap_filen) + offset_; CossSwapDir *SD = (CossSwapDir *)INDEXSD(swap_dirn); dest = SD->storeCossMemPointerFromDiskOffset(diskoffset, &membuf); @@ -421,7 +421,7 @@ CossState::doCallback(int errflag) { STIOCB *callback = this->callback; void *cbdata; - debug(79, 3) ("CossState::doCallback: errflag=%d\n", errflag); + debugs(79, 3, "CossState::doCallback: errflag=" << errflag); assert(NULL == locked_membuf); xfree(readbuffer); this->callback = NULL; @@ -457,7 +457,7 @@ void CossState::lockMemBuf() { CossMemBuf *t = SD->storeCossFilenoToMembuf(swap_filen); - debug(79, 3) ("CossState::lockMemBuf: locking %p, lockcount %d\n", t, t->lockcount); + debugs(79, 3, "CossState::lockMemBuf: locking " << t << ", lockcount " << t->lockcount); locked_membuf = t; ++t->lockcount; } @@ -471,7 +471,7 @@ CossSwapDir::storeCossMemBufUnlock(StoreIOState::Pointer sio) if (NULL == t) return; - debug(79, 3) ("storeCossMemBufUnlock: unlocking %p, lockcount %d\n", t, t->lockcount); + debugs(79, 3, "storeCossMemBufUnlock: unlocking " << t << ", lockcount " << t->lockcount); t->lockcount--; @@ -499,7 +499,7 @@ CossSwapDir::sync() t = (CossMemBuf *)m->data; if (t->flags.writing) { - debug(79, 1) ("WARNING: sleeping for 5 seconds in storeCossSync()\n"); + debugs(79, 1, "WARNING: sleeping for 5 seconds in storeCossSync()"); sleep(5); /* XXX EEEWWW! */ } @@ -519,11 +519,11 @@ CossMemBuf::maybeWrite(CossSwapDir * SD) describe(3, __LINE__); if (!flags.full) - debug(79, 3) ("membuf %p not full\n", this); + debugs(79, 3, "membuf " << this << " not full"); else if (flags.writing) - debug(79, 3) ("membuf %p writing\n", this); + debugs(79, 3, "membuf " << this << " writing"); else if (lockcount) - debug(79, 3) ("membuf %p lockcount=%d\n", this, lockcount); + debugs(79, 3, "membuf " << this << " lockcount=" << lockcount); else write(SD); } @@ -532,8 +532,7 @@ void CossMemBuf::write(CossSwapDir * SD) { StoreFScoss::GetInstance().stats.stripe_write.ops++; - debug(79, 3) ("CossMemBuf::write: offset %ld, len %ld\n", - (long int) diskstart, (long int) (diskend - diskstart)); + debugs(79, 3, "CossMemBuf::write: offset " << (long int) diskstart << ", len " << (long int) (diskend - diskstart)); flags.writing = 1; /* XXX Remember that diskstart/diskend are block offsets! */ SD->theFile->write(new CossWrite(WriteRequest((char const *)&buffer, diskstart, diskend - diskstart, NULL), this)); @@ -551,8 +550,8 @@ CossSwapDir::createMemBuf(size_t start, sfileno curfn, int *collision) CBDATA_INIT_TYPE_FREECB(CossMemBuf, NULL); newmb = cbdataAlloc(CossMemBuf); newmb->diskstart = start; - debug(79, 3) ("CossSwapDir::createMemBuf: creating new membuf at %ld\n", (long int) newmb->diskstart); - debug(79, 3) ("CossSwapDir::createMemBuf: at %p\n", newmb); + debugs(79, 3, "CossSwapDir::createMemBuf: creating new membuf at " << (long int) newmb->diskstart); + debugs(79, 3, "CossSwapDir::createMemBuf: at " << newmb); newmb->diskend = newmb->diskstart + COSS_MEMBUF_SZ; newmb->flags.full = 0; newmb->flags.writing = 0; @@ -563,7 +562,7 @@ CossSwapDir::createMemBuf(size_t start, sfileno curfn, int *collision) /* Print out the list of membufs */ - debug(79, 3) ("CossSwapDir::createMemBuf: membuflist:\n"); + debugs(79, 3, "CossSwapDir::createMemBuf: membuflist:"); for (m = membufs.head; m; m = m->next) { t = (CossMemBuf *)m->data; @@ -590,7 +589,7 @@ CossSwapDir::createMemBuf(size_t start, sfileno curfn, int *collision) } if (numreleased > 0) - debug(79, 3) ("CossSwapDir::createMemBuf: this allocation released %d storeEntries\n", numreleased); + debugs(79, 3, "CossSwapDir::createMemBuf: this allocation released " << numreleased << " storeEntries"); StoreFScoss::GetInstance().stats.stripes++; @@ -618,11 +617,9 @@ CossState::~CossState() void CossMemBuf::describe(int level, int line) { - debug(79, level) ("membuf %p, LC:%02d, ST:%010lu, FL:%c%c\n", - this, - lockcount, - (unsigned long) diskstart, - flags.full ? 'F' : '.', - flags.writing ? 'W' : '.'); + debugs(79, level, "membuf " << this << ", LC:" << std::setfill('0') << + std::setw(2) << lockcount << ", ST:" << + std::setw(10) << (unsigned long) diskstart << ", FL:" << + (flags.full ? 'F' : '.') << (flags.writing ? 'W' : '.')); } diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 3ff0e214ff..9691bed309 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.80 2007/04/21 07:14:16 wessels Exp $ + * $Id: store_dir_ufs.cc,v 1.81 2007/04/28 22:26:51 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -82,11 +82,9 @@ UFSSwapDir::parseSizeL1L2() /* just reconfigure it */ if (reconfiguring) { if (size == max_size) - debug(3, 2) ("Cache dir '%s' size remains unchanged at %d KB\n", - path, size); + debugs(3, 2, "Cache dir '" << path << "' size remains unchanged at " << size << " KB"); else - debug(3, 1) ("Cache dir '%s' size changed to %d KB\n", - path, size); + debugs(3, 1, "Cache dir '" << path << "' size changed to " << size << " KB"); } max_size = size; @@ -273,9 +271,8 @@ UFSSwapDir::~UFSSwapDir() void UFSSwapDir::dumpEntry(StoreEntry &e) const { - debug(47, 0) ("UFSSwapDir::dumpEntry: FILENO %08X\n", e.swap_filen); - debug(47, 0) ("UFSSwapDir::dumpEntry: PATH %s\n", - fullPath(e.swap_filen, NULL)); + debugs(47, 0, "UFSSwapDir::dumpEntry: FILENO "<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << e.swap_filen); + debugs(47, 0, "UFSSwapDir::dumpEntry: PATH " << fullPath(e.swap_filen, NULL) ); e.dump(0); } @@ -291,15 +288,14 @@ UFSSwapDir::doubleCheck(StoreEntry & e) struct stat sb; if (::stat(fullPath(e.swap_filen, NULL), &sb) < 0) { - debug(47, 0) ("UFSSwapDir::doubleCheck: MISSING SWAP FILE\n"); + debugs(47, 0, "UFSSwapDir::doubleCheck: MISSING SWAP FILE"); dumpEntry(e); return true; } if ((off_t)e.swap_file_sz != sb.st_size) { - debug(47, 0) ("UFSSwapDir::doubleCheck: SIZE MISMATCH\n"); - debug(47, 0) ("UFSSwapDir::doubleCheck: ENTRY SIZE: %ld, FILE SIZE: %ld\n", - (long int) e.swap_file_sz, (long int) sb.st_size); + debugs(47, 0, "UFSSwapDir::doubleCheck: SIZE MISMATCH"); + debugs(47, 0, "UFSSwapDir::doubleCheck: ENTRY SIZE: " << (long int) e.swap_file_sz << ", FILE SIZE: " << (long int) sb.st_size); dumpEntry(e); return true; } @@ -378,8 +374,7 @@ UFSSwapDir::maintain() * This is kinda cheap, but so we need this priority hack? */ - debug(47, 3) ("storeMaintainSwapSpace: f=%f, max_scan=%d, max_remove=%d\n", - f, max_scan, max_remove); + debugs(47, 3, "storeMaintainSwapSpace: f=" << f << ", max_scan=" << max_scan << ", max_remove=" << max_remove ); walker = repl->PurgeInit(repl, max_scan); @@ -401,8 +396,9 @@ UFSSwapDir::maintain() } walker->Done(walker); - debug(47, (removed ? 2 : 3)) ("UFSSwapDir::maintain: %s removed %d/%d f=%.03f max_scan=%d\n", - path, removed, max_remove, f, max_scan); + debugs(47, (removed ? 2 : 3), "UFSSwapDir::maintain: " << path << + " removed " << removed << "/" << max_remove << " f=" << + std::setprecision(4) << f << " max_scan=" << max_scan); } /* @@ -414,8 +410,7 @@ UFSSwapDir::maintain() void UFSSwapDir::reference(StoreEntry &e) { - debug(47, 3) ("UFSSwapDir::reference: referencing %p %d/%d\n", &e, e.swap_dirn, - e.swap_filen); + debugs(47, 3, "UFSSwapDir::reference: referencing " << &e << " " << e.swap_dirn << "/" << e.swap_filen); if (repl->Referenced) repl->Referenced(repl, &e, &e.repl); @@ -429,8 +424,7 @@ UFSSwapDir::reference(StoreEntry &e) void UFSSwapDir::dereference(StoreEntry & e) { - debug(47, 3) ("UFSSwapDir::dereference: referencing %p %d/%d\n", &e, e.swap_dirn, - e.swap_filen); + debugs(47, 3, "UFSSwapDir::dereference: referencing " << &e << " " << e.swap_dirn << "/" << e.swap_filen); if (repl->Dereferenced) repl->Dereferenced(repl, &e, &e.repl); @@ -504,7 +498,7 @@ UFSSwapDir::createDirectory(const char *path, int should_exist) if (0 == ::stat(path, &st)) { if (S_ISDIR(st.st_mode)) { - debug(47, should_exist ? 3 : 1) ("%s exists\n", path); + debugs(47, should_exist ? 3 : 1, path << " exists"); } else { fatalf("Swap directory %s is not a directory.", path); } @@ -516,7 +510,7 @@ UFSSwapDir::createDirectory(const char *path, int should_exist) } else if (0 == mkdir(path, 0755)) { #endif - debug(47, should_exist ? 1 : 3) ("%s created\n", path); + debugs(47, should_exist ? 1 : 3, path << " created"); created = 1; } else { fatalf("Failed to make swap directory %s: %s", @@ -533,12 +527,12 @@ UFSSwapDir::pathIsDirectory(const char *path)const struct stat sb; if (::stat(path, &sb) < 0) { - debug(47, 0) ("%s: %s\n", path, xstrerror()); + debugs(47, 0, "" << path << ": " << xstrerror()); return false; } if (S_ISDIR(sb.st_mode) == 0) { - debug(47, 0) ("%s is not a directory\n", path); + debugs(47, 0, "" << path << " is not a directory"); return false; } @@ -581,7 +575,7 @@ UFSSwapDir::createSwapSubDirs() else should_exist = 1; - debug(47, 1) ("Making directories in %s\n", name); + debugs(47, 1, "Making directories in " << name); for (int k = 0; k < l2; k++) { snprintf(name, MAXPATHLEN, "%s/%02X/%02X", path, i, k); @@ -637,11 +631,11 @@ UFSSwapDir::openLog() swaplog_fd = file_open(logPath, O_WRONLY | O_CREAT | O_BINARY); if (swaplog_fd < 0) { - debug(50, 1) ("%s: %s\n", logPath, xstrerror()); + debugs(50, 1, "" << logPath << ": " << xstrerror()); fatal("commonUfsDirOpenSwapLog: Failed to open swap log."); } - debug(50, 3) ("Cache Dir #%d log opened on FD %d\n", index, swaplog_fd); + debugs(50, 3, "Cache Dir #" << index << " log opened on FD " << swaplog_fd); if (0 == NumberOfUFSDirs) assert(NULL == UFSDirToGlobalDirMapping); @@ -659,8 +653,7 @@ UFSSwapDir::closeLog() file_close(swaplog_fd); - debug(47, 3) ("Cache Dir #%d log closed on FD %d\n", - index, swaplog_fd); + debugs(47, 3, "Cache Dir #" << index << " log closed on FD " << swaplog_fd); swaplog_fd = -1; @@ -699,7 +692,8 @@ UFSSwapDir::addDiskRestore(const cache_key * key, int clean) { StoreEntry *e = NULL; - debug(47, 5) ("commonUfsAddDiskRestore: %s, fileno=%08X\n", storeKeyText(key), file_number); + debugs(47, 5, "commonUfsAddDiskRestore: " << storeKeyText(key) << + ", fileno="<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << file_number); /* if you call this you'd better be sure file_number is not * already in use! */ e = new StoreEntry(); @@ -749,14 +743,14 @@ UFSSwapDir::closeTmpSwapLog() fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY); if (fd < 0) { - debug(50, 1) ("%s: %s\n", swaplog_path, xstrerror()); + debugs(50, 1, "" << swaplog_path << ": " << xstrerror()); fatal("commonUfsDirCloseTmpSwapLog: Failed to open swap log."); } safe_free(swaplog_path); safe_free(new_path); swaplog_fd = fd; - debug(47, 3) ("Cache Dir #%d log opened on FD %d\n", index, fd); + debugs(47, 3, "Cache Dir #" << index << " log opened on FD " << fd); } FILE * @@ -773,7 +767,7 @@ UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag) int fd; if (::stat(swaplog_path, &log_sb) < 0) { - debug(47, 1) ("Cache Dir #%d: No log file\n", index); + debugs(47, 1, "Cache Dir #" << index << ": No log file"); safe_free(swaplog_path); safe_free(clean_path); safe_free(new_path); @@ -790,7 +784,7 @@ UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag) fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); if (fd < 0) { - debug(50, 1) ("%s: %s\n", new_path, xstrerror()); + debugs(50, 1, "" << new_path << ": " << xstrerror()); fatal("storeDirOpenTmpSwapLog: Failed to open swap log."); } @@ -799,7 +793,7 @@ UFSSwapDir::openTmpSwapLog(int *clean_flag, int *zero_flag) fp = fopen(swaplog_path, "rb"); if (fp == NULL) { - debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror()); + debugs(50, 0, "" << swaplog_path << ": " << xstrerror()); fatal("Failed to open swap log for reading"); } @@ -877,8 +871,7 @@ UFSSwapDir::writeCleanStart() state->outbuf_offset = 0; state->walker = repl->WalkInit(repl); ::unlink(state->cln); - debug(47, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n", - state->newLog, state->fd); + debugs(47, 3, "storeDirWriteCleanLogs: opened " << state->newLog << ", FD " << state->fd); #if HAVE_FCHMOD if (::stat(state->cur, &sb) == 0) @@ -930,9 +923,8 @@ UFSCleanLog::write(StoreEntry const &e) if (outbuf_offset + ss >= CLEAN_BUF_SZ) { if (FD_WRITE_METHOD(fd, outbuf, outbuf_offset) < 0) { /* XXX This error handling should probably move up to the caller */ - debug(50, 0) ("storeDirWriteCleanLogs: %s: write: %s\n", - newLog, xstrerror()); - debug(50, 0) ("storeDirWriteCleanLogs: Current swap logfile not replaced.\n"); + debugs(50, 0, "storeDirWriteCleanLogs: " << newLog << ": write: " << xstrerror()); + debugs(50, 0, "storeDirWriteCleanLogs: Current swap logfile not replaced."); file_close(fd); fd = -1; unlink(newLog); @@ -960,10 +952,8 @@ UFSSwapDir::writeCleanDone() state->walker->Done(state->walker); if (FD_WRITE_METHOD(state->fd, state->outbuf, state->outbuf_offset) < 0) { - debug(50, 0) ("storeDirWriteCleanLogs: %s: write: %s\n", - state->newLog, xstrerror()); - debug(50, 0) ("storeDirWriteCleanLogs: Current swap logfile " - "not replaced.\n"); + debugs(50, 0, "storeDirWriteCleanLogs: " << state->newLog << ": write: " << xstrerror()); + debugs(50, 0, "storeDirWriteCleanLogs: Current swap logfile not replaced."); file_close(state->fd); state->fd = -1; ::unlink(state->newLog); @@ -1080,12 +1070,12 @@ UFSSwapDir::DirClean(int swap_index) D2 = ((swap_index / N0) / N1) % N2; snprintf(p1, SQUID_MAXPATHLEN, "%s/%02X/%02X", SD->path, D1, D2); - debug(36, 3) ("storeDirClean: Cleaning directory %s\n", p1); + debugs(36, 3, "storeDirClean: Cleaning directory " << p1); dir_pointer = opendir(p1); if (dir_pointer == NULL) { if (errno == ENOENT) { - debug(36, 0) ("storeDirClean: WARNING: Creating %s\n", p1); + debugs(36, 0, "storeDirClean: WARNING: Creating " << p1); #ifdef _SQUID_MSWIN_ if (mkdir(p1) == 0) @@ -1097,7 +1087,7 @@ UFSSwapDir::DirClean(int swap_index) return 0; } - debug(50, 0) ("storeDirClean: %s: %s\n", p1, xstrerror()); + debugs(50, 0, "storeDirClean: " << p1 << ": " << xstrerror()); safeunlink(p1, 1); return 0; } @@ -1127,13 +1117,13 @@ UFSSwapDir::DirClean(int swap_index) k = 10; for (n = 0; n < k; n++) { - debug(36, 3) ("storeDirClean: Cleaning file %08X\n", files[n]); + debugs(36, 3, "storeDirClean: Cleaning file "<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << files[n]); snprintf(p2, MAXPATHLEN + 1, "%s/%08X", p1, files[n]); safeunlink(p2, 0); statCounter.swap.files_cleaned++; } - debug(36, 3) ("Cleaned %d unused files from %s\n", k, p1); + debugs(36, 3, "Cleaned " << k << " unused files from " << p1); return k; } @@ -1267,7 +1257,9 @@ UFSSwapDir::validFileno(sfileno filn, int flag) const void UFSSwapDir::unlinkFile(sfileno f) { - debug(79, 3) ("UFSSwapDir::unlinkFile: unlinking fileno %08X '%s'\n", f, fullPath(f,NULL)); + debugs(79, 3, "UFSSwapDir::unlinkFile: unlinking fileno " << std::setfill('0') << + std::hex << std::uppercase << std::setw(8) << f << " '" << + fullPath(f,NULL) << "'"); /* commonUfsDirMapBitReset(this, f); */ IO->unlinkFile(fullPath(f,NULL)); } @@ -1275,7 +1267,8 @@ UFSSwapDir::unlinkFile(sfileno f) void UFSSwapDir::unlink(StoreEntry & e) { - debug(79, 3) ("storeUfsUnlink: dirno %d, fileno %08X\n", index, e.swap_filen); + debugs(79, 3, "storeUfsUnlink: dirno " << index << ", fileno "<< + std::setfill('0') << std::hex << std::uppercase << std::setw(8) << e.swap_filen); replacementRemove(&e); mapBitReset(e.swap_filen); UFSSwapDir::unlinkFile(e.swap_filen); @@ -1289,8 +1282,7 @@ UFSSwapDir::unlink(StoreEntry & e) void UFSSwapDir::replacementAdd(StoreEntry * e) { - debug(47, 4) ("UFSSwapDir::replacementAdd: added node %p to dir %d\n", e, - index); + debugs(47, 4, "UFSSwapDir::replacementAdd: added node " << e << " to dir " << index); repl->Add(repl, e, &e->repl); } @@ -1307,8 +1299,7 @@ UFSSwapDir::replacementRemove(StoreEntry * e) assert (dynamic_cast(SD.getRaw()) == this); - debug(47, 4) ("UFSSwapDir::replacementRemove: remove node %p from dir %d\n", e, - index); + debugs(47, 4, "UFSSwapDir::replacementRemove: remove node " << e << " from dir " << index); repl->Remove(repl, e, &e->repl); } diff --git a/src/fs/ufs/store_io_ufs.cc b/src/fs/ufs/store_io_ufs.cc index 7966c40907..fa395e2a2f 100644 --- a/src/fs/ufs/store_io_ufs.cc +++ b/src/fs/ufs/store_io_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.36 2007/04/12 20:36:56 wessels Exp $ + * $Id: store_io_ufs.cc,v 1.37 2007/04/28 22:26:51 hno Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -103,8 +103,11 @@ UFSStoreState::ioCompletedNotification() { if (opening) { opening = false; - debug(79, 3) ("UFSStoreState::ioCompletedNotification: dirno %d, fileno %08x status %d\n", - swap_dirn, swap_filen, theFile->error()); + debugs(79, 3, "UFSStoreState::ioCompletedNotification: dirno " << + swap_dirn << ", fileno "<< std::setfill('0') << std::hex << + std::setw(8) << swap_filen << " status "<< std::setfill(' ') << + std::dec << theFile->error()); + assert (FILE_MODE(mode) == O_RDONLY); openDone(); @@ -113,15 +116,21 @@ UFSStoreState::ioCompletedNotification() if (creating) { creating = false; - debug(79, 3) ("UFSStoreState::ioCompletedNotification: dirno %d, fileno %08x status %d\n", - swap_dirn, swap_filen, theFile->error()); + debugs(79, 3, "UFSStoreState::ioCompletedNotification: dirno " << + swap_dirn << ", fileno "<< std::setfill('0') << std::hex << + std::setw(8) << swap_filen << " status "<< std::setfill(' ') << + std::dec << theFile->error()); + openDone(); return; } assert (!(closing ||opening)); - debug(79, 3) ("diskd::ioCompleted: dirno %d, fileno %08x status %d\n", swap_dirn, swap_filen, theFile->error()); + debugs(79, 3, "diskd::ioCompleted: dirno " << swap_dirn << ", fileno "<< + std::setfill('0') << std::hex << std::setw(8) << swap_filen << + " status "<< std::setfill(' ') << std::dec << theFile->error()); + /* Ok, notification past open means an error has occured */ assert (theFile->error()); tryClosing(); @@ -149,15 +158,17 @@ UFSStoreState::openDone() if (flags.try_closing) tryClosing(); - debug(79, 3) ("UFSStoreState::openDone: exiting\n"); + debugs(79, 3, "UFSStoreState::openDone: exiting"); } void UFSStoreState::closeCompleted() { assert (closing); - debug(79, 3) ("UFSStoreState::closeCompleted: dirno %d, fileno %08x status %d\n", - swap_dirn, swap_filen, theFile->error()); + debugs(79, 3, "UFSStoreState::closeCompleted: dirno " << swap_dirn << + ", fileno "<< std::setfill('0') << std::hex << std::setw(8) << + swap_filen << " status "<< std::setfill(' ') << std::dec << + theFile->error()); if (theFile->error()) { debugs(79,3,HERE<< "theFile->error() ret " << theFile->error()); @@ -181,8 +192,8 @@ UFSStoreState::closeCompleted() void UFSStoreState::close() { - debug(79, 3) ("UFSStoreState::close: dirno %d, fileno %08X\n", swap_dirn, - swap_filen); + debugs(79, 3, "UFSStoreState::close: dirno " << swap_dirn << ", fileno "<< + std::setfill('0') << std::hex << std::uppercase << std::setw(8) << swap_filen); tryClosing(); } @@ -196,15 +207,15 @@ UFSStoreState::read_(char *buf, size_t size, off_t offset, STRCB * callback, voi assert (callback); if (!theFile->canRead()) { - debug(79, 3) ("UFSStoreState::read_: queueing read because theFile can't read\n"); + debugs(79, 3, "UFSStoreState::read_: queueing read because theFile can't read"); queueRead (buf, size, offset, callback, callback_data); return; } read.callback = callback; read.callback_data = cbdataReference(callback_data); - debug(79, 3) ("UFSStoreState::read_: dirno %d, fileno %08X\n", - swap_dirn, swap_filen); + debugs(79, 3, "UFSStoreState::read_: dirno " << swap_dirn << ", fileno "<< + std::setfill('0') << std::hex << std::uppercase << std::setw(8) << swap_filen); offset_ = offset; read_buf = buf; reading = true; @@ -223,7 +234,8 @@ UFSStoreState::read_(char *buf, size_t size, off_t offset, STRCB * callback, voi void UFSStoreState::write(char const *buf, size_t size, off_t offset, FREE * free_func) { - debug(79, 3) ("UFSStoreState::write: dirn %d, fileno %08X\n", swap_dirn, swap_filen); + debugs(79, 3, "UFSStoreState::write: dirn " << swap_dirn << ", fileno "<< + std::setfill('0') << std::hex << std::uppercase << std::setw(8) << swap_filen); if (theFile->error()) { debugs(79,1,HERE << "avoid write on theFile with error"); @@ -290,8 +302,9 @@ UFSStoreState::readCompleted(const char *buf, int len, int errflag, RefCount 0) offset_ += len; @@ -330,8 +343,9 @@ UFSStoreState::readCompleted(const char *buf, int len, int errflag, RefCount writeRequest) { - debug(79, 3) ("UFSStoreState::writeCompleted: dirno %d, fileno %08X, len %ld\n", - swap_dirn, swap_filen, (long int) len); + debugs(79, 3, "UFSStoreState::writeCompleted: dirno " << swap_dirn << ", fileno " << + std::setfill('0') << std::hex << std::uppercase << std::setw(8) << swap_filen << + ", len " << len ); /* * DPW 2006-05-24 * See doWrites() for why we don't update UFSStoreState::writing @@ -363,7 +377,7 @@ UFSStoreState::writeCompleted(int errflag, size_t len, RefCount wr void UFSStoreState::doCloseCallback(int errflag) { - debug(79, 3) ("storeUfsIOCallback: errflag=%d\n", errflag); + debugs(79, 3, "storeUfsIOCallback: errflag=" << errflag); /* * DPW 2006-05-24 * When we signal the higher layer with this callback, it might unlock @@ -439,8 +453,7 @@ UFSStoreState::kickReadQueue() if (NULL == q) return false; - debug(79, 3) ("UFSStoreState::kickReadQueue: reading queued request of %ld bytes\n", - (long int) q->size); + debugs(79, 3, "UFSStoreState::kickReadQueue: reading queued request of " << (long int) q->size << " bytes"); void *cbdata; @@ -455,7 +468,7 @@ UFSStoreState::kickReadQueue() void UFSStoreState::queueRead(char *buf, size_t size, off_t offset, STRCB *callback, void *callback_data) { - debug(79, 3) ("UFSStoreState::queueRead: queueing read\n"); + debugs(79, 3, "UFSStoreState::queueRead: queueing read"); assert(opening); assert (pending_reads == NULL); _queued_read *q = new _queued_read; @@ -547,7 +560,7 @@ UFSStrategy::open(SwapDir * SD, StoreEntry * e, StoreIOState::STFNCB * file_call StoreIOState::STIOCB * callback, void *callback_data) { assert (((UFSSwapDir *)SD)->IO == this); - debug(79, 3) ("UFSStrategy::open: fileno %08X\n", e->swap_filen); + debugs(79, 3, "UFSStrategy::open: fileno "<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << e->swap_filen); /* to consider: make createstate a private UFSStrategy call */ StoreIOState::Pointer sio = createState (SD, e, callback, callback_data); @@ -584,7 +597,7 @@ UFSStrategy::create(SwapDir * SD, StoreEntry * e, StoreIOState::STFNCB * file_ca assert (((UFSSwapDir *)SD)->IO == this); /* Allocate a number */ sfileno filn = ((UFSSwapDir *)SD)->mapBitAllocate(); - debug(79, 3) ("UFSStrategy::create: fileno %08X\n", filn); + debugs(79, 3, "UFSStrategy::create: fileno "<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << filn); /* Shouldn't we handle a 'bitmap full' error here? */ diff --git a/src/fs/ufs/ufscommon.cc b/src/fs/ufs/ufscommon.cc index 84767f5d8c..ccab8e80b7 100644 --- a/src/fs/ufs/ufscommon.cc +++ b/src/fs/ufs/ufscommon.cc @@ -1,5 +1,5 @@ /* - * $Id: ufscommon.cc,v 1.10 2007/04/21 07:14:16 wessels Exp $ + * $Id: ufscommon.cc,v 1.11 2007/04/28 22:26:51 hno Exp $ * vim: set et : * * DEBUG: section 47 Store Directory Routines @@ -73,8 +73,7 @@ RebuildState::RebuildState (RefCount aSwapDir) : sd (aSwapDir), e(NU if (!clean) flags.need_to_validate = 1; - debug(47, 1) ("Rebuilding storage in %s (%s)\n", - sd->path, clean ? "CLEAN" : "DIRTY"); + debugs(47, 1, "Rebuilding storage in " << sd->path << " (" << (clean ? "CLEAN" : "DIRTY") << ")"); } RebuildState::~RebuildState() @@ -146,7 +145,7 @@ RebuildState::rebuildFromDirectory() int fd = -1; StoreMeta *tlv_list; assert(this != NULL); - debug(47, 3) ("commonUfsDirRebuildFromDirectory: DIR #%d\n", sd->index); + debugs(47, 3, "commonUfsDirRebuildFromDirectory: DIR #" << sd->index); for (int count = 0; count < speed; count++) { assert(fd == -1); @@ -155,8 +154,7 @@ RebuildState::rebuildFromDirectory() fd = getNextFile(&filn, &size); if (fd == -2) { - debug(47, 1) ("Done scanning %s swaplog (%d entries)\n", - sd->path, n_read); + debugs(47, 1, "Done scanning " << sd->path << " swaplog (" << n_read << " entries)"); _done = true; return; } else if (fd < 0) { @@ -167,8 +165,7 @@ RebuildState::rebuildFromDirectory() /* lets get file stats here */ if (fstat(fd, &sb) < 0) { - debug(47, 1) ("commonUfsDirRebuildFromDirectory: fstat(FD %d): %s\n", - fd, xstrerror()); + debugs(47, 1, "commonUfsDirRebuildFromDirectory: fstat(FD " << fd << "): " << xstrerror()); file_close(fd); store_open_disk_fd--; fd = -1; @@ -176,18 +173,16 @@ RebuildState::rebuildFromDirectory() } if ((++counts.scancount & 0xFFFF) == 0) - debug(47, 3) (" %s %7d files opened so far.\n", - sd->path, counts.scancount); + debugs(47, 3, " " << sd->path << " " << std::setw(7) << counts.scancount << " files opened so far."); + debugs(47, 9, "file_in: fd=" << fd << " "<< std::setfill('0') << std::hex << std::uppercase << std::setw(8) << filn); - debug(47, 9) ("file_in: fd=%d %08X\n", fd, filn); statCounter.syscalls.disk.reads++; int len; if ((len = FD_READ_METHOD(fd, hdr_buf, SM_PAGE_SIZE)) < 0) { - debug(47, 1) ("commonUfsDirRebuildFromDirectory: read(FD %d): %s\n", - fd, xstrerror()); + debugs(47, 1, "commonUfsDirRebuildFromDirectory: read(FD " << fd << "): " << xstrerror()); file_close(fd); store_open_disk_fd--; fd = -1; @@ -202,7 +197,7 @@ RebuildState::rebuildFromDirectory() StoreMetaUnpacker aBuilder(hdr_buf, len, &swap_hdr_len); if (!aBuilder.isBufferSane()) { - debug(47, 1) ("commonUfsDirRebuildFromDirectory: Swap data buffer length is not sane.\n"); + debugs(47, 1, "commonUfsDirRebuildFromDirectory: Swap data buffer length is not sane."); /* XXX shouldn't this be a call to commonUfsUnlink ? */ sd->unlinkFile ( filn); continue; @@ -211,13 +206,13 @@ RebuildState::rebuildFromDirectory() tlv_list = aBuilder.createStoreMeta (); if (tlv_list == NULL) { - debug(47, 1) ("commonUfsDirRebuildFromDirectory: failed to get meta data\n"); + debugs(47, 1, "commonUfsDirRebuildFromDirectory: failed to get meta data"); /* XXX shouldn't this be a call to commonUfsUnlink ? */ sd->unlinkFile (filn); continue; } - debug(47, 3) ("commonUfsDirRebuildFromDirectory: successful swap meta unpacking\n"); + debugs(47, 3, "commonUfsDirRebuildFromDirectory: successful swap meta unpacking"); memset(key, '\0', MD5_DIGEST_CHARS); memset(&tmpe, '\0', sizeof(StoreEntry)); InitStoreEntry visitor(&tmpe, key); @@ -226,7 +221,7 @@ RebuildState::rebuildFromDirectory() tlv_list = NULL; if (storeKeyNull(key)) { - debug(47, 1) ("commonUfsDirRebuildFromDirectory: NULL key\n"); + debugs(47, 1, "commonUfsDirRebuildFromDirectory: NULL key"); sd->unlinkFile(filn); continue; } @@ -239,8 +234,10 @@ RebuildState::rebuildFromDirectory() } else if (tmpe.swap_file_sz == (size_t)(sb.st_size - swap_hdr_len)) { tmpe.swap_file_sz = (size_t) sb.st_size; } else if (tmpe.swap_file_sz != (size_t)sb.st_size) { - debug(47, 1) ("commonUfsDirRebuildFromDirectory: SIZE MISMATCH %ld!=%ld\n", - (long int) tmpe.swap_file_sz, (long int) sb.st_size); + debugs(47, 1, "commonUfsDirRebuildFromDirectory: SIZE MISMATCH " << + (long int) tmpe.swap_file_sz << "!=" << + (long int) sb.st_size); + sd->unlinkFile(filn); continue; } @@ -324,8 +321,7 @@ RebuildState::rebuildFromSwapLog() size_t ss = sizeof(StoreSwapLogData); if (fread(&swapData, ss, 1, log) != 1) { - debug(47, 1) ("Done reading %s swaplog (%d entries)\n", - sd->path, n_read); + debugs(47, 1, "Done reading " << sd->path << " swaplog (" << n_read << " entries)"); fclose(log); log = NULL; _done = true; @@ -350,10 +346,11 @@ RebuildState::rebuildFromSwapLog() */ swapData.swap_filen &= 0x00FFFFFF; - debug(47, 3) ("commonUfsDirRebuildFromSwapLog: %s %s %08X\n", - swap_log_op_str[(int) swapData.op], - storeKeyText(swapData.key), - swapData.swap_filen); + debugs(47, 3, "commonUfsDirRebuildFromSwapLog: " << + swap_log_op_str[(int) swapData.op] << " " << + storeKeyText(swapData.key) << " "<< std::setfill('0') << + std::hex << std::uppercase << std::setw(8) << + swapData.swap_filen); if (swapData.op == SWAP_LOG_ADD) { (void) 0; @@ -397,8 +394,7 @@ RebuildState::rebuildFromSwapLog() x = ::log(static_cast(++counts.bad_log_op)) / ::log(10.0); if (0.0 == x - (double) (int) x) - debug(47, 1) ("WARNING: %d invalid swap log entries found\n", - counts.bad_log_op); + debugs(47, 1, "WARNING: " << counts.bad_log_op << " invalid swap log entries found"); counts.invalid++; @@ -459,7 +455,7 @@ RebuildState::rebuildFromSwapLog() sd->dereference(*currentEntry()); } else { debug_trap("commonUfsDirRebuildFromSwapLog: bad condition"); - debug(47, 1) ("\tSee %s:%d\n", __FILE__, __LINE__); + debugs(47, 1, "\tSee " << __FILE__ << ":" << __LINE__); } continue; @@ -469,8 +465,10 @@ RebuildState::rebuildFromSwapLog() * point. If the log is dirty, the filesize check should have * caught this. If the log is clean, there should never be a * newer entry. */ - debug(47, 1) ("WARNING: newer swaplog entry for dirno %d, fileno %08X\n", - sd->index, swapData.swap_filen); + debugs(47, 1, "WARNING: newer swaplog entry for dirno " << + sd->index << ", fileno "<< std::setfill('0') << std::hex << + std::uppercase << std::setw(8) << swapData.swap_filen); + /* I'm tempted to remove the swapfile here just to be safe, * but there is a bad race condition in the NOVM version if * the swapfile has recently been opened for writing, but @@ -535,11 +533,10 @@ RebuildState::getNextFile(sfileno * filn_p, int *size) { int fd = -1; int dirs_opened = 0; - debug(47, 3) ("commonUfsDirGetNextFile: flag=%d, %d: /%02X/%02X\n", - flags.init, - sd->index, - curlvl1, - curlvl2); + debugs(47, 3, "commonUfsDirGetNextFile: flag=" << flags.init << ", " << + sd->index << ": /"<< std::setfill('0') << std::hex << + std::uppercase << std::setw(2) << curlvl1 << "/" << std::setw(2) << + curlvl2); if (done) return -2; @@ -569,16 +566,14 @@ RebuildState::getNextFile(sfileno * filn_p, int *size) dirs_opened++; if (td == NULL) { - debug(47, 1) ("commonUfsDirGetNextFile: opendir: %s: %s\n", - fullpath, xstrerror()); + debugs(47, 1, "commonUfsDirGetNextFile: opendir: " << fullpath << ": " << xstrerror()); } else { entry = readdir(td); /* skip . and .. */ entry = readdir(td); if (entry == NULL && errno == ENOENT) - debug(47, 1) ("commonUfsDirGetNextFile: directory does not exist!.\n"); - - debug(47, 3) ("commonUfsDirGetNextFile: Directory %s\n", fullpath); + debugs(47, 1, "commonUfsDirGetNextFile: directory does not exist!."); + debugs(47, 3, "commonUfsDirGetNextFile: Directory " << fullpath); } } @@ -586,29 +581,31 @@ RebuildState::getNextFile(sfileno * filn_p, int *size) in_dir++; if (sscanf(entry->d_name, "%x", &fn) != 1) { - debug(47, 3) ("commonUfsDirGetNextFile: invalid %s\n", - entry->d_name); + debugs(47, 3, "commonUfsDirGetNextFile: invalid " << entry->d_name); continue; } if (!UFSSwapDir::FilenoBelongsHere(fn, sd->index, curlvl1, curlvl2)) { - debug(47, 3) ("commonUfsDirGetNextFile: %08X does not belong in %d/%d/%d\n", - fn, sd->index, curlvl1, curlvl2); + debugs(47, 3, "commonUfsDirGetNextFile: "<< std::setfill('0') << + std::hex << std::uppercase << std::setw(8) << fn << + " does not belong in " << std::dec << sd->index << "/" << + curlvl1 << "/" << curlvl2); + continue; } if (sd->mapBitTest(fn)) { - debug(47, 3) ("commonUfsDirGetNextFile: Locked, continuing with next.\n"); + debugs(47, 3, "commonUfsDirGetNextFile: Locked, continuing with next."); continue; } snprintf(fullfilename, SQUID_MAXPATHLEN, "%s/%s", fullpath, entry->d_name); - debug(47, 3) ("commonUfsDirGetNextFile: Opening %s\n", fullfilename); + debugs(47, 3, "commonUfsDirGetNextFile: Opening " << fullfilename); fd = file_open(fullfilename, O_RDONLY | O_BINARY); if (fd < 0) - debug(47, 1) ("commonUfsDirGetNextFile: %s: %s\n", fullfilename, xstrerror()); + debugs(47, 1, "commonUfsDirGetNextFile: " << fullfilename << ": " << xstrerror()); else store_open_disk_fd++; diff --git a/src/ftp.cc b/src/ftp.cc index e73985d5ee..f8b32ca42b 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.417 2007/04/25 14:37:55 rousskov Exp $ + * $Id: ftp.cc,v 1.418 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -376,7 +376,7 @@ FtpStateData::ftpSocketClosed(int fdnotused, void *data) FtpStateData::FtpStateData(FwdState *theFwdState) : ServerStateData(theFwdState) { const char *url = entry->url(); - debug(9, 3) ("ftpStart: '%s'\n", url); + debugs(9, 3, "ftpStart: '" << url << "'" ); statCounter.server.all.requests++; statCounter.server.ftp.requests++; ctrl.fd = theFwdState->server_fd; @@ -397,7 +397,7 @@ FtpStateData::FtpStateData(FwdState *theFwdState) : ServerStateData(theFwdState) FtpStateData::~FtpStateData() { - debug(9, 3) ("~ftpStateData: %s\n", entry->url()); + debugs(9, 3, "~ftpStateData: " << entry->url() ); entry->unregisterAbort(); @@ -489,13 +489,13 @@ FtpStateData::ftpTimeout(int fd, void *data) { FtpStateData *ftpState = (FtpStateData *)data; StoreEntry *entry = ftpState->entry; - debug(9, 4) ("ftpTimeout: FD %d: '%s'\n", fd, entry->url()); + debugs(9, 4, "ftpTimeout: FD " << fd << ": '" << entry->url() << "'" ); if (SENT_PASV == ftpState->state && fd == ftpState->data.fd) { /* stupid ftp.netscape.com */ ftpState->fwd->dontRetry(false); ftpState->fwd->ftpPasvFailed(true); - debug(9, 1) ("ftpTimeout: timeout in SENT_PASV state\n"); + debugs(9, 1, "ftpTimeout: timeout in SENT_PASV state" ); } ftpState->failed(ERR_READ_TIMEOUT, 0); @@ -576,7 +576,7 @@ FtpStateData::listingStart() /* Error guard, or "assert" */ printfReplyBody("ERROR: Failed to parse URL: %s\n", html_quote(title)); - debug(9, 0) ("Failed to parse URL: %s\n", title); + debugs(9, 0, "Failed to parse URL: " << title); break; } } @@ -1107,7 +1107,7 @@ FtpStateData::parseListing() size_t len = data.readBuf->contentSize(); if (!len) { - debug(9, 3) ("ftpParseListing: no content to parse for %s\n", e->url()); + debugs(9, 3, "ftpParseListing: no content to parse for " << e->url() ); return; } @@ -1123,15 +1123,16 @@ FtpStateData::parseListing() usable = end - sbuf; - debug(9, 3) ("ftpParseListing: usable = %d\n", (int) usable); + debugs(9, 3, "ftpParseListing: usable = " << (int) usable); if (usable == 0) { - debug(9, 3) ("ftpParseListing: didn't find end for %s\n", e->url()); + debugs(9, 3, "ftpParseListing: didn't find end for " << e->url() ); xfree(sbuf); return; } - debug(9, 3) ("ftpParseListing: %lu bytes to play with\n", (unsigned long int)len); + debugs(9, 3, "ftpParseListing: " << (unsigned long int)len << " bytes to play with"); + line = (char *)memAllocate(MEM_4K_BUF); end++; e->buffer(); /* released when done processing current data payload */ @@ -1139,7 +1140,7 @@ FtpStateData::parseListing() s += strspn(s, crlf); for (; s < end; s += strcspn(s, crlf), s += strspn(s, crlf)) { - debug(9, 3) ("ftpParseListing: s = {%s}\n", s); + debugs(9, 3, "ftpParseListing: s = {" << s << "}"); linelen = strcspn(s, crlf) + 1; if (linelen < 2) @@ -1150,7 +1151,7 @@ FtpStateData::parseListing() xstrncpy(line, s, linelen); - debug(9, 7) ("ftpParseListing: {%s}\n", line); + debugs(9, 7, "ftpParseListing: {" << line << "}"); if (!strncmp(line, "total", 5)) continue; @@ -1186,7 +1187,7 @@ FtpStateData::dataDescriptor() const { void FtpStateData::dataComplete() { - debug(9, 3) ("ftpDataComplete\n"); + debugs(9, 3, "ftpDataComplete"); /* Connection closed; transfer done. */ if (data.fd > -1) { @@ -1303,7 +1304,7 @@ FtpStateData::dataRead(int fd, char *buf, size_t len, comm_err_t errflag, int xe } if (errflag != COMM_OK || len < 0) { - debug(50, ignoreErrno(xerrno) ? 3 : 1) ("ftpDataRead: read error: %s\n", xstrerr(xerrno)); + debugs(50, ignoreErrno(xerrno) ? 3 : 1, "ftpDataRead: read error: " << xstrerr(xerrno)); if (ignoreErrno(xerrno)) { commSetTimeout(fd, Config.Timeout.read, ftpTimeout, this); @@ -1528,9 +1529,10 @@ FtpStateData::start() checkUrlpath(); buildTitleUrl(); - debug(9, 5) ("ftpStart: host=%s, path=%s, user=%s, passwd=%s\n", - request->host, request->urlpath.buf(), - user, password); + debugs(9, 5, "ftpStart: host=" << request->host << ", path=" << + request->urlpath.buf() << ", user=" << user << ", passwd=" << + password); + state = BEGIN; ctrl.last_command = xstrdup("Connect to server"); ctrl.buf = (char *)memAllocBuf(4096, &ctrl.size); @@ -1572,7 +1574,7 @@ void FtpStateData::writeCommand(const char *buf) { char *ebuf; - debug(9, 5) ("ftpWriteCommand: %s\n", buf); + debugs(9, 5, "ftpWriteCommand: " << buf); if (Config.Ftp.telnet) ebuf = escapeIAC(buf); @@ -1599,7 +1601,7 @@ FtpStateData::ftpWriteCommandCallback(int fd, char *buf, size_t size, comm_err_t { FtpStateData *ftpState = (FtpStateData *)data; - debug(9, 7) ("ftpWriteCommandCallback: wrote %d bytes\n", (int) size); + debugs(9, 7, "ftpWriteCommandCallback: wrote " << (int) size << " bytes"); if (size > 0) { fd_bytes(fd, size, FD_WRITE); @@ -1611,7 +1613,7 @@ FtpStateData::ftpWriteCommandCallback(int fd, char *buf, size_t size, comm_err_t return; if (errflag) { - debug(9, 1) ("ftpWriteCommandCallback: FD %d: %s\n", fd, xstrerr(xerrno)); + debugs(9, 1, "ftpWriteCommandCallback: FD " << fd << ": " << xstrerr(xerrno)); ftpState->failed(ERR_WRITE_ERROR, xerrno); /* failed closes ctrl.fd and frees ftpState */ return; @@ -1632,7 +1634,7 @@ FtpStateData::ftpParseControlReply(char *buf, size_t len, int *codep, int *used) off_t offset; size_t linelen; int code = -1; - debug(9, 5) ("ftpParseControlReply\n"); + debugs(9, 5, "ftpParseControlReply"); /* * We need a NULL-terminated buffer for scanning, ick */ @@ -1645,15 +1647,15 @@ FtpStateData::ftpParseControlReply(char *buf, size_t len, int *codep, int *used) usable = end - sbuf; - debug(9, 3) ("ftpParseControlReply: usable = %d\n", usable); + debugs(9, 3, "ftpParseControlReply: usable = " << usable); if (usable == 0) { - debug(9, 3) ("ftpParseControlReply: didn't find end of line\n"); + debugs(9, 3, "ftpParseControlReply: didn't find end of line"); safe_free(sbuf); return NULL; } - debug(9, 3) ("ftpParseControlReply: %d bytes to play with\n", (int) len); + debugs(9, 3, "ftpParseControlReply: " << (int) len << " bytes to play with"); end++; s = sbuf; s += strspn(s, crlf); @@ -1662,7 +1664,7 @@ FtpStateData::ftpParseControlReply(char *buf, size_t len, int *codep, int *used) if (complete) break; - debug(9, 3) ("ftpParseControlReply: s = {%s}\n", s); + debugs(9, 3, "ftpParseControlReply: s = {" << s << "}"); linelen = strcspn(s, crlf) + 1; @@ -1687,7 +1689,7 @@ FtpStateData::ftpParseControlReply(char *buf, size_t len, int *codep, int *used) xstrncpy(list->key, s + offset, linelen - offset); - debug(9, 7) ("%d %s\n", code, list->key); + debugs(9, 7, "" << code << " " << list->key); *tail = list; @@ -1714,7 +1716,7 @@ FtpStateData::ftpParseControlReply(char *buf, size_t len, int *codep, int *used) void FtpStateData::scheduleReadControlReply(int buffered_ok) { - debug(9, 3) ("scheduleReadControlReply: FD %d\n", ctrl.fd); + debugs(9, 3, "scheduleReadControlReply: FD " << ctrl.fd); if (buffered_ok && ctrl.offset > 0) { /* We've already read some reply data */ @@ -1740,7 +1742,7 @@ FtpStateData::ftpReadControlReply(int fd, char *buf, size_t len, comm_err_t errf { FtpStateData *ftpState = (FtpStateData *)data; StoreEntry *entry = ftpState->entry; - debug(9, 5) ("ftpReadControlReply: FD %d, Read %d bytes\n", fd, (int)len); + debugs(9, 5, "ftpReadControlReply: FD " << fd << ", Read " << (int)len << " bytes"); if (len > 0) { kb_incr(&statCounter.server.all.kbytes_in, len); @@ -1763,7 +1765,7 @@ FtpStateData::ftpReadControlReply(int fd, char *buf, size_t len, comm_err_t errf if (errflag != COMM_OK || len < 0) { - debug(50, ignoreErrno(xerrno) ? 3 : 1) ("ftpReadControlReply: read error: %s\n", xstrerr(xerrno)); + debugs(50, ignoreErrno(xerrno) ? 3 : 1, "ftpReadControlReply: read error: " << xstrerr(xerrno)); if (ignoreErrno(xerrno)) { ftpState->scheduleReadControlReply(0); @@ -1838,8 +1840,7 @@ FtpStateData::handleControlReply() */ wordlistAddWl(&cwd_message, ctrl.message); - debug(9, 8) ("handleControlReply: state=%d, code=%d\n", state, - ctrl.replycode); + debugs(9, 8, "handleControlReply: state=" << state << ", code=" << ctrl.replycode); FTP_SM_FUNCS[state] (this); } @@ -1850,7 +1851,7 @@ static void ftpReadWelcome(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("ftpReadWelcome\n"); + debugs(9, 3, "ftpReadWelcome"); if (ftpState->flags.pasv_only) ftpState->login_att++; @@ -1867,8 +1868,7 @@ ftpReadWelcome(FtpStateData * ftpState) ftpSendUser(ftpState); } else if (code == 120) { if (NULL != ftpState->ctrl.message) - debug(9, 3) ("FTP server is busy: %s\n", - ftpState->ctrl.message->key); + debugs(9, 3, "FTP server is busy: " << ftpState->ctrl.message->key); return; } else { @@ -1895,7 +1895,7 @@ static void ftpReadUser(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("ftpReadUser\n"); + debugs(9, 3, "ftpReadUser"); if (code == 230) { ftpReadPass(ftpState); @@ -1918,7 +1918,7 @@ static void ftpReadPass(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("ftpReadPass\n"); + debugs(9, 3, "ftpReadPass"); if (code == 230) { ftpSendType(ftpState); @@ -1980,7 +1980,7 @@ ftpReadType(FtpStateData * ftpState) int code = ftpState->ctrl.replycode; char *path; char *d, *p; - debug(9, 3) ("This is ftpReadType\n"); + debugs(9, 3, "This is ftpReadType"); if (code == 200) { p = path = xstrdup(ftpState->request->urlpath.buf()); @@ -2016,8 +2016,7 @@ static void ftpTraverseDirectory(FtpStateData * ftpState) { wordlist *w; - debug(9, 4) ("ftpTraverseDirectory %s\n", - ftpState->filepath ? ftpState->filepath : ""); + debugs(9, 4, "ftpTraverseDirectory " << (ftpState->filepath ? ftpState->filepath : "")); safe_free(ftpState->dirpath); ftpState->dirpath = ftpState->filepath; @@ -2026,7 +2025,7 @@ ftpTraverseDirectory(FtpStateData * ftpState) /* Done? */ if (ftpState->pathcomps == NULL) { - debug(9, 3) ("the final component was a directory\n"); + debugs(9, 3, "the final component was a directory"); ftpListDir(ftpState); return; } @@ -2044,7 +2043,7 @@ ftpTraverseDirectory(FtpStateData * ftpState) if (ftpState->pathcomps != NULL || ftpState->flags.isdir) { ftpSendCwd(ftpState); } else { - debug(9, 3) ("final component is probably a file\n"); + debugs(9, 3, "final component is probably a file"); ftpGetFile(ftpState); return; } @@ -2054,7 +2053,7 @@ static void ftpSendCwd(FtpStateData * ftpState) { char *path = ftpState->filepath; - debug(9, 3) ("ftpSendCwd\n"); + debugs(9, 3, "ftpSendCwd"); if (!strcmp(path, "..") || !strcmp(path, "/")) { ftpState->flags.no_dotdot = 1; @@ -2073,7 +2072,7 @@ static void ftpReadCwd(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadCwd\n"); + debugs(9, 3, "This is ftpReadCwd"); if (code >= 200 && code < 300) { /* CWD OK */ @@ -2103,7 +2102,7 @@ static void ftpSendMkdir(FtpStateData * ftpState) { char *path = ftpState->filepath; - debug(9, 3) ("ftpSendMkdir: with path=%s\n", path); + debugs(9, 3, "ftpSendMkdir: with path=" << path); snprintf(cbuf, 1024, "MKD %s\r\n", path); ftpState->writeCommand(cbuf); ftpState->state = SENT_MKDIR; @@ -2115,7 +2114,7 @@ ftpReadMkdir(FtpStateData * ftpState) char *path = ftpState->filepath; int code = ftpState->ctrl.replycode; - debug(9, 3) ("ftpReadMkdir: path %s, code %d\n", path, code); + debugs(9, 3, "ftpReadMkdir: path " << path << ", code " << code); if (code == 257) { /* success */ ftpSendCwd(ftpState); @@ -2142,7 +2141,7 @@ static void ftpListDir(FtpStateData * ftpState) { if (ftpState->flags.dir_slash) { - debug(9, 3) ("Directory path did not end in /\n"); + debugs(9, 3, "Directory path did not end in /"); ftpState->title_url.append("/"); ftpState->flags.isdir = 1; } @@ -2163,7 +2162,7 @@ static void ftpReadMdtm(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadMdtm\n"); + debugs(9, 3, "This is ftpReadMdtm"); if (code == 213) { ftpState->mdtm = parse_iso3307_time(ftpState->ctrl.last_reply); @@ -2196,16 +2195,17 @@ static void ftpReadSize(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadSize\n"); + debugs(9, 3, "This is ftpReadSize"); if (code == 213) { ftpState->unhack(); ftpState->size = atoi(ftpState->ctrl.last_reply); if (ftpState->size == 0) { - debug(9, 2) ("ftpReadSize: SIZE reported %s on %s\n", - ftpState->ctrl.last_reply, - ftpState->title_url.buf()); + debugs(9, 2, "ftpReadSize: SIZE reported " << + ftpState->ctrl.last_reply << " on " << + ftpState->title_url.buf()); + ftpState->size = -1; } } else if (code < 0) { @@ -2256,8 +2256,7 @@ ftpSendPasv(FtpStateData * ftpState) addr_len = sizeof(addr); if (getsockname(ftpState->ctrl.fd, (struct sockaddr *) &addr, &addr_len)) { - debug(9, 0) ("ftpSendPasv: getsockname(%d,..): %s\n", - ftpState->ctrl.fd, xstrerror()); + debugs(9, 0, "ftpSendPasv: getsockname(" << ftpState->ctrl.fd << ",..): " << xstrerror()); ftpFail(ftpState); return; } @@ -2270,7 +2269,7 @@ ftpSendPasv(FtpStateData * ftpState) COMM_NONBLOCKING, ftpState->entry->url()); - debug(9, 3) ("ftpSendPasv: Unconnected data socket created on FD %d\n", fd); + debugs(9, 3, "ftpSendPasv: Unconnected data socket created on FD " << fd); if (fd < 0) { ftpFail(ftpState); @@ -2313,24 +2312,27 @@ ftpReadPasv(FtpStateData * ftpState) int fd = ftpState->data.fd; char *buf; LOCAL_ARRAY(char, ipaddr, 1024); - debug(9, 3) ("This is ftpReadPasv\n"); + debugs(9, 3, "This is ftpReadPasv"); if (code != 227) { - debug(9, 3) ("PASV not supported by remote end\n"); + debugs(9, 3, "PASV not supported by remote end"); ftpSendPort(ftpState); return; } /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */ /* ANSI sez [^0-9] is undefined, it breaks on Watcom cc */ - debug(9, 5) ("scanning: %s\n", ftpState->ctrl.last_reply); + debugs(9, 5, "scanning: " << ftpState->ctrl.last_reply); buf = ftpState->ctrl.last_reply + strcspn(ftpState->ctrl.last_reply, "0123456789"); n = sscanf(buf, "%d,%d,%d,%d,%d,%d", &h1, &h2, &h3, &h4, &p1, &p2); if (n != 6 || p1 < 0 || p2 < 0 || p1 > 255 || p2 > 255) { - debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debugs(9, 1, "Unsafe PASV reply from " << + fd_table[ftpState->ctrl.fd].ipaddr << ": " << + ftpState->ctrl.last_reply); + ftpSendPort(ftpState); return; } @@ -2338,7 +2340,10 @@ ftpReadPasv(FtpStateData * ftpState) snprintf(ipaddr, 1024, "%d.%d.%d.%d", h1, h2, h3, h4); if (!safe_inet_addr(ipaddr, NULL)) { - debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debugs(9, 1, "Unsafe PASV reply from " << + fd_table[ftpState->ctrl.fd].ipaddr << ": " << + ftpState->ctrl.last_reply); + ftpSendPort(ftpState); return; } @@ -2346,14 +2351,20 @@ ftpReadPasv(FtpStateData * ftpState) port = ((p1 << 8) + p2); if (0 == port) { - debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debugs(9, 1, "Unsafe PASV reply from " << + fd_table[ftpState->ctrl.fd].ipaddr << ": " << + ftpState->ctrl.last_reply); + ftpSendPort(ftpState); return; } if (Config.Ftp.sanitycheck) { if (port < 1024) { - debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply); + debugs(9, 1, "Unsafe PASV reply from " << + fd_table[ftpState->ctrl.fd].ipaddr << ": " << + ftpState->ctrl.last_reply); + ftpSendPort(ftpState); return; } @@ -2372,7 +2383,7 @@ ftpReadPasv(FtpStateData * ftpState) ftpState->ctrl.last_command = xstrdup("Connect to server data port"); - debug(9, 5) ("ftpReadPasv: connecting to %s, port %d\n", ftpState->data.host, ftpState->data.port); + debugs(9, 5, "ftpReadPasv: connecting to " << ftpState->data.host << ", port " << ftpState->data.port); commConnectStart(fd, ipaddr, port, FtpStateData::ftpPasvCallback, ftpState); } @@ -2381,10 +2392,10 @@ void FtpStateData::ftpPasvCallback(int fd, comm_err_t status, int xerrno, void *data) { FtpStateData *ftpState = (FtpStateData *)data; - debug(9, 3) ("ftpPasvCallback\n"); + debugs(9, 3, "ftpPasvCallback"); if (status != COMM_OK) { - debug(9, 2) ("ftpPasvCallback: failed to connect. Retrying without PASV.\n"); + debugs(9, 2, "ftpPasvCallback: failed to connect. Retrying without PASV."); ftpState->fwd->dontRetry(false); /* this is a retryable error */ ftpState->fwd->ftpPasvFailed(true); ftpState->failed(ERR_NONE, 0); @@ -2421,8 +2432,7 @@ ftpOpenListenSocket(FtpStateData * ftpState, int fallback) addr_len = sizeof(addr); if (getsockname(ftpState->ctrl.fd, (struct sockaddr *) &addr, &addr_len)) { - debug(9, 0) ("ftpOpenListenSocket: getsockname(%d,..): %s\n", - ftpState->ctrl.fd, xstrerror()); + debugs(9, 0, "ftpOpenListenSocket: getsockname(" << ftpState->ctrl.fd << ",..): " << xstrerror()); return -1; } @@ -2441,10 +2451,10 @@ ftpOpenListenSocket(FtpStateData * ftpState, int fallback) port, COMM_NONBLOCKING | (fallback ? COMM_REUSEADDR : 0), ftpState->entry->url()); - debug(9, 3) ("ftpOpenListenSocket: Unconnected data socket created on FD %d\n", fd); + debugs(9, 3, "ftpOpenListenSocket: Unconnected data socket created on FD " << fd ); if (fd < 0) { - debug(9, 0) ("ftpOpenListenSocket: comm_open failed\n"); + debugs(9, 0, "ftpOpenListenSocket: comm_open failed"); return -1; } @@ -2468,13 +2478,14 @@ ftpSendPort(FtpStateData * ftpState) socklen_t addr_len; unsigned char *addrptr; unsigned char *portptr; - debug(9, 3) ("This is ftpSendPort\n"); + debugs(9, 3, "This is ftpSendPort"); ftpState->flags.pasv_supported = 0; fd = ftpOpenListenSocket(ftpState, 0); addr_len = sizeof(addr); if (getsockname(fd, (struct sockaddr *) &addr, &addr_len)) { - debug(9, 0) ("ftpSendPort: getsockname(%d,..): %s\n", fd, xstrerror()); + debugs(9, 0, "ftpSendPort: getsockname(" << fd << ",..): " << xstrerror()); + /* XXX Need to set error message */ ftpFail(ftpState); return; @@ -2493,11 +2504,11 @@ static void ftpReadPort(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadPort\n"); + debugs(9, 3, "This is ftpReadPort"); if (code != 200) { /* Fall back on using the same port as the control connection */ - debug(9, 3) ("PORT not supported by remote end\n"); + debugs(9, 3, "PORT not supported by remote end"); ftpOpenListenSocket(ftpState, 1); } @@ -2510,7 +2521,7 @@ ftpAcceptDataConnection(int fd, int newfd, ConnectionDetail *details, comm_err_t flag, int xerrno, void *data) { FtpStateData *ftpState = (FtpStateData *)data; - debug(9, 3) ("ftpAcceptDataConnection\n"); + debugs(9, 3, "ftpAcceptDataConnection"); if (flag == COMM_ERR_CLOSING) return; @@ -2524,7 +2535,10 @@ ftpAcceptDataConnection(int fd, int newfd, ConnectionDetail *details, char *ipaddr = inet_ntoa(details->peer.sin_addr); if (strcmp(fd_table[ftpState->ctrl.fd].ipaddr, ipaddr) != 0) { - debug(9, 1) ("FTP data connection from unexpected server (%s:%d), expecting %s\n", ipaddr, (int) ntohs(details->peer.sin_port), fd_table[ftpState->ctrl.fd].ipaddr); + debugs(9, 1, "FTP data connection from unexpected server (" << + ipaddr << ":" << (int) ntohs(details->peer.sin_port) << + "), expecting " << fd_table[ftpState->ctrl.fd].ipaddr); + comm_close(newfd); comm_accept(ftpState->data.fd, ftpAcceptDataConnection, ftpState); return; @@ -2532,7 +2546,7 @@ ftpAcceptDataConnection(int fd, int newfd, ConnectionDetail *details, } if (flag != COMM_OK) { - debug(9, 1) ("ftpHandleDataAccept: comm_accept(%d): %s\n", newfd, xstrerr(xerrno)); + debugs(9, 1, "ftpHandleDataAccept: comm_accept(" << newfd << "): " << xstrerr(xerrno)); /* XXX Need to set error message */ ftpFail(ftpState); return; @@ -2541,7 +2555,7 @@ ftpAcceptDataConnection(int fd, int newfd, ConnectionDetail *details, /* Replace the Listen socket with the accepted data socket */ comm_close(ftpState->data.fd); - debug(9, 3) ("ftpAcceptDataConnection: Connected data socket on FD %d\n", newfd); + debugs(9, 3, "ftpAcceptDataConnection: Connected data socket on FD " << newfd); ftpState->data.fd = newfd; @@ -2565,7 +2579,7 @@ ftpAcceptDataConnection(int fd, int newfd, ConnectionDetail *details, static void ftpRestOrList(FtpStateData * ftpState) { - debug(9, 3) ("This is ftpRestOrList\n"); + debugs(9, 3, "This is ftpRestOrList"); if (ftpState->typecode == 'D') { ftpState->flags.isdir = 1; @@ -2576,7 +2590,7 @@ ftpRestOrList(FtpStateData * ftpState) ftpSendNlst(ftpState); /* GET name;type=d sec 3.2.2 of RFC 1738 */ } } else if (ftpState->flags.put) { - debug(9, 3) ("ftpRestOrList: Sending STOR request...\n"); + debugs(9, 3, "ftpRestOrList: Sending STOR request..."); ftpSendStor(ftpState); } else if (ftpState->flags.isdir) ftpSendList(ftpState); @@ -2613,19 +2627,19 @@ ftpReadStor(FtpStateData * ftpState) void FtpStateData::readStor() { int code = ctrl.replycode; - debug(9, 3) ("This is ftpReadStor\n"); + debugs(9, 3, "This is ftpReadStor"); if (code == 125 || (code == 150 && data.host)) { // register to receive body data assert(request->body_pipe != NULL); if (!request->body_pipe->setConsumerIfNotLate(this)) { - debug(9, 3) ("ftpReadStor: aborting on partially consumed body\n"); + debugs(9, 3, "ftpReadStor: aborting on partially consumed body"); ftpFail(this); return; } /* Begin data transfer */ - debug(9, 3) ("ftpReadStor: starting data transfer\n"); + debugs(9, 3, "ftpReadStor: starting data transfer"); sendMoreRequestBody(); /* * Cancel the timeout on the Control socket and @@ -2636,13 +2650,13 @@ void FtpStateData::readStor() { this); state = WRITING_DATA; - debug(9, 3) ("ftpReadStor: writing data channel\n"); + debugs(9, 3, "ftpReadStor: writing data channel"); } else if (code == 150) { /* Accept data channel */ - debug(9, 3) ("ftpReadStor: accepting data channel\n"); + debugs(9, 3, "ftpReadStor: accepting data channel"); comm_accept(data.fd, ftpAcceptDataConnection, this); } else { - debug(9, 3) ("ftpReadStor: Unexpected reply code %03d\n", code); + debugs(9, 3, "ftpReadStor: Unexpected reply code "<< std::setfill('0') << std::setw(3) << code); ftpFail(this); } } @@ -2682,14 +2696,14 @@ static void ftpReadRest(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadRest\n"); + debugs(9, 3, "This is ftpReadRest"); assert(ftpState->restart_offset > 0); if (code == 350) { ftpState->restarted_offset = ftpState->restart_offset; ftpSendRetr(ftpState); } else if (code > 0) { - debug(9, 3) ("ftpReadRest: REST not supported\n"); + debugs(9, 3, "ftpReadRest: REST not supported"); ftpState->flags.rest_supported = 0; ftpSendRetr(ftpState); } else { @@ -2729,7 +2743,7 @@ static void ftpReadList(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadList\n"); + debugs(9, 3, "This is ftpReadList"); if (code == 125 || (code == 150 && ftpState->data.host)) { /* Begin data transfer */ @@ -2773,11 +2787,11 @@ static void ftpReadRetr(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadRetr\n"); + debugs(9, 3, "This is ftpReadRetr"); if (code == 125 || (code == 150 && ftpState->data.host)) { /* Begin data transfer */ - debug(9, 3) ("ftpReadRetr: reading data channel\n"); + debugs(9, 3, "ftpReadRetr: reading data channel"); /* XXX what about Config.Timeout.read? */ ftpState->maybeReadVirginBody(); ftpState->state = READING_DATA; @@ -2812,7 +2826,7 @@ static void ftpReadTransferDone(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpReadTransferDone\n"); + debugs(9, 3, "This is ftpReadTransferDone"); if (code == 226 || code == 250) { /* Connection closed; retrieval done. */ @@ -2822,8 +2836,7 @@ ftpReadTransferDone(FtpStateData * ftpState) ftpSendQuit(ftpState); } else { /* != 226 */ - debug(9, 1) ("ftpReadTransferDone: Got code %d after reading data\n", - code); + debugs(9, 1, "ftpReadTransferDone: Got code " << code << " after reading data"); ftpState->failed(ERR_FTP_FAILURE, 0); /* failed closes ctrl.fd and frees ftpState */ return; @@ -2852,11 +2865,10 @@ static void ftpWriteTransferDone(FtpStateData * ftpState) { int code = ftpState->ctrl.replycode; - debug(9, 3) ("This is ftpWriteTransferDone\n"); + debugs(9, 3, "This is ftpWriteTransferDone"); if (!(code == 226 || code == 250)) { - debug(9, 1) ("ftpReadTransferDone: Got code %d after sending data\n", - code); + debugs(9, 1, "ftpReadTransferDone: Got code " << code << " after sending data"); ftpState->failed(ERR_FTP_PUT_ERROR, 0); return; } @@ -2939,7 +2951,7 @@ FtpStateData::hackShortcut(FTPSM * nextState) static void ftpFail(FtpStateData *ftpState) { - debug(9, 3) ("ftpFail\n"); + debugs(9, 3, "ftpFail"); /* Try the / hack to support "Netscape" FTP URL's for retreiving files */ if (!ftpState->flags.isdir && /* Not a directory */ @@ -3064,11 +3076,10 @@ ftpSendReply(FtpStateData * ftpState) int code = ftpState->ctrl.replycode; http_status http_code; err_type err_code = ERR_NONE; - debug(9, 5) ("ftpSendReply: %s, code %d\n", - ftpState->entry->url(), code); + debugs(9, 5, "ftpSendReply: " << ftpState->entry->url() << ", code " << code ); if (cbdataReferenceValid(ftpState)) - debug(9, 5) ("ftpSendReply: ftpState (%p) is valid!\n", ftpState); + debugs(9, 5, "ftpSendReply: ftpState (" << ftpState << ") is valid!"); if (code == 226 || code == 250) { err_code = (ftpState->mdtm > 0) ? ERR_FTP_PUT_MODIFIED : ERR_FTP_PUT_CREATED; diff --git a/src/gopher.cc b/src/gopher.cc index 4b7515082f..3848ebdaa7 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.202 2007/04/21 07:14:14 wessels Exp $ + * $Id: gopher.cc,v 1.203 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -399,8 +399,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) xstrncpy(line, gopherState->buf, gopherState->len + 1); if (gopherState->len + len > TEMP_BUF_SIZE) { - debug(10, 1) ("GopherHTML: Buffer overflow. Lost some data on URL: %s\n", - entry->url()); + debugs(10, 1, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url() ); len = TEMP_BUF_SIZE - gopherState->len; } @@ -413,8 +412,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) /* copy it to temp buffer */ if (gopherState->len + len > TEMP_BUF_SIZE) { - debug(10, 1) ("GopherHTML: Buffer overflow. Lost some data on URL: %s\n", - entry->url()); + debugs(10, 1, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url() ); len = TEMP_BUF_SIZE - gopherState->len; } @@ -444,8 +442,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len) /* copy it to temp buffer */ if ((len - (pos - inbuf)) > TEMP_BUF_SIZE) { - debug(10, 1) ("GopherHTML: Buffer overflow. Lost some data on URL: %s\n", - entry->url()); + debugs(10, 1, "GopherHTML: Buffer overflow. Lost some data on URL: " << entry->url() ); len = TEMP_BUF_SIZE; } @@ -708,7 +705,7 @@ gopherTimeout(int fd, void *data) { GopherStateData *gopherState = (GopherStateData *)data; StoreEntry *entry = gopherState->entry; - debug(10, 4) ("gopherTimeout: FD %d: '%s'\n", fd, entry->url()); + debugs(10, 4, "gopherTimeout: FD " << fd << ": '" << entry->url() << "'" ); gopherState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, gopherState->fwd->request)); @@ -761,7 +758,7 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void kb_incr(&statCounter.server.other.kbytes_in, len); } - debug(10, 5) ("gopherReadReply: FD %d read len=%d\n", fd, (int)len); + debugs(10, 5, "gopherReadReply: FD " << fd << " read len=" << (int)len); if (flag == COMM_OK && len > 0) { commSetTimeout(fd, Config.Timeout.read, NULL, NULL); @@ -774,7 +771,7 @@ gopherReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void } if (flag != COMM_OK || len < 0) { - debug(50, 1) ("gopherReadReply: error reading: %s\n", xstrerror()); + debugs(50, 1, "gopherReadReply: error reading: " << xstrerror()); if (ignoreErrno(errno)) { do_next_read = 1; @@ -829,8 +826,7 @@ gopherSendComplete(int fd, char *buf, size_t size, comm_err_t errflag, int xerrn { GopherStateData *gopherState = (GopherStateData *) data; StoreEntry *entry = gopherState->entry; - debug(10, 5) ("gopherSendComplete: FD %d size: %d errflag: %d\n", - fd, (int) size, errflag); + debugs(10, 5, "gopherSendComplete: FD " << fd << " size: " << (int) size << " errflag: " << errflag); if (size > 0) { fd_bytes(fd, size, FD_WRITE); @@ -921,7 +917,7 @@ gopherSendRequest(int fd, void *data) snprintf(buf, 4096, "%s\r\n", gopherState->request); } - debug(10, 5) ("gopherSendRequest: FD %d\n", fd); + debugs(10, 5, "gopherSendRequest: FD " << fd); comm_write(fd, buf, strlen(buf), gopherSendComplete, gopherState, NULL); if (EBIT_TEST(gopherState->entry->flags, ENTRY_CACHABLE)) @@ -947,7 +943,7 @@ gopherStart(FwdState * fwd) gopherState->fwd = fwd; - debug(10, 3) ("gopherStart: %s\n", entry->url()); + debugs(10, 3, "gopherStart: " << entry->url() ); statCounter.server.all.requests++; diff --git a/src/helper.cc b/src/helper.cc index fefe816708..3d3adefb60 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -1,6 +1,6 @@ /* - * $Id: helper.cc,v 1.79 2007/04/06 12:15:51 serassio Exp $ + * $Id: helper.cc,v 1.80 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Harvest Derived? @@ -96,8 +96,7 @@ helperOpenServers(helper * hlp) else shortname = xstrdup(progname); - debug(84, 1) ("helperOpenServers: Starting %d '%s' processes\n", - hlp->n_to_start, shortname); + debugs(84, 1, "helperOpenServers: Starting " << hlp->n_to_start << " '" << shortname << "' processes"); procname = (char *)xmalloc(strlen(shortname) + 3); @@ -124,7 +123,7 @@ helperOpenServers(helper * hlp) &hIpc); if (pid < 0) { - debug(84, 1) ("WARNING: Cannot run '%s' process.\n", progname); + debugs(84, 1, "WARNING: Cannot run '" << progname << "' process."); continue; } @@ -198,8 +197,7 @@ helperStatefulOpenServers(statefulhelper * hlp) else shortname = xstrdup(progname); - debug(84, 1) ("helperStatefulOpenServers: Starting %d '%s' processes\n", - hlp->n_to_start, shortname); + debugs(84, 1, "helperStatefulOpenServers: Starting " << hlp->n_to_start << " '" << shortname << "' processes"); procname = (char *)xmalloc(strlen(shortname) + 3); @@ -226,7 +224,7 @@ helperStatefulOpenServers(statefulhelper * hlp) &hIpc); if (pid < 0) { - debug(84, 1) ("WARNING: Cannot run '%s' process.\n", progname); + debugs(84, 1, "WARNING: Cannot run '" << progname << "' process."); continue; } @@ -289,7 +287,7 @@ helperSubmit(helper * hlp, const char *buf, HLPCB * callback, void *data) helper_server *srv; if (hlp == NULL) { - debug(84, 3) ("helperSubmit: hlp == NULL\n"); + debugs(84, 3, "helperSubmit: hlp == NULL"); callback(data, NULL); return; } @@ -303,7 +301,7 @@ helperSubmit(helper * hlp, const char *buf, HLPCB * callback, void *data) else Enqueue(hlp, r); - debug(84, 9) ("helperSubmit: %s\n", buf); + debugs(84, 9, "helperSubmit: " << buf); } /* lastserver = "server last used as part of a deferred or reserved @@ -316,7 +314,7 @@ helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, v helper_stateful_server *srv; if (hlp == NULL) { - debug(84, 3) ("helperStatefulSubmit: hlp == NULL\n"); + debugs(84, 3, "helperStatefulSubmit: hlp == NULL"); callback(data, 0, NULL); return; } @@ -333,7 +331,7 @@ helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, v } if ((buf != NULL) && lastserver) { - debug(84, 5) ("StatefulSubmit with lastserver %p\n", lastserver); + debugs(84, 5, "StatefulSubmit with lastserver " << lastserver); /* the queue doesn't count for this assert because queued requests * have already gone through here and been tested. * It's legal to have deferred_requests == 0 and queue entries @@ -350,10 +348,10 @@ helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, v } if (!(lastserver->request)) { - debug(84, 5) ("StatefulSubmit dispatching\n"); + debugs(84, 5, "StatefulSubmit dispatching"); helperStatefulDispatch(lastserver, r); } else { - debug(84, 5) ("StatefulSubmit queuing\n"); + debugs(84, 5, "StatefulSubmit queuing"); StatefulServerEnqueue(lastserver, r); } } else { @@ -363,7 +361,7 @@ helperStatefulSubmit(statefulhelper * hlp, const char *buf, HLPSCB * callback, v StatefulEnqueue(hlp, r); } - debug(84, 9) ("helperStatefulSubmit: placeholder: '%d', buf '%s'.\n", r->placeholder, buf); + debugs(84, 9, "helperStatefulSubmit: placeholder: '" << r->placeholder << "', buf '" << buf << "'."); } helper_stateful_server * @@ -375,15 +373,15 @@ helperStatefulDefer(statefulhelper * hlp) if (hlp == NULL) { - debug(84, 3) ("helperStatefulDefer: hlp == NULL\n"); + debugs(84, 3, "helperStatefulDefer: hlp == NULL"); return NULL; } - debug(84, 5) ("helperStatefulDefer: Running servers %d.\n", hlp->n_running); + debugs(84, 5, "helperStatefulDefer: Running servers " << hlp->n_running << "."); if (hlp->n_running == 0) { - debug(84, 1) ("helperStatefulDefer: No running servers!. \n"); + debugs(84, 1, "helperStatefulDefer: No running servers!. "); return NULL; } @@ -418,7 +416,7 @@ helperStatefulDefer(statefulhelper * hlp) if (rv == NULL) { - debug(84, 1) ("helperStatefulDefer: None available.\n"); + debugs(84, 1, "helperStatefulDefer: None available."); return NULL; } @@ -455,8 +453,7 @@ helperStatefulReset(helper_stateful_server * srv) if (r != NULL) { /* reset attempt DURING an outstaning request */ - debug(84, 1) ("helperStatefulReset: RESET During request %s \n", - hlp->id_name); + debugs(84, 1, "helperStatefulReset: RESET During request " << hlp->id_name << " "); srv->flags.busy = 0; srv->roffset = 0; helperStatefulRequestFree(r); @@ -634,8 +631,7 @@ helperShutdown(helper * hlp) link = link->next; if (srv->flags.shutdown) { - debug(84, 3) ("helperShutdown: %s #%d has already SHUT DOWN.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " has already SHUT DOWN."); continue; } @@ -645,14 +641,12 @@ helperShutdown(helper * hlp) srv->flags.shutdown = 1; /* request it to shut itself down */ if (srv->flags.closing) { - debug(84, 3) ("helperShutdown: %s #%d is CLOSING.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is CLOSING."); continue; } if (srv->stats.pending) { - debug(84, 3) ("helperShutdown: %s #%d is BUSY.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is BUSY."); continue; } @@ -665,8 +659,7 @@ helperShutdown(helper * hlp) shutdown(srv->wfd, SD_BOTH); #endif - debug(84, 3) ("helperShutdown: %s #%d shutting down.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperShutdown: " << hlp->id_name << " #" << srv->index + 1 << " shutting down."); /* the rest of the details is dealt with in the helperServerFree * close handler */ @@ -676,9 +669,10 @@ helperShutdown(helper * hlp) if (hIpc) { if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) { getCurrentTime(); - debug(84, 1) ("helperShutdown: WARNING: %s #%d (%s,%ld) " - "didn't exit in 5 seconds\n", - hlp->id_name, no, hlp->cmdline->key, (long int)pid); + debugs(84, 1, "helperShutdown: WARNING: " << hlp->id_name << + " #" << no << " (" << hlp->cmdline->key << "," << + (long int)pid << ") didn't exit in 5 seconds"); + } CloseHandle(hIpc); @@ -706,8 +700,7 @@ helperStatefulShutdown(statefulhelper * hlp) link = link->next; if (srv->flags.shutdown) { - debug(84, 3) ("helperStatefulShutdown: %s #%d has already SHUT DOWN.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " has already SHUT DOWN."); continue; } @@ -716,26 +709,22 @@ helperStatefulShutdown(statefulhelper * hlp) srv->flags.shutdown = 1; /* request it to shut itself down */ if (srv->flags.busy) { - debug(84, 3) ("helperStatefulShutdown: %s #%d is BUSY.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is BUSY."); continue; } if (srv->flags.closing) { - debug(84, 3) ("helperStatefulShutdown: %s #%d is CLOSING.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is CLOSING."); continue; } if (srv->flags.reserved != S_HELPER_FREE) { - debug(84, 3) ("helperStatefulShutdown: %s #%d is RESERVED.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " is RESERVED."); continue; } if (srv->deferred_requests) { - debug(84, 3) ("helperStatefulShutdown: %s #%d has DEFERRED requests.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " has DEFERRED requests."); continue; } @@ -748,8 +737,8 @@ helperStatefulShutdown(statefulhelper * hlp) shutdown(srv->wfd, SD_BOTH); #endif - debug(84, 3) ("helperStatefulShutdown: %s #%d shutting down.\n", - hlp->id_name, srv->index + 1); + debugs(84, 3, "helperStatefulShutdown: " << hlp->id_name << " #" << srv->index + 1 << " shutting down."); + /* the rest of the details is dealt with in the helperStatefulServerFree * close handler */ @@ -759,9 +748,9 @@ helperStatefulShutdown(statefulhelper * hlp) if (hIpc) { if (WaitForSingleObject(hIpc, 5000) != WAIT_OBJECT_0) { getCurrentTime(); - debug(84, 1) ("helperShutdown: WARNING: %s #%d (%s,%ld) " - "didn't exit in 5 seconds\n", - hlp->id_name, no, hlp->cmdline->key, (long int)pid); + debugs(84, 1, "helperShutdown: WARNING: " << hlp->id_name << + " #" << no << " (" << hlp->cmdline->key << "," << + (long int)pid << ") didn't exit in 5 seconds"); } CloseHandle(hIpc); @@ -802,8 +791,8 @@ helperFree(helper * hlp) /* note, don't free hlp->name, it probably points to static memory */ if (hlp->queue.head) - debug(84, 0) ("WARNING: freeing %s helper with %d requests queued\n", - hlp->id_name, hlp->stats.queue_size); + debugs(84, 0, "WARNING: freeing " << hlp->id_name << " helper with " << + hlp->stats.queue_size << " requests queued"); cbdataFree(hlp); } @@ -816,8 +805,8 @@ helperStatefulFree(statefulhelper * hlp) /* note, don't free hlp->name, it probably points to static memory */ if (hlp->queue.head) - debug(84, 0) ("WARNING: freeing %s helper with %d requests queued\n", - hlp->id_name, hlp->stats.queue_size); + debugs(84, 0, "WARNING: freeing " << hlp->id_name << " helper with " << + hlp->stats.queue_size << " requests queued"); cbdataFree(hlp); } @@ -881,16 +870,16 @@ helperServerFree(int fd, void *data) if (!srv->flags.shutdown) { hlp->n_active--; assert(hlp->n_active >= 0); - debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n", - hlp->id_name, srv->index + 1, fd); + debugs(84, 0, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << + " (FD " << fd << ") exited"); if (hlp->n_active < hlp->n_to_start / 2) { - debug(80, 0) ("Too few %s processes are running\n", hlp->id_name); + debugs(80, 0, "Too few " << hlp->id_name << " processes are running"); if (hlp->last_restart > squid_curtime - 30) fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name); - debug(80, 0) ("Starting new helpers\n"); + debugs(80, 0, "Starting new helpers"); helperOpenServers(hlp); } @@ -944,16 +933,15 @@ helperStatefulServerFree(int fd, void *data) if (!srv->flags.shutdown) { hlp->n_active--; assert( hlp->n_active >= 0); - debug(84, 0) ("WARNING: %s #%d (FD %d) exited\n", - hlp->id_name, srv->index + 1, fd); + debugs(84, 0, "WARNING: " << hlp->id_name << " #" << srv->index + 1 << " (FD " << fd << ") exited"); if (hlp->n_active <= hlp->n_to_start / 2) { - debug(80, 0) ("Too few %s processes are running\n", hlp->id_name); + debugs(80, 0, "Too few " << hlp->id_name << " processes are running"); if (hlp->last_restart > squid_curtime - 30) fatalf("The %s helpers are crashing too rapidly, need help!\n", hlp->id_name); - debug(80, 0) ("Starting new helpers\n"); + debugs(80, 0, "Starting new helpers"); helperStatefulOpenServers(hlp); } @@ -983,12 +971,11 @@ helperHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, voi return; } - debug(84, 5) ("helperHandleRead: %d bytes from %s #%d.\n", - (int)len, hlp->id_name, srv->index + 1); + debugs(84, 5, "helperHandleRead: " << (int)len << " bytes from " << hlp->id_name << " #" << srv->index + 1 << "."); if (flag != COMM_OK || len <= 0) { if (len < 0) - debug(84, 1) ("helperHandleRead: FD %d read: %s\n", fd, xstrerror()); + debugs(84, 1, "helperHandleRead: FD " << fd << " read: " << xstrerror()); comm_close(fd); @@ -997,12 +984,14 @@ helperHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, voi srv->roffset += len; srv->rbuf[srv->roffset] = '\0'; - debug(84, 9) ("helperHandleRead: '%s'\n", srv->rbuf); + debugs(84, 9, "helperHandleRead: '" << srv->rbuf << "'"); if (!srv->stats.pending) { /* someone spoke without being spoken to */ - debug(84, 1) ("helperHandleRead: unexpected read from %s #%d, %d bytes '%s'\n", - hlp->id_name, srv->index + 1, (int)len, srv->rbuf); + debugs(84, 1, "helperHandleRead: unexpected read from " << + hlp->id_name << " #" << srv->index + 1 << ", " << (int)len << + " bytes '" << srv->rbuf << "'"); + srv->roffset = 0; srv->rbuf[0] = '\0'; } @@ -1012,7 +1001,7 @@ helperHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, voi helper_request *r; char *msg = srv->rbuf; int i = 0; - debug(84, 3) ("helperHandleRead: end of reply found\n"); + debugs(84, 3, "helperHandleRead: end of reply found"); if (t > srv->rbuf && t[-1] == '\r') t[-1] = '\0'; @@ -1054,8 +1043,10 @@ helperHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, voi helperRequestFree(r); } else { - debug(84, 1) ("helperHandleRead: unexpected reply on channel %d from %s #%d '%s'\n", - i, hlp->id_name, srv->index + 1, srv->rbuf); + debugs(84, 1, "helperHandleRead: unexpected reply on channel " << + i << " from " << hlp->id_name << " #" << srv->index + 1 << + " '" << srv->rbuf << "'"); + } srv->roffset -= (t - srv->rbuf); @@ -1089,12 +1080,13 @@ helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xer return; } - debug(84, 5) ("helperStatefulHandleRead: %d bytes from %s #%d.\n", - (int)len, hlp->id_name, srv->index + 1); + debugs(84, 5, "helperStatefulHandleRead: " << (int)len << " bytes from " << + hlp->id_name << " #" << srv->index + 1 << "."); + if (flag != COMM_OK || len <= 0) { if (len < 0) - debug(84, 1) ("helperStatefulHandleRead: FD %d read: %s\n", fd, xstrerror()); + debugs(84, 1, "helperStatefulHandleRead: FD " << fd << " read: " << xstrerror()); comm_close(fd); @@ -1107,14 +1099,16 @@ helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xer if (r == NULL) { /* someone spoke without being spoken to */ - debug(84, 1) ("helperStatefulHandleRead: unexpected read from %s #%d, %d bytes '%s'\n", - hlp->id_name, srv->index + 1, (int)len, srv->rbuf); + debugs(84, 1, "helperStatefulHandleRead: unexpected read from " << + hlp->id_name << " #" << srv->index + 1 << ", " << (int)len << + " bytes '" << srv->rbuf << "'"); + srv->roffset = 0; } if ((t = strchr(srv->rbuf, '\n'))) { /* end of reply found */ - debug(84, 3) ("helperStatefulHandleRead: end of reply found\n"); + debugs(84, 3, "helperStatefulHandleRead: end of reply found"); if (t > srv->rbuf && t[-1] == '\r') t[-1] = '\0'; @@ -1136,10 +1130,12 @@ helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xer if ((srv->parent->OnEmptyQueue != NULL) && (srv->data)) srv->parent->OnEmptyQueue(srv->data); - debug(84, 5) ("StatefulHandleRead: releasing %s #%d\n", hlp->id_name, srv->index + 1); + debugs(84, 5, "StatefulHandleRead: releasing " << hlp->id_name << " #" << srv->index + 1); } else { srv->flags.reserved = S_HELPER_DEFERRED; - debug(84, 5) ("StatefulHandleRead: outstanding deferred requests on %s #%d. reserving for deferred requests.\n", hlp->id_name, srv->index + 1); + debugs(84, 5, "StatefulHandleRead: outstanding deferred requests on " << + hlp->id_name << " #" << srv->index + 1 << + ". reserving for deferred requests."); } break; @@ -1149,7 +1145,7 @@ helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xer if (!srv->queue.head) { assert(srv->deferred_requests == 0); srv->flags.reserved = S_HELPER_RESERVED; - debug(84, 5) ("StatefulHandleRead: reserving %s #%d\n", hlp->id_name, srv->index + 1); + debugs(84, 5, "StatefulHandleRead: reserving " << hlp->id_name << " #" << srv->index + 1); } else { fatal("StatefulHandleRead: Callback routine attempted to reserve a stateful helper with deferred requests. This can lead to deadlock.\n"); } @@ -1163,7 +1159,7 @@ helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xer srv->flags.reserved = S_HELPER_DEFERRED; srv->deferred_requests++; srv->stats.deferbycb++; - debug(84, 5) ("StatefulHandleRead: reserving %s #%d for deferred requests.\n", hlp->id_name, srv->index + 1); + debugs(84, 5, "StatefulHandleRead: reserving " << hlp->id_name << " #" << srv->index + 1 << " for deferred requests."); break; default: @@ -1171,7 +1167,7 @@ helperStatefulHandleRead(int fd, char *buf, size_t len, comm_err_t flag, int xer } } else { - debug(84, 1) ("StatefulHandleRead: no callback data registered\n"); + debugs(84, 1, "StatefulHandleRead: no callback data registered"); } srv->flags.busy = 0; @@ -1222,14 +1218,15 @@ Enqueue(helper * hlp, helper_request * r) hlp->last_queue_warn = squid_curtime; - debug(84, 0) ("WARNING: All %s processes are busy.\n", hlp->id_name); + debugs(84, 0, "WARNING: All " << hlp->id_name << " processes are busy."); + debugs(84, 0, "WARNING: " << hlp->stats.queue_size << " pending requests queued"); - debug(84, 0) ("WARNING: %d pending requests queued\n", hlp->stats.queue_size); if (hlp->stats.queue_size > hlp->n_running * 2) fatalf("Too many queued %s requests", hlp->id_name); - debug(84, 1) ("Consider increasing the number of %s processes in your config file.\n", hlp->id_name); + debugs(84, 1, "Consider increasing the number of " << hlp->id_name << " processes in your config file."); + } static void @@ -1253,11 +1250,11 @@ StatefulEnqueue(statefulhelper * hlp, helper_stateful_request * r) hlp->last_queue_warn = squid_curtime; - debug(84, 0) ("WARNING: All %s processes are busy.\n", hlp->id_name); + debugs(84, 0, "WARNING: All " << hlp->id_name << " processes are busy."); - debug(84, 0) ("WARNING: %d pending requests queued\n", hlp->stats.queue_size); + debugs(84, 0, "WARNING: " << hlp->stats.queue_size << " pending requests queued"); + debugs(84, 1, "Consider increasing the number of " << hlp->id_name << " processes in your config file."); - debug(84, 1) ("Consider increasing the number of %s processes in your config file.\n", hlp->id_name); } static void @@ -1277,11 +1274,11 @@ StatefulServerEnqueue(helper_stateful_server * srv, helper_stateful_request * r) * if (shutting_down || reconfiguring) * return; * hlp->last_queue_warn = squid_curtime; - * debug(84, 0) ("WARNING: All %s processes are busy.\n", hlp->id_name); - * debug(84, 0) ("WARNING: %d pending requests queued\n", hlp->stats.queue_size); + * debugs(84, 0, "WARNING: All " << hlp->id_name << " processes are busy."); + * debugs(84, 0, "WARNING: " << hlp->stats.queue_size << " pending requests queued"); * if (hlp->stats.queue_size > hlp->n_running * 2) * fatalf("Too many queued %s requests", hlp->id_name); - * debug(84, 1) ("Consider increasing the number of %s processes in your config file.\n", hlp->id_name); */ + * debugs(84, 1, "Consider increasing the number of " << hlp->id_name << " processes in your config file." ); */ } @@ -1378,7 +1375,7 @@ StatefulGetFirstAvailable(statefulhelper * hlp) { dlink_node *n; helper_stateful_server *srv = NULL; - debug(84, 5) ("StatefulGetFirstAvailable: Running servers %d.\n", hlp->n_running); + debugs(84, 5, "StatefulGetFirstAvailable: Running servers " << hlp->n_running << "."); if (hlp->n_running == 0) return NULL; @@ -1401,7 +1398,7 @@ StatefulGetFirstAvailable(statefulhelper * hlp) return srv; } - debug(84, 5) ("StatefulGetFirstAvailable: None available.\n"); + debugs(84, 5, "StatefulGetFirstAvailable: None available."); return NULL; } @@ -1418,8 +1415,7 @@ helperDispatchWriteDone(int fd, char *buf, size_t len, comm_err_t flag, int xerr if (flag != COMM_OK) { /* Helper server has crashed */ - debug(84, 0) ("helperDispatch: Helper %s #%d has crashed\n", - srv->parent->id_name, srv->index + 1); + debugs(84, 0, "helperDispatch: Helper " << srv->parent->id_name << " #" << srv->index + 1 << " has crashed"); return; } @@ -1443,7 +1439,7 @@ helperDispatch(helper_server * srv, helper_request * r) unsigned int slot; if (!cbdataReferenceValid(r->data)) { - debug(84, 1) ("helperDispatch: invalid callback data\n"); + debugs(84, 1, "helperDispatch: invalid callback data"); helperRequestFree(r); return; } @@ -1480,8 +1476,8 @@ helperDispatch(helper_server * srv, helper_request * r) srv, NULL); /* Handler-data, free func */ } - debug(84, 5) ("helperDispatch: Request sent to %s #%d, %d bytes\n", - hlp->id_name, srv->index + 1, (int) strlen(r->buf)); + debugs(84, 5, "helperDispatch: Request sent to " << hlp->id_name << " #" << srv->index + 1 << ", " << (int) strlen(r->buf) << " bytes"); + srv->stats.uses++; hlp->stats.requests++; } @@ -1500,12 +1496,12 @@ helperStatefulDispatch(helper_stateful_server * srv, helper_stateful_request * r statefulhelper *hlp = srv->parent; if (!cbdataReferenceValid(r->data)) { - debug(84, 1) ("helperStatefulDispatch: invalid callback data\n"); + debugs(84, 1, "helperStatefulDispatch: invalid callback data"); helperStatefulRequestFree(r); return; } - debug(84, 9) ("helperStatefulDispatch busying helper %s #%d\n", hlp->id_name, srv->index + 1); + debugs(84, 9, "helperStatefulDispatch busying helper " << hlp->id_name << " #" << srv->index + 1); if (r->placeholder == 1) { /* a callback is needed before this request can _use_ a helper. */ @@ -1543,8 +1539,10 @@ helperStatefulDispatch(helper_stateful_server * srv, helper_stateful_request * r strlen(r->buf), helperStatefulDispatchWriteDone, /* Handler */ hlp, NULL); /* Handler-data, free func */ - debug(84, 5) ("helperStatefulDispatch: Request sent to %s #%d, %d bytes\n", - hlp->id_name, srv->index + 1, (int) strlen(r->buf)); + debugs(84, 5, "helperStatefulDispatch: Request sent to " << + hlp->id_name << " #" << srv->index + 1 << ", " << + (int) strlen(r->buf) << " bytes"); + srv->stats.uses++; hlp->stats.requests++; } diff --git a/src/htcp.cc b/src/htcp.cc index 2590e22afd..44624b1f4a 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -1,6 +1,6 @@ /* - * $Id: htcp.cc,v 1.74 2007/04/21 07:14:14 wessels Exp $ + * $Id: htcp.cc,v 1.75 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -310,7 +310,7 @@ htcpHexdump(const char *tag, const char *s, int sz) int i; int k; char hex[80]; - debug(31, 3) ("htcpHexdump %s\n", tag); + debugs(31, 3, "htcpHexdump " << tag); memset(hex, '\0', 80); for (i = 0; i < sz; i++) { @@ -320,7 +320,7 @@ htcpHexdump(const char *tag, const char *s, int sz) if (k < 15 && i < (sz - 1)) continue; - debug(31, 3) ("\t%s\n", hex); + debugs(31, 3, "\t" << hex); memset(hex, '\0', 80); } @@ -363,7 +363,7 @@ htcpBuildCountstr(char *buf, size_t buflen, const char *s) debugs(31, 3, "htcpBuildCountstr: LENGTH = " << len); - debug(31, 3) ("htcpBuildCountstr: TEXT = {%s}\n", s ? s : ""); + debugs(31, 3, "htcpBuildCountstr: TEXT = {" << (s ? s : "") << "}"); length = htons((u_int16_t) len); @@ -415,7 +415,7 @@ htcpBuildSpecifier(char *buf, size_t buflen, htcpStuff * stuff) off += s; - debug(31, 3) ("htcpBuildSpecifier: size %d\n", (int) off); + debugs(31, 3, "htcpBuildSpecifier: size " << (int) off); return off; } @@ -455,12 +455,12 @@ htcpBuildTstOpData(char *buf, size_t buflen, htcpStuff * stuff) switch (stuff->rr) { case RR_REQUEST: - debug(31, 3) ("htcpBuildTstOpData: RR_REQUEST\n"); + debugs(31, 3, "htcpBuildTstOpData: RR_REQUEST"); return htcpBuildSpecifier(buf, buflen, stuff); case RR_RESPONSE: - debug(31, 3) ("htcpBuildTstOpData: RR_RESPONSE\n"); - debug(31, 3) ("htcpBuildTstOpData: F1 = %d\n", stuff->f1); + debugs(31, 3, "htcpBuildTstOpData: RR_RESPONSE"); + debugs(31, 3, "htcpBuildTstOpData: F1 = " << stuff->f1); if (stuff->f1) /* cache miss */ return 0; @@ -478,8 +478,7 @@ static ssize_t htcpBuildOpData(char *buf, size_t buflen, htcpStuff * stuff) { ssize_t off = 0; - debug(31, 3) ("htcpBuildOpData: opcode %s\n", - htcpOpcodeStr[stuff->op]); + debugs(31, 3, "htcpBuildOpData: opcode " << htcpOpcodeStr[stuff->op]); switch (stuff->op) { @@ -519,7 +518,7 @@ htcpBuildData(char *buf, size_t buflen, htcpStuff * stuff) off += op_data_sz; - debug(31, 3) ("htcpBuildData: hdr.length = %d\n", (int) off); + debugs(31, 3, "htcpBuildData: hdr.length = " << (int) off); hdr.length = (u_int16_t) off; @@ -551,7 +550,7 @@ htcpBuildData(char *buf, size_t buflen, htcpStuff * stuff) xmemcpy(buf, &hdrSquid, hdr_sz); } - debug(31, 3) ("htcpBuildData: size %d\n", (int) off); + debugs(31, 3, "htcpBuildData: size " << (int) off); return off; } @@ -598,7 +597,7 @@ htcpBuildPacket(char *buf, size_t buflen, htcpStuff * stuff) xmemcpy(buf, &hdr, hdr_sz); - debug(31, 3) ("htcpBuildPacket: size %d\n", (int) off); + debugs(31, 3, "htcpBuildPacket: size " << (int) off); return off; } @@ -618,7 +617,7 @@ htcpSend(const char *buf, int len, struct sockaddr_in *to) len); if (x < 0) - debug(31, 1) ("htcpSend: FD %d sendto: %s\n", htcpOutSocket, xstrerror()); + debugs(31, 1, "htcpSend: FD " << htcpOutSocket << " sendto: " << xstrerror()); else statCounter.htcp.pkts_sent++; } @@ -670,7 +669,7 @@ htcpUnpackSpecifier(char *buf, int sz) buf += 2; if (l > sz) { - debug(31, 1) ("htcpUnpackSpecifier: failed to unpack METHOD\n"); + debugs(31, 1, "htcpUnpackSpecifier: failed to unpack METHOD"); htcpFreeSpecifier(s); return NULL; } @@ -688,7 +687,7 @@ htcpUnpackSpecifier(char *buf, int sz) sz -= 2; if (l > sz) { - debug(31, 1) ("htcpUnpackSpecifier: failed to unpack URI\n"); + debugs(31, 1, "htcpUnpackSpecifier: failed to unpack URI"); htcpFreeSpecifier(s); return NULL; } @@ -711,7 +710,7 @@ htcpUnpackSpecifier(char *buf, int sz) sz -= 2; if (l > sz) { - debug(31, 1) ("htcpUnpackSpecifier: failed to unpack VERSION\n"); + debugs(31, 1, "htcpUnpackSpecifier: failed to unpack VERSION"); htcpFreeSpecifier(s); return NULL; } @@ -734,7 +733,7 @@ htcpUnpackSpecifier(char *buf, int sz) sz -= 2; if (l > sz) { - debug(31, 1) ("htcpUnpackSpecifier: failed to unpack REQ-HDRS\n"); + debugs(31, 1, "htcpUnpackSpecifier: failed to unpack REQ-HDRS"); htcpFreeSpecifier(s); return NULL; } @@ -751,7 +750,7 @@ htcpUnpackSpecifier(char *buf, int sz) sz -= l; - debug(31, 3) ("htcpUnpackSpecifier: %d bytes left\n", sz); + debugs(31, 3, "htcpUnpackSpecifier: " << sz << " bytes left"); /* * Add terminating null to REQ-HDRS. This is possible because we allocated @@ -788,7 +787,7 @@ htcpUnpackDetail(char *buf, int sz) buf += 2; if (l > sz) { - debug(31, 1) ("htcpUnpackDetail: failed to unpack RESP_HDRS\n"); + debugs(31, 1, "htcpUnpackDetail: failed to unpack RESP_HDRS"); htcpFreeDetail(d); return NULL; } @@ -806,7 +805,7 @@ htcpUnpackDetail(char *buf, int sz) sz -= 2; if (l > sz) { - debug(31, 1) ("htcpUnpackDetail: failed to unpack ENTITY_HDRS\n"); + debugs(31, 1, "htcpUnpackDetail: failed to unpack ENTITY_HDRS"); htcpFreeDetail(d); return NULL; } @@ -829,7 +828,7 @@ htcpUnpackDetail(char *buf, int sz) sz -= 2; if (l > sz) { - debug(31, 1) ("htcpUnpackDetail: failed to unpack CACHE_HDRS\n"); + debugs(31, 1, "htcpUnpackDetail: failed to unpack CACHE_HDRS"); htcpFreeDetail(d); return NULL; } @@ -846,7 +845,7 @@ htcpUnpackDetail(char *buf, int sz) sz -= l; - debug(31, 3) ("htcpUnpackDetail: %d bytes left\n", sz); + debugs(31, 3, "htcpUnpackDetail: " << sz << " bytes left"); /* * Add terminating null to CACHE-HDRS. This is possible because we allocated @@ -892,7 +891,7 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct stuff.rr = RR_RESPONSE; stuff.f1 = 0; stuff.response = e ? 0 : 1; - debug(31, 3) ("htcpTstReply: response = %d\n", stuff.response); + debugs(31, 3, "htcpTstReply: response = " << stuff.response); stuff.msg_id = dhdr->msg_id; if (spec) @@ -908,7 +907,7 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct squid_curtime - e->timestamp : 0); hdr.packInto(&p); stuff.D.resp_hdrs = xstrdup(mb.buf); - debug(31, 3) ("htcpTstReply: resp_hdrs = {%s}\n", stuff.D.resp_hdrs); + debugs(31, 3, "htcpTstReply: resp_hdrs = {" << stuff.D.resp_hdrs << "}"); mb.reset(); hdr.reset(); @@ -922,7 +921,7 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct stuff.D.entity_hdrs = xstrdup(mb.buf); - debug(31, 3) ("htcpTstReply: entity_hdrs = {%s}\n", stuff.D.entity_hdrs); + debugs(31, 3, "htcpTstReply: entity_hdrs = {" << stuff.D.entity_hdrs << "}"); mb.reset(); @@ -940,7 +939,7 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct hdr.packInto(&p); stuff.D.cache_hdrs = xstrdup(mb.buf); - debug(31, 3) ("htcpTstReply: cache_hdrs = {%s}\n", stuff.D.cache_hdrs); + debugs(31, 3, "htcpTstReply: cache_hdrs = {" << stuff.D.cache_hdrs << "}"); mb.clean(); hdr.clean(); packerClean(&p); @@ -954,7 +953,7 @@ htcpTstReply(htcpDataHeader * dhdr, StoreEntry * e, htcpSpecifier * spec, struct if (!pktlen) { - debug(31, 1) ("htcpTstReply: htcpBuildPacket() failed\n"); + debugs(31, 1, "htcpTstReply: htcpBuildPacket() failed"); return; } @@ -984,7 +983,7 @@ htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, struct sockaddr_in *from stuff.response = purgeSucceeded ? 0 : 2; - debug(31, 3) ("htcpClrReply: response = %d\n", stuff.response); + debugs(31, 3, "htcpClrReply: response = " << stuff.response); stuff.msg_id = dhdr->msg_id; @@ -992,7 +991,7 @@ htcpClrReply(htcpDataHeader * dhdr, int purgeSucceeded, struct sockaddr_in *from if (pktlen == 0) { - debug(31, 1) ("htcpClrReply: htcpBuildPacket() failed\n"); + debugs(31, 1, "htcpClrReply: htcpBuildPacket() failed"); return; } @@ -1003,7 +1002,7 @@ static void htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) { - debug(31, 3) ("htcpHandleNop: Unimplemented\n"); + debugs(31, 3, "htcpHandleNop: Unimplemented"); } void @@ -1013,7 +1012,7 @@ htcpSpecifier::checkHit() checkHitRequest = request; if (NULL == checkHitRequest) { - debug(31, 3) ("htcpCheckHit: NO; failed to parse URL\n"); + debugs(31, 3, "htcpCheckHit: NO; failed to parse URL"); checkedHit(NullStoreEntry::getInstance()); return; } @@ -1021,7 +1020,7 @@ htcpSpecifier::checkHit() blk_end = req_hdrs + strlen(req_hdrs); if (!checkHitRequest->header.parse(req_hdrs, blk_end)) { - debug(31, 3) ("htcpCheckHit: NO; failed to parse request headers\n"); + debugs(31, 3, "htcpCheckHit: NO; failed to parse request headers"); delete checkHitRequest; checkHitRequest = NULL; checkedHit(NullStoreEntry::getInstance()); @@ -1038,21 +1037,21 @@ htcpSpecifier::created (StoreEntry *e) assert (e); if (e->isNull()) { - debug(31, 3) ("htcpCheckHit: NO; public object not found\n"); + debugs(31, 3, "htcpCheckHit: NO; public object not found"); goto miss; } if (!e->validToSend()) { - debug(31, 3) ("htcpCheckHit: NO; entry not valid to send\n"); + debugs(31, 3, "htcpCheckHit: NO; entry not valid to send" ); goto miss; } if (refreshCheckHTCP(e, checkHitRequest)) { - debug(31, 3) ("htcpCheckHit: NO; cached response is stale\n"); + debugs(31, 3, "htcpCheckHit: NO; cached response is stale"); goto miss; } - debug(31, 3) ("htcpCheckHit: YES!?\n"); + debugs(31, 3, "htcpCheckHit: YES!?"); hit = e; miss: @@ -1062,7 +1061,7 @@ miss: static void htcpClrStoreEntry(StoreEntry * e) { - debug(31, 4) ("htcpClrStoreEntry: Clearing store for entry: %s\n", e->url()); + debugs(31, 4, "htcpClrStoreEntry: Clearing store for entry: " << e->url() ); e->releaseRequest(); } @@ -1075,7 +1074,7 @@ htcpClrStore(const htcpSpecifier * s) int released = 0; if (request == NULL) { - debug(31, 3) ("htcpClrStore: failed to parse URL\n"); + debugs(31, 3, "htcpClrStore: failed to parse URL"); return -1; } @@ -1083,7 +1082,7 @@ htcpClrStore(const htcpSpecifier * s) blk_end = s->req_hdrs + strlen(s->req_hdrs); if (!request->header.parse(s->req_hdrs, blk_end)) { - debug(31, 2) ("htcpClrStore: failed to parse request headers\n"); + debugs(31, 2, "htcpClrStore: failed to parse request headers"); return -1; } @@ -1096,10 +1095,10 @@ htcpClrStore(const htcpSpecifier * s) } if (released) { - debug(31, 4) ("htcpClrStore: Cleared %d matching entries\n", released); + debugs(31, 4, "htcpClrStore: Cleared " << released << " matching entries"); return 1; } else { - debug(31, 4) ("htcpClrStore: No matching entry found\n"); + debugs(31, 4, "htcpClrStore: No matching entry found"); return 0; } } @@ -1108,7 +1107,7 @@ static void htcpHandleTst(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) { - debug(31, 3) ("htcpHandleTst: sz = %d\n", (int) sz); + debugs(31, 3, "htcpHandleTst: sz = " << (int) sz); if (hdr->RR == RR_REQUEST) htcpHandleTstRequest(hdr, buf, sz, from); @@ -1133,7 +1132,11 @@ htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_i if (queried_id[hdr->msg_id % N_QUERIED_KEYS] != hdr->msg_id) { - debug(31, 2) ("htcpHandleTstResponse: No matching query id '%d' (expected %d) from '%s'\n", hdr->msg_id, queried_id[hdr->msg_id % N_QUERIED_KEYS], inet_ntoa(from->sin_addr)); + debugs(31, 2, "htcpHandleTstResponse: No matching query id '" << + hdr->msg_id << "' (expected " << + queried_id[hdr->msg_id % N_QUERIED_KEYS] << ") from '" << + inet_ntoa(from->sin_addr) << "'"); + return; } @@ -1141,7 +1144,7 @@ htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_i if (!key) { - debug(31, 1) ("htcpHandleTstResponse: No query key for response id '%d' from '%s'\n", hdr->msg_id, inet_ntoa(from->sin_addr)); + debugs(31, 1, "htcpHandleTstResponse: No query key for response id '" << hdr->msg_id << "' from '" << inet_ntoa(from->sin_addr) << "'"); return; } @@ -1149,30 +1152,30 @@ htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_i if (peer->sin_addr.s_addr != from->sin_addr.s_addr || peer->sin_port != from->sin_port) { - debug(31, 1) ("htcpHandleTstResponse: Unexpected response source %s\n", inet_ntoa(from->sin_addr)); + debugs(31, 1, "htcpHandleTstResponse: Unexpected response source " << inet_ntoa(from->sin_addr)); return; } if (hdr->F1 == 1) { - debug(31, 2) ("htcpHandleTstResponse: error condition, F1/MO == 1\n"); + debugs(31, 2, "htcpHandleTstResponse: error condition, F1/MO == 1"); return; } htcpReply.msg_id = hdr->msg_id; - debug(31, 3) ("htcpHandleTstResponse: msg_id = %d\n", (int) htcpReply.msg_id); + debugs(31, 3, "htcpHandleTstResponse: msg_id = " << (int) htcpReply.msg_id); htcpReply.hit = hdr->response ? 0 : 1; if (hdr->F1) { - debug(31, 3) ("htcpHandleTstResponse: MISS\n"); + debugs(31, 3, "htcpHandleTstResponse: MISS"); } else { - debug(31, 3) ("htcpHandleTstResponse: HIT\n"); + debugs(31, 3, "htcpHandleTstResponse: HIT"); d = htcpUnpackDetail(buf, sz); if (d == NULL) { - debug(31, 1) ("htcpHandleTstResponse: bad DETAIL\n"); + debugs(31, 1, "htcpHandleTstResponse: bad DETAIL"); return; } @@ -1186,7 +1189,7 @@ htcpHandleTstResponse(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_i htcpReply.hdr.parse(t, t + strlen(t)); } - debug(31, 3) ("htcpHandleTstResponse: key (%p) %s\n", key, storeKeyText(key)); + debugs(31, 3, "htcpHandleTstResponse: key (" << key << ") " << storeKeyText(key)); neighborsHtcpReply(key, &htcpReply, from); htcpReply.hdr.clean(); @@ -1203,7 +1206,7 @@ htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct sockaddr_i if (sz == 0) { - debug(31, 3) ("htcpHandleTst: nothing to do\n"); + debugs(31, 3, "htcpHandleTst: nothing to do"); return; } @@ -1219,29 +1222,26 @@ htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct sockaddr_i if (NULL == s) { - debug(31, 2) ("htcpHandleTstRequest: htcpUnpackSpecifier failed\n"); + debugs(31, 2, "htcpHandleTstRequest: htcpUnpackSpecifier failed"); return; } if (!s->request) { - debug(31, 2) ("htcpHandleTstRequest: failed to parse request\n"); + debugs(31, 2, "htcpHandleTstRequest: failed to parse request"); htcpFreeSpecifier(s); return; } if (!htcpAccessCheck(Config.accessList.htcp, s, from)) { - debug(31, 2) ("htcpHandleTstRequest: Access denied\n"); + debugs(31, 2, "htcpHandleTstRequest: Access denied"); htcpFreeSpecifier(s); return; } - debug(31, 3) ("htcpHandleTstRequest: %s %s %s\n", - s->method, - s->uri, - s->version); - debug(31, 3) ("htcpHandleTstRequest: %s\n", s->req_hdrs); + debugs(31, 3, "htcpHandleTstRequest: " << s->method << " " << s->uri << " " << s->version); + debugs(31, 3, "htcpHandleTstRequest: " << s->req_hdrs); s->checkHit(); } @@ -1260,14 +1260,14 @@ static void htcpHandleMon(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) { - debug(31, 3) ("htcpHandleMon: Unimplemented\n"); + debugs(31, 3, "htcpHandleMon: Unimplemented"); } static void htcpHandleSet(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) { - debug(31, 3) ("htcpHandleSet: Unimplemented\n"); + debugs(31, 3, "htcpHandleSet: Unimplemented"); } static void @@ -1277,7 +1277,7 @@ htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) htcpSpecifier *s; /* buf[0/1] is reserved and reason */ int reason = buf[1] << 4; - debug(31, 3) ("htcpHandleClr: reason=%d\n", reason); + debugs(31, 3, "htcpHandleClr: reason=" << reason); buf += 2; sz -= 2; @@ -1285,7 +1285,7 @@ htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) if (sz == 0) { - debug(31, 4) ("htcpHandleClr: nothing to do\n"); + debugs(31, 4, "htcpHandleClr: nothing to do"); return; } @@ -1293,22 +1293,19 @@ htcpHandleClr(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from) if (NULL == s) { - debug(31, 3) ("htcpHandleClr: htcpUnpackSpecifier failed\n"); + debugs(31, 3, "htcpHandleClr: htcpUnpackSpecifier failed"); return; } if (!htcpAccessCheck(Config.accessList.htcp_clr, s, from)) { - debug(31, 2) ("htcpHandleClr: Access denied\n"); + debugs(31, 2, "htcpHandleClr: Access denied"); htcpFreeSpecifier(s); return; } - debug(31, 5) ("htcpHandleClr: %s %s %s\n", - s->method, - s->uri, - s->version); - debug(31, 5) ("htcpHandleClr: request headers: %s\n", s->req_hdrs); + debugs(31, 5, "htcpHandleClr: " << s->method << " " << s->uri << " " << s->version); + debugs(31, 5, "htcpHandleClr: request headers: " << s->req_hdrs); /* Release objects from cache * analog to clientPurgeRequest in client_side.c @@ -1340,7 +1337,7 @@ htcpHandleData(char *buf, int sz, struct sockaddr_in *from) if ((size_t)sz < sizeof(htcpDataHeader)) { - debug(31, 1) ("htcpHandleData: msg size less than htcpDataHeader size\n"); + debugs(31, 1, "htcpHandleData: msg size less than htcpDataHeader size"); return; } @@ -1362,27 +1359,24 @@ htcpHandleData(char *buf, int sz, struct sockaddr_in *from) hdr.length = ntohs(hdr.length); hdr.msg_id = ntohl(hdr.msg_id); - debug(31, 3) ("htcpHandleData: sz = %d\n", sz); - debug(31, 3) ("htcpHandleData: length = %d\n", (int) hdr.length); + debugs(31, 3, "htcpHandleData: sz = " << sz); + debugs(31, 3, "htcpHandleData: length = " << (int) hdr.length); if (hdr.opcode >= HTCP_END) { - debug(31, 1) ("htcpHandleData: client %s, opcode %d out of range\n", - inet_ntoa(from->sin_addr), - (int) hdr.opcode); + debugs(31, 1, "htcpHandleData: client " << inet_ntoa(from->sin_addr) << ", opcode " << (int) hdr.opcode << " out of range"); return; } - debug(31, 3) ("htcpHandleData: opcode = %d %s\n", - (int) hdr.opcode, htcpOpcodeStr[hdr.opcode]); - debug(31, 3) ("htcpHandleData: response = %d\n", (int) hdr.response); - debug(31, 3) ("htcpHandleData: F1 = %d\n", (int) hdr.F1); - debug(31, 3) ("htcpHandleData: RR = %d\n", (int) hdr.RR); - debug(31, 3) ("htcpHandleData: msg_id = %d\n", (int) hdr.msg_id); + debugs(31, 3, "htcpHandleData: opcode = " << (int) hdr.opcode << " " << htcpOpcodeStr[hdr.opcode]); + debugs(31, 3, "htcpHandleData: response = " << (int) hdr.response); + debugs(31, 3, "htcpHandleData: F1 = " << (int) hdr.F1); + debugs(31, 3, "htcpHandleData: RR = " << (int) hdr.RR); + debugs(31, 3, "htcpHandleData: msg_id = " << (int) hdr.msg_id); if (sz < hdr.length) { - debug(31, 1) ("htcpHandleData: sz < hdr.length\n"); + debugs(31, 1, "htcpHandleData: sz < hdr.length"); return; } @@ -1396,7 +1390,7 @@ htcpHandleData(char *buf, int sz, struct sockaddr_in *from) sz -= sizeof(htcpDataHeader); - debug(31, 3) ("htcpHandleData: sz = %d\n", sz); + debugs(31, 3, "htcpHandleData: sz = " << sz); htcpHexdump("htcpHandleData", buf, sz); @@ -1437,7 +1431,7 @@ htcpHandle(char *buf, int sz, struct sockaddr_in *from) if ((size_t)sz < sizeof(htcpHeader)) { - debug(31, 1) ("htcpHandle: msg size less than htcpHeader size\n"); + debugs(31, 1, "htcpHandle: msg size less than htcpHeader size"); return; } @@ -1450,25 +1444,25 @@ htcpHandle(char *buf, int sz, struct sockaddr_in *from) else old_squid_format = 0; - debug(31, 3) ("htcpHandle: htcpHdr.length = %d\n", (int) htcpHdr.length); - - debug(31, 3) ("htcpHandle: htcpHdr.major = %d\n", (int) htcpHdr.major); - - debug(31, 3) ("htcpHandle: htcpHdr.minor = %d\n", (int) htcpHdr.minor); + debugs(31, 3, "htcpHandle: htcpHdr.length = " << (int) htcpHdr.length); + debugs(31, 3, "htcpHandle: htcpHdr.major = " << (int) htcpHdr.major); + debugs(31, 3, "htcpHandle: htcpHdr.minor = " << (int) htcpHdr.minor); if (sz != htcpHdr.length) { - debug(31, 1) ("htcpHandle: sz/%d != htcpHdr.length/%d from %s:%d\n", - sz, htcpHdr.length, - inet_ntoa(from->sin_addr), (int) ntohs(from->sin_port)); + debugs(31, 1, "htcpHandle: sz/" << sz << " != htcpHdr.length/" << + htcpHdr.length << " from " << inet_ntoa(from->sin_addr) << ":" << + (int) ntohs(from->sin_port)); + return; } if (htcpHdr.major != 0) { - debug(31, 1) ("htcpHandle: Unknown major version %d from %s:%d\n", - htcpHdr.major, - inet_ntoa(from->sin_addr), (int) ntohs(from->sin_port)); + debugs(31, 1, "htcpHandle: Unknown major version " << htcpHdr.major << + " from " << inet_ntoa(from->sin_addr) << ":" << + (int) ntohs(from->sin_port)); + return; } @@ -1491,8 +1485,8 @@ htcpRecv(int fd, void *data) /* Receive up to 8191 bytes, leaving room for a null */ len = comm_udp_recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &from, &flen); - debug(31, 3) ("htcpRecv: FD %d, %d bytes from %s:%d\n", - fd, len, inet_ntoa(from.sin_addr), ntohs(from.sin_port)); + debugs(31, 3, "htcpRecv: FD " << fd << ", " << len << " bytes from " << + inet_ntoa(from.sin_addr) << ":" << ntohs(from.sin_port)); if (len) statCounter.htcp.pkts_recv++; @@ -1512,7 +1506,7 @@ void htcpInit(void) { if (Config.Port.htcp <= 0) { - debug(31, 1) ("HTCP Disabled.\n"); + debugs(31, 1, "HTCP Disabled."); return; } @@ -1530,8 +1524,7 @@ htcpInit(void) commSetSelect(htcpInSocket, COMM_SELECT_READ, htcpRecv, NULL, 0); - debug(31, 1) ("Accepting HTCP messages on port %d, FD %d.\n", - (int) Config.Port.htcp, htcpInSocket); + debugs(31, 1, "Accepting HTCP messages on port " << (int) Config.Port.htcp << ", FD " << htcpInSocket << "."); if (Config.Addrs.udp_outgoing.s_addr != no_addr.s_addr) { enter_suid(); @@ -1548,8 +1541,7 @@ htcpInit(void) commSetSelect(htcpOutSocket, COMM_SELECT_READ, htcpRecv, NULL, 0); - debug(31, 1) ("Outgoing HTCP messages on port %d, FD %d.\n", - (int) Config.Port.htcp, htcpOutSocket); + debugs(31, 1, "Outgoing HTCP messages on port " << (int) Config.Port.htcp << ", FD " << htcpOutSocket << "."); fd_note(htcpInSocket, "Incoming HTCP socket"); } else { @@ -1619,7 +1611,7 @@ htcpQuery(StoreEntry * e, HttpRequest * req, peer * p) mb.clean(); if (!pktlen) { - debug(31, 1) ("htcpQuery: htcpBuildPacket() failed\n"); + debugs(31, 1, "htcpQuery: htcpBuildPacket() failed"); return; } @@ -1628,7 +1620,7 @@ htcpQuery(StoreEntry * e, HttpRequest * req, peer * p) save_key = queried_keys[stuff.msg_id % N_QUERIED_KEYS]; storeKeyCopy(save_key, (const cache_key *)e->key); queried_addr[stuff.msg_id % N_QUERIED_KEYS] = p->in_addr; - debug(31, 3) ("htcpQuery: key (%p) %s\n", save_key, storeKeyText(save_key)); + debugs(31, 3, "htcpQuery: key (" << save_key << ") " << storeKeyText(save_key)); } /* @@ -1642,7 +1634,7 @@ htcpSocketShutdown(void) return; if (htcpInSocket != htcpOutSocket) { - debug(12, 1) ("FD %d Closing HTCP socket\n", htcpInSocket); + debugs(12, 1, "FD " << htcpInSocket << " Closing HTCP socket"); comm_close(htcpInSocket); } @@ -1674,7 +1666,7 @@ htcpSocketClose(void) htcpSocketShutdown(); if (htcpOutSocket > -1) { - debug(12, 1) ("FD %d Closing HTCP socket\n", htcpOutSocket); + debugs(12, 1, "FD " << htcpOutSocket << " Closing HTCP socket"); comm_close(htcpOutSocket); htcpOutSocket = -1; } diff --git a/src/http.cc b/src/http.cc index ed296d46f2..d2e5e54493 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.516 2007/04/24 23:13:25 wessels Exp $ + * $Id: http.cc,v 1.517 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -161,7 +161,7 @@ static void httpStateFree(int fd, void *data) { HttpStateData *httpState = static_cast(data); - debug(11,5)("httpStateFree: FD %d, httpState=%p\n", fd, data); + debugs(11, 5, "httpStateFree: FD " << fd << ", httpState=" << data); delete httpState; } @@ -182,7 +182,7 @@ httpTimeout(int fd, void *data) { HttpStateData *httpState = static_cast(data); StoreEntry *entry = httpState->entry; - debug(11, 4) ("httpTimeout: FD %d: '%s'\n", fd, entry->url()); + debugs(11, 4, "httpTimeout: FD " << fd << ": '" << entry->url() << "'" ); if (entry->store_status == STORE_PENDING) { httpState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, httpState->fwd->request)); @@ -467,7 +467,7 @@ HttpStateData::cacheableReply() */ if (!refreshIsCachable(entry)) { - debug(22, 3) ("refreshIsCachable() returned non-cacheable..\n"); + debugs(22, 3, "refreshIsCachable() returned non-cacheable.."); return 0; } @@ -646,7 +646,7 @@ httpMakeVaryMark(HttpRequest * request, HttpReply const * reply) vary.clean(); #endif - debug(11, 3) ("httpMakeVaryMark: %s\n", vstr.buf()); + debugs(11, 3, "httpMakeVaryMark: " << vstr.buf()); return vstr.buf(); } @@ -674,8 +674,8 @@ HttpStateData::keepaliveAccounting(HttpReply *reply) _peer->stats.n_keepalives_recv++; if (Config.onoff.detect_broken_server_pconns && reply->bodySize(request->method) == -1) { - debug(11, 1) ("keepaliveAccounting: Impossible keep-alive header from '%s'\n", entry->url()); - // debug(11, 2) ("GOT HTTP REPLY HDR:\n---------\n%s\n----------\n", readBuf->content()); + debugs(11, 1, "keepaliveAccounting: Impossible keep-alive header from '" << entry->url() << "'" ); + // debugs(11, 2, "GOT HTTP REPLY HDR:\n---------\n" << readBuf->content() << "\n----------" ); flags.keepalive_broken = 1; } } @@ -688,8 +688,7 @@ HttpStateData::checkDateSkew(HttpReply *reply) int skew = abs((int)(reply->date - squid_curtime)); if (skew > 86400) - debug(11, 3) ("%s's clock is skewed by %d seconds!\n", - request->host, skew); + debugs(11, 3, "" << request->host << "'s clock is skewed by " << skew << " seconds!"); } } @@ -707,7 +706,7 @@ HttpStateData::processReplyHeader() */ HttpReply *newrep = new HttpReply; Ctx ctx = ctx_enter(entry->mem_obj->url); - debug(11, 3) ("processReplyHeader: key '%s'\n", entry->getMD5Text()); + debugs(11, 3, "processReplyHeader: key '" << entry->getMD5Text() << "'"); assert(!flags.headers_parsed); @@ -734,8 +733,7 @@ HttpStateData::processReplyHeader() reply = HTTPMSGLOCK(newrep); - debug(11, 9) ("GOT HTTP REPLY HDR:\n---------\n%s\n----------\n", - readBuf->content()); + debugs(11, 9, "GOT HTTP REPLY HDR:\n---------\n" << readBuf->content() << "\n----------"); header_bytes_read = headersEnd(readBuf->content(), readBuf->contentSize()); readBuf->consume(header_bytes_read); @@ -791,7 +789,7 @@ HttpStateData::haveParsedReplyHeaders() entry->timestampsSet(); /* Check if object is cacheable or not based on reply code */ - debug(11, 3) ("haveParsedReplyHeaders: HTTP CODE: %d\n", getReply()->sline.status); + debugs(11, 3, "haveParsedReplyHeaders: HTTP CODE: " << getReply()->sline.status); if (neighbors_do_private_keys) httpMaybeRemovePublic(entry, getReply()->sline.status); @@ -885,9 +883,7 @@ HttpStateData::statusIfComplete() const * connection. */ if (!flags.request_sent) { - debug(11, 1) ("statusIfComplete: Request not yet fully sent \"%s %s\"\n", - RequestMethodStr[orig_request->method], - entry->url()); + debugs(11, 1, "statusIfComplete: Request not yet fully sent \"" << RequestMethodStr[orig_request->method] << " " << entry->url() << "\"" ); return COMPLETE_NONPERSISTENT_MSG; } @@ -912,19 +908,18 @@ HttpStateData::statusIfComplete() const HttpStateData::ConnectionStatus HttpStateData::persistentConnStatus() const { - debug(11, 3) ("persistentConnStatus: FD %d\n", fd); - debug(11, 5) ("persistentConnStatus: content_length=%d\n", - reply->content_length); + debugs(11, 3, "persistentConnStatus: FD " << fd); + debugs(11, 5, "persistentConnStatus: content_length=" << reply->content_length); /* If we haven't seen the end of reply headers, we are not done */ - debug(11,5)("persistentConnStatus: flags.headers_parsed=%d\n", flags.headers_parsed); + debugs(11, 5, "persistentConnStatus: flags.headers_parsed=" << flags.headers_parsed); if (!flags.headers_parsed) return INCOMPLETE_MSG; const int clen = reply->bodySize(request->method); - debug(11,5)("persistentConnStatus: clen=%d\n", clen); + debugs(11, 5, "persistentConnStatus: clen=" << clen); /* If the body size is unknown we must wait for EOF */ if (clen < 0) @@ -973,7 +968,7 @@ HttpStateData::readReply (size_t len, comm_err_t flag, int xerrno) */ if (flag == COMM_ERR_CLOSING) { - debug (11,3)("http socket closing\n"); + debugs(11, 3, "http socket closing"); return; } @@ -985,7 +980,7 @@ HttpStateData::readReply (size_t len, comm_err_t flag, int xerrno) errno = 0; /* prepare the read size for the next read (if any) */ - debug(11, 5) ("httpReadReply: FD %d: len %d.\n", fd, (int)len); + debugs(11, 5, "httpReadReply: FD " << fd << ": len " << (int)len << "."); if (flag == COMM_OK && len > 0) { readBuf->appended(len); @@ -1030,8 +1025,7 @@ HttpStateData::readReply (size_t len, comm_err_t flag, int xerrno) #endif if (flag != COMM_OK || len < 0) { - debug(50, 2) ("httpReadReply: FD %d: read failure: %s.\n", - fd, xstrerror()); + debugs(50, 2, "httpReadReply: FD " << fd << ": read failure: " << xstrerror() << "."); if (ignoreErrno(errno)) { flags.do_next_read = 1; @@ -1184,7 +1178,7 @@ HttpStateData::processReplyBody() switch (persistentConnStatus()) { case INCOMPLETE_MSG: - debug(11,5)("processReplyBody: INCOMPLETE_MSG\n"); + debugs(11, 5, "processReplyBody: INCOMPLETE_MSG"); /* Wait for more data or EOF condition */ if (flags.keepalive_broken) { @@ -1197,7 +1191,7 @@ HttpStateData::processReplyBody() break; case COMPLETE_PERSISTENT_MSG: - debug(11,5)("processReplyBody: COMPLETE_PERSISTENT_MSG\n"); + debugs(11, 5, "processReplyBody: COMPLETE_PERSISTENT_MSG"); /* yes we have to clear all these! */ commSetTimeout(fd, -1, NULL, NULL); flags.do_next_read = 0; @@ -1226,7 +1220,7 @@ HttpStateData::processReplyBody() return; case COMPLETE_NONPERSISTENT_MSG: - debug(11,5)("processReplyBody: COMPLETE_NONPERSISTENT_MSG\n"); + debugs(11, 5, "processReplyBody: COMPLETE_NONPERSISTENT_MSG"); serverComplete(); return; } @@ -1291,8 +1285,7 @@ void HttpStateData::SendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, int xerrno, void *data) { HttpStateData *httpState = static_cast(data); - debug(11, 5) ("httpSendComplete: FD %d: size %d: errflag %d.\n", - fd, (int) size, errflag); + debugs(11, 5, "httpSendComplete: FD " << fd << ": size " << (int) size << ": errflag " << errflag << "."); #if URL_CHECKSUM_DEBUG entry->mem_obj->checkUrlChecksum(); @@ -1574,11 +1567,10 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, void copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, String strConnection, HttpRequest * request, HttpRequest * orig_request, HttpHeader * hdr_out, int we_do_ranges, http_state_flags flags) { - debug(11, 5) ("httpBuildRequestHeader: %s: %s\n", - e->name.buf(), e->value.buf()); + debugs(11, 5, "httpBuildRequestHeader: " << e->name.buf() << ": " << e->value.buf()); if (!httpRequestHdrAllowed(e, &strConnection)) { - debug(11, 2) ("'%s' header denied by anonymize_headers configuration\n",+ e->name.buf()); + debugs(11, 2, "'" << e->name.buf() << "' header denied by anonymize_headers configuration"); return; } @@ -1717,8 +1709,9 @@ HttpStateData::decideIfWeDoRanges (HttpRequest * orig_request) || orig_request->range->offsetLimitExceeded()) result = false; - debug(11, 8) ("decideIfWeDoRanges: range specs: %p, cachable: %d; we_do_ranges: %d\n", - orig_request->range, orig_request->flags.cachable, result); + debugs(11, 8, "decideIfWeDoRanges: range specs: " << + orig_request->range << ", cachable: " << + orig_request->flags.cachable << "; we_do_ranges: " << result); return result; } @@ -1759,7 +1752,7 @@ HttpStateData::sendRequest() { MemBuf mb; - debug(11, 5) ("httpSendRequest: FD %d, request %p, this %p.\n", fd, request, this); + debugs(11, 5, "httpSendRequest: FD " << fd << ", request " << request << ", this " << this << "."); commSetTimeout(fd, Config.Timeout.lifetime, httpTimeout, this); flags.do_next_read = 1; @@ -1817,7 +1810,7 @@ HttpStateData::sendRequest() mb.init(); buildRequestPrefix(request, orig_request, entry, &mb, flags); - debug(11, 6) ("httpSendRequest: FD %d:\n%s\n", fd, mb.buf); + debugs(11, 6, "httpSendRequest: FD " << fd << ":\n" << mb.buf); comm_write_mbuf(fd, &mb, requestSender, this); return true; @@ -1826,13 +1819,11 @@ HttpStateData::sendRequest() void httpStart(FwdState *fwd) { - debug(11, 3) ("httpStart: \"%s %s\"\n", - RequestMethodStr[fwd->request->method], - fwd->entry->url()); + debugs(11, 3, "httpStart: \"" << RequestMethodStr[fwd->request->method] << " " << fwd->entry->url() << "\"" ); HttpStateData *httpState = new HttpStateData(fwd); if (!httpState->sendRequest()) { - debug(11, 3) ("httpStart: aborted"); + debugs(11, 3, "httpStart: aborted"); delete httpState; return; } @@ -1860,13 +1851,13 @@ HttpStateData::doneSendingRequestBody() /* cbdataReferenceDone() happens in either fastCheck() or ~ACLCheckList */ if (!Config.accessList.brokenPosts) { - debug(11, 5) ("doneSendingRequestBody: No brokenPosts list\n"); + debugs(11, 5, "doneSendingRequestBody: No brokenPosts list"); HttpStateData::SendComplete(fd, NULL, 0, COMM_OK, 0, this); } else if (!ch.fastCheck()) { - debug(11, 5) ("doneSendingRequestBody: didn't match brokenPosts\n"); + debugs(11, 5, "doneSendingRequestBody: didn't match brokenPosts"); HttpStateData::SendComplete(fd, NULL, 0, COMM_OK, 0, this); } else { - debug(11, 2) ("doneSendingRequestBody: matched brokenPosts\n"); + debugs(11, 2, "doneSendingRequestBody: matched brokenPosts"); comm_write(fd, "\r\n", 2, HttpStateData::SendComplete, this, NULL); } } @@ -1890,9 +1881,7 @@ HttpStateData::handleMoreRequestBodyAvailable() if (flags.headers_parsed && !flags.abuse_detected) { flags.abuse_detected = 1; - debug(11, 1) ("http handleMoreRequestBodyAvailable: Likely proxy abuse detected '%s' -> '%s'\n", - inet_ntoa(orig_request->client_addr), - entry->url()); + debugs(11, 1, "http handleMoreRequestBodyAvailable: Likely proxy abuse detected '" << inet_ntoa(orig_request->client_addr) << "' -> '" << entry->url() << "'" ); if (getReply()->sline.status == HTTP_INVALID_HEADER) { comm_close(fd); diff --git a/src/icmp.cc b/src/icmp.cc index 859c17c3ea..f4d31de57f 100644 --- a/src/icmp.cc +++ b/src/icmp.cc @@ -1,6 +1,6 @@ /* - * $Id: icmp.cc,v 1.90 2007/04/19 21:25:38 wessels Exp $ + * $Id: icmp.cc,v 1.91 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 37 ICMP Routines * AUTHOR: Duane Wessels @@ -94,7 +94,7 @@ icmpRecv(int unused1, void *unused2) 0); if (n < 0 && EAGAIN != errno) { - debug(37, 1) ("icmpRecv: recv: %s\n", xstrerror()); + debugs(37, 1, "icmpRecv: recv: " << xstrerror()); if (errno == ECONNREFUSED) icmpClose(); @@ -135,7 +135,7 @@ icmpRecv(int unused1, void *unused2) break; default: - debug(37, 1) ("icmpRecv: Bad opcode: %d\n", (int) preply.opcode); + debugs(37, 1, "icmpRecv: Bad opcode: " << (int) preply.opcode); break; } } @@ -148,20 +148,20 @@ icmpSend(pingerEchoData * pkt, int len) if (icmp_sock < 0) return; - debug(37, 2) ("icmpSend: to %s, opcode %d, len %d\n", - inet_ntoa(pkt->to), (int) pkt->opcode, pkt->psize); + debugs(37, 2, "icmpSend: to " << inet_ntoa(pkt->to) << ", opcode " << + (int) pkt->opcode << ", len " << pkt->psize); x = comm_udp_send(icmp_sock, (char *) pkt, len, 0); if (x < 0) { - debug(37, 1) ("icmpSend: send: %s\n", xstrerror()); + debugs(37, 1, "icmpSend: send: " << xstrerror()); if (errno == ECONNREFUSED || errno == EPIPE) { icmpClose(); return; } } else if (x != len) { - debug(37, 1) ("icmpSend: Wrote %d of %d bytes\n", x, len); + debugs(37, 1, "icmpSend: Wrote " << x << " of " << len << " bytes"); } } @@ -176,8 +176,8 @@ icmpHandleSourcePing(const struct sockaddr_in *from, const char *buf) xmemcpy(&header, buf, sizeof(icp_common_t)); url = buf + sizeof(icp_common_t); key = icpGetCacheKey(url, (int) header.reqnum); - debug(37, 3) ("icmpHandleSourcePing: from %s, key '%s'\n", - inet_ntoa(from->sin_addr), storeKeyText(key)); + debugs(37, 3, "icmpHandleSourcePing: from " << inet_ntoa(from->sin_addr) << ", key '" << storeKeyText(key) << "'"); + /* call neighborsUdpAck even if ping_status != PING_WAITING */ neighborsUdpAck(key, &header, from); } @@ -195,7 +195,7 @@ icmpSourcePing(struct IN_ADDR to, const icp_common_t * header, const char *url) char *payload; int len; int ulen; - debug(37, 3) ("icmpSourcePing: '%s'\n", url); + debugs(37, 3, "icmpSourcePing: '" << url << "'"); if ((ulen = strlen(url)) > MAX_URL) return; @@ -224,7 +224,7 @@ void icmpDomainPing(struct IN_ADDR to, const char *domain) { #if USE_ICMP - debug(37, 3) ("icmpDomainPing: '%s'\n", domain); + debugs(37, 3, "icmpDomainPing: '" << domain << "'"); icmpSendEcho(to, S_ICMP_DOM, domain, 0); #endif } @@ -264,11 +264,11 @@ icmpOpen(void) commSetTimeout(icmp_sock, -1, NULL, NULL); - debug(37, 1) ("Pinger socket opened on FD %d\n", icmp_sock); + debugs(37, 1, "Pinger socket opened on FD " << icmp_sock); #ifdef _SQUID_MSWIN_ - debug(37, 4) ("Pinger handle: 0x%x, PID: %d\n", (unsigned)hIpc, pid); + debugs(37, 4, "Pinger handle: 0x" << hex << (unsigned)hIpc << dec << ", PID: " << pid); #endif #endif @@ -282,7 +282,7 @@ icmpClose(void) if (icmp_sock < 0) return; - debug(37, 1) ("Closing Pinger socket on FD %d\n", icmp_sock); + debugs(37, 1, "Closing Pinger socket on FD " << icmp_sock); #ifdef _SQUID_MSWIN_ @@ -297,9 +297,7 @@ icmpClose(void) if (hIpc) { if (WaitForSingleObject(hIpc, 12000) != WAIT_OBJECT_0) { getCurrentTime(); - debug(37, 1) - ("icmpClose: WARNING: (pinger,%ld) didn't exit in 12 seconds\n", - (long int)pid); + debugs(37, 1, "icmpClose: WARNING: (pinger," << (long int)pid << ") didn't exit in 12 seconds"); } CloseHandle(hIpc); diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 5fb415c62d..72f04afa39 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -1,6 +1,6 @@ /* - * $Id: icp_v2.cc,v 1.97 2007/04/21 07:14:14 wessels Exp $ + * $Id: icp_v2.cc,v 1.98 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -131,7 +131,7 @@ void ICP2State::created (StoreEntry *newEntry) { StoreEntry *entry = newEntry->isNull () ? NULL : newEntry; - debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]); + debugs(12, 5, "icpHandleIcpV2: OPCODE " << icp_opcode_str[header.opcode]); icp_opcode codeToSend; if (icpCheckUdpHit(entry, request)) { @@ -264,12 +264,10 @@ icpUdpSend(int fd, int x; int len; len = (int) ntohs(msg->length); - debug(12, 5) ("icpUdpSend: FD %d sending %s, %d bytes to %s:%d\n", - fd, - icp_opcode_str[msg->opcode], - len, - inet_ntoa(to->sin_addr), - ntohs(to->sin_port)); + debugs(12, 5, "icpUdpSend: FD " << fd << " sending " << + icp_opcode_str[msg->opcode] << ", " << len << " bytes to " << + inet_ntoa(to->sin_addr) << ":" << ntohs(to->sin_port)); + x = comm_udp_sendto(fd, to, sizeof(*to), msg, len); if (x >= 0) @@ -380,8 +378,7 @@ void icpDenyAccess(struct sockaddr_in *from, char *url, int reqnum, int fd) { - debug(12, 2) ("icpDenyAccess: Access Denied for %s by %s.\n", - inet_ntoa(from->sin_addr), AclMatchedName); + debugs(12, 2, "icpDenyAccess: Access Denied for " << inet_ntoa(from->sin_addr) << " by " << AclMatchedName << "."); if (clientdbCutoffDenied(from->sin_addr)) { @@ -498,17 +495,14 @@ _icp_common_t::handleReply(char *buf, struct sockaddr_in *from) { if (neighbors_do_private_keys && reqnum == 0) { - debug(12, 0) ("icpHandleIcpV2: Neighbor %s returned reqnum = 0\n", - inet_ntoa(from->sin_addr)); - debug(12, 0) ("icpHandleIcpV2: Disabling use of private keys\n"); + debugs(12, 0, "icpHandleIcpV2: Neighbor " << inet_ntoa(from->sin_addr) << " returned reqnum = 0"); + debugs(12, 0, "icpHandleIcpV2: Disabling use of private keys"); neighbors_do_private_keys = 0; } char *url = buf + sizeof(icp_common_t); - debug(12, 3) ("icpHandleIcpV2: %s from %s for '%s'\n", - icp_opcode_str[opcode], - inet_ntoa(from->sin_addr), - url); + debugs(12, 3, "icpHandleIcpV2: " << icp_opcode_str[opcode] << " from " << inet_ntoa(from->sin_addr) << " for '" << url << "'"); + const cache_key *key = icpGetCacheKey(url, (int) reqnum); /* call neighborsUdpAck even if ping_status != PING_WAITING */ neighborsUdpAck(key, this, from); @@ -520,7 +514,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) { if (len <= 0) { - debug(12, 3) ("icpHandleIcpV2: ICP message is too small\n"); + debugs(12, 3, "icpHandleIcpV2: ICP message is too small"); return; } @@ -531,7 +525,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) if (len != header.length) { - debug(12, 3) ("icpHandleIcpV2: ICP message is too small\n"); + debugs(12, 3, "icpHandleIcpV2: ICP message is too small"); return; } @@ -565,8 +559,8 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) break; default: - debug(12, 0) ("icpHandleIcpV2: UNKNOWN OPCODE: %d from %s\n", - header.opcode, inet_ntoa(from.sin_addr)); + debugs(12, 0, "icpHandleIcpV2: UNKNOWN OPCODE: " << header.opcode << " from " << inet_ntoa(from.sin_addr)); + break; } } @@ -578,16 +572,14 @@ icpPktDump(icp_common_t * pkt) struct IN_ADDR a; - debug(12, 9) ("opcode: %3d %s\n", - (int) pkt->opcode, - icp_opcode_str[pkt->opcode]); - debug(12, 9) ("version: %-8d\n", (int) pkt->version); - debug(12, 9) ("length: %-8d\n", (int) ntohs(pkt->length)); - debug(12, 9) ("reqnum: %-8d\n", ntohl(pkt->reqnum)); - debug(12, 9) ("flags: %-8x\n", ntohl(pkt->flags)); + debugs(12, 9, "opcode: " << std::setw(3) << (int) pkt->opcode << " " << icp_opcode_str[pkt->opcode]); + debugs(12, 9, "version: "<< std::left << std::setw(8) << (int) pkt->version); + debugs(12, 9, "length: "<< std::left << std::setw(8) << (int) ntohs(pkt->length)); + debugs(12, 9, "reqnum: "<< std::left << std::setw(8) << ntohl(pkt->reqnum)); + debugs(12, 9, "flags: "<< std::left << std::hex << std::setw(8) << ntohl(pkt->flags)); a.s_addr = pkt->shostid; - debug(12, 9) ("shostid: %s\n", inet_ntoa(a)); - debug(12, 9) ("payload: %s\n", (char *) pkt + sizeof(icp_common_t)); + debugs(12, 9, "shostid: " << inet_ntoa(a)); + debugs(12, 9, "payload: " << (char *) pkt + sizeof(icp_common_t)); } #endif @@ -631,8 +623,7 @@ icpHandleUdp(int sock, void *data) if (errno != ECONNREFUSED && errno != EHOSTUNREACH) #endif - debug(50, 1) ("icpHandleUdp: FD %d recvfrom: %s\n", - sock, xstrerror()); + debugs(50, 1, "icpHandleUdp: FD " << sock << " recvfrom: " << xstrerror()); break; } @@ -640,17 +631,17 @@ icpHandleUdp(int sock, void *data) (*N)++; icpCount(buf, RECV, (size_t) len, 0); buf[len] = '\0'; - debug(12, 4) ("icpHandleUdp: FD %d: received %lu bytes from %s.\n", - sock, - (unsigned long int)len, - inet_ntoa(from.sin_addr)); + debugs(12, 4, "icpHandleUdp: FD " << sock << ": received " << + (unsigned long int)len << " bytes from " << + inet_ntoa(from.sin_addr) << "."); + #ifdef ICP_PACKET_DUMP icpPktDump(buf); #endif if ((size_t) len < sizeof(icp_common_t)) { - debug(12, 4) ("icpHandleUdp: Ignoring too-small UDP packet\n"); + debugs(12, 4, "icpHandleUdp: Ignoring too-small UDP packet"); break; } @@ -661,10 +652,8 @@ icpHandleUdp(int sock, void *data) else if (icp_version == ICP_VERSION_3) icpHandleIcpV3(sock, from, buf, len); else - debug(12, 1) ("WARNING: Unused ICP version %d received from %s:%d\n", - icp_version, - inet_ntoa(from.sin_addr), - ntohs(from.sin_port)); + debugs(12, 1, "WARNING: Unused ICP version " << icp_version << + " received from " << inet_ntoa(from.sin_addr) << ":" << ntohs(from.sin_port)); } } @@ -706,9 +695,10 @@ icpConnectionsOpen(void) for (s = Config.mcast_group_list; s; s = s->next) ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL); - debug(12, 1) ("Accepting ICP messages at %s, port %d, FD %d.\n", - inet_ntoa(Config.Addrs.udp_incoming), - (int) port, theInIcpConnection); + debugs(12, 1, "Accepting ICP messages at " << + inet_ntoa(Config.Addrs.udp_incoming) << ", port " << (int) port << + ", FD " << theInIcpConnection << "."); + if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) { enter_suid(); @@ -729,8 +719,7 @@ icpConnectionsOpen(void) NULL, 0); - debug(12, 1) ("Outgoing ICP messages on port %d, FD %d.\n", - (int) port, theOutIcpConnection); + debugs(12, 1, "Outgoing ICP messages on port " << (int) port << ", FD " << theOutIcpConnection << "."); fd_note(theOutIcpConnection, "Outgoing ICP socket"); @@ -748,8 +737,7 @@ icpConnectionsOpen(void) (struct sockaddr *) &xaddr, &len); if (x < 0) - debug(50, 1) ("theOutIcpConnection FD %d: getsockname: %s\n", - theOutIcpConnection, xstrerror()); + debugs(50, 1, "theOutIcpConnection FD " << theOutIcpConnection << ": getsockname: " << xstrerror()); else theOutICPAddr = xaddr.sin_addr; } @@ -765,7 +753,7 @@ icpConnectionShutdown(void) return; if (theInIcpConnection != theOutIcpConnection) { - debug(12, 1) ("FD %d Closing ICP connection\n", theInIcpConnection); + debugs(12, 1, "FD " << theInIcpConnection << " Closing ICP connection"); comm_close(theInIcpConnection); } @@ -794,7 +782,7 @@ icpConnectionClose(void) icpConnectionShutdown(); if (theOutIcpConnection > -1) { - debug(12, 1) ("FD %d Closing ICP connection\n", theOutIcpConnection); + debugs(12, 1, "FD " << theOutIcpConnection << " Closing ICP connection"); comm_close(theOutIcpConnection); theOutIcpConnection = -1; } diff --git a/src/icp_v3.cc b/src/icp_v3.cc index 2302f28d10..8b8c5874b7 100644 --- a/src/icp_v3.cc +++ b/src/icp_v3.cc @@ -1,6 +1,6 @@ /* - * $Id: icp_v3.cc,v 1.41 2007/04/19 20:21:34 wessels Exp $ + * $Id: icp_v3.cc,v 1.42 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -87,8 +87,7 @@ void ICP3State::created (StoreEntry *newEntry) { StoreEntry *entry = newEntry->isNull () ? NULL : newEntry; - debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n", - icp_opcode_str[header.opcode]); + debugs(12, 5, "icpHandleIcpV3: OPCODE " << icp_opcode_str[header.opcode]); icp_opcode codeToSend; if (icpCheckUdpHit(entry, request)) { @@ -110,7 +109,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) { if (len <= 0) { - debug(12, 3) ("icpHandleIcpV3: ICP message is too small\n"); + debugs(12, 3, "icpHandleIcpV3: ICP message is too small"); return; } @@ -121,7 +120,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) if (len != header.length) { - debug(12, 3) ("icpHandleIcpV3: ICP message is too small\n"); + debugs(12, 3, "icpHandleIcpV3: ICP message is too small"); return; } @@ -154,8 +153,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) break; default: - debug(12, 0) ("icpHandleIcpV3: UNKNOWN OPCODE: %d from %s\n", - header.opcode, inet_ntoa(from.sin_addr)); + debugs(12, 0, "icpHandleIcpV3: UNKNOWN OPCODE: " << header.opcode << " from " << inet_ntoa(from.sin_addr)); break; } } diff --git a/src/ident.cc b/src/ident.cc index d1d4b2dc82..178d875312 100644 --- a/src/ident.cc +++ b/src/ident.cc @@ -1,6 +1,6 @@ /* - * $Id: ident.cc,v 1.74 2006/09/19 07:56:57 adrian Exp $ + * $Id: ident.cc,v 1.75 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 30 Ident (RFC 931) * AUTHOR: Duane Wessels @@ -107,8 +107,8 @@ static void identTimeout(int fd, void *data) { IdentStateData *state = (IdentStateData *)data; - debug(30, 3) ("identTimeout: FD %d, %s\n", fd, - inet_ntoa(state->my_peer.sin_addr)); + debugs(30, 3, "identTimeout: FD " << fd << ", " << inet_ntoa(state->my_peer.sin_addr)); + comm_close(fd); } @@ -175,7 +175,7 @@ identReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void if ((t = strchr(buf, '\n'))) *t = '\0'; - debug(30, 5) ("identReadReply: FD %d: Read '%s'\n", fd, buf); + debugs(30, 5, "identReadReply: FD " << fd << ": Read '" << buf << "'"); if (strstr(buf, "USERID")) { if ((ident = strrchr(buf, ':'))) { diff --git a/src/internal.cc b/src/internal.cc index 38e786a6a4..37aa418a4b 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -1,6 +1,6 @@ /* - * $Id: internal.cc,v 1.44 2007/04/21 07:14:14 wessels Exp $ + * $Id: internal.cc,v 1.45 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 76 Internal Squid Object handling * AUTHOR: Duane, Alex, Henrik @@ -51,8 +51,7 @@ internalStart(HttpRequest * request, StoreEntry * entry) { ErrorState *err; const char *upath = request->urlpath.buf(); - debug(76, 3) ("internalStart: %s requesting '%s'\n", - inet_ntoa(request->client_addr), upath); + debugs(76, 3, "internalStart: " << inet_ntoa(request->client_addr) << " requesting '" << upath << "'"); if (0 == strcmp(upath, "/squid-internal-dynamic/netdb")) { netdbBinaryExchange(entry); diff --git a/src/ipc.cc b/src/ipc.cc index 5e921a957d..42392e0f2b 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -1,6 +1,6 @@ /* - * $Id: ipc.cc,v 1.44 2006/09/03 19:28:10 serassio Exp $ + * $Id: ipc.cc,v 1.45 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 54 Interprocess Communication * AUTHOR: Duane Wessels @@ -135,12 +135,12 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name int c2p[2]; if (pipe(p2c) < 0) { - debug(54, 0) ("ipcCreate: pipe: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: pipe: " << xstrerror()); return -1; } if (pipe(c2p) < 0) { - debug(54, 0) ("ipcCreate: pipe: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: pipe: " << xstrerror()); return -1; } @@ -155,7 +155,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name int buflen = 32768; if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0) { - debug(54, 0) ("ipcCreate: socketpair: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: socketpair: " << xstrerror()); return -1; } @@ -169,7 +169,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name int fds[2]; if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fds) < 0) { - debug(54, 0) ("ipcCreate: socketpair: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: socketpair: " << xstrerror()); return -1; } @@ -181,18 +181,18 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name assert(IPC_NONE); } - debug(54, 3) ("ipcCreate: prfd FD %d\n", prfd); - debug(54, 3) ("ipcCreate: pwfd FD %d\n", pwfd); - debug(54, 3) ("ipcCreate: crfd FD %d\n", crfd); - debug(54, 3) ("ipcCreate: cwfd FD %d\n", cwfd); + debugs(54, 3, "ipcCreate: prfd FD " << prfd); + debugs(54, 3, "ipcCreate: pwfd FD " << pwfd); + debugs(54, 3, "ipcCreate: crfd FD " << crfd); + debugs(54, 3, "ipcCreate: cwfd FD " << cwfd); if (crfd < 0) { - debug(54, 0) ("ipcCreate: Failed to create child FD.\n"); + debugs(54, 0, "ipcCreate: Failed to create child FD."); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } if (pwfd < 0) { - debug(54, 0) ("ipcCreate: Failed to create server FD.\n"); + debugs(54, 0, "ipcCreate: Failed to create server FD."); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } @@ -201,38 +201,38 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name memset(&PaS, '\0', len); if (getsockname(pwfd, (struct sockaddr *) &PaS, &len) < 0) { - debug(54, 0) ("ipcCreate: getsockname: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: getsockname: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } - debug(54, 3) ("ipcCreate: FD %d sockaddr %s:%d\n", - pwfd, inet_ntoa(PaS.sin_addr), ntohs(PaS.sin_port)); + debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << inet_ntoa(PaS.sin_addr) << ":" << ntohs(PaS.sin_port)); + len = sizeof(ChS); memset(&ChS, '\0', len); if (getsockname(crfd, (struct sockaddr *) &ChS, &len) < 0) { - debug(54, 0) ("ipcCreate: getsockname: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: getsockname: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } - debug(54, 3) ("ipcCreate: FD %d sockaddr %s:%d\n", - crfd, inet_ntoa(ChS.sin_addr), ntohs(ChS.sin_port)); + debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << inet_ntoa(ChS.sin_addr) << ":" << ntohs(ChS.sin_port)); + } if (type == IPC_TCP_SOCKET) { if (listen(crfd, 1) < 0) { - debug(54, 1) ("ipcCreate: listen FD %d: %s\n", crfd, xstrerror()); + debugs(54, 1, "ipcCreate: listen FD " << crfd << ": " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } - debug(54, 3) ("ipcCreate: FD %d listening...\n", crfd); + debugs(54, 3, "ipcCreate: FD " << crfd << " listening..."); } /* flush or else we get dup data if unbuffered_logs is set */ logsFlush(); if ((pid = fork()) < 0) { - debug(54, 1) ("ipcCreate: fork: %s\n", xstrerror()); + debugs(54, 1, "ipcCreate: fork: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } @@ -258,13 +258,13 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name x = read(prfd, hello_buf, HELLO_BUF_SZ - 1); if (x < 0) { - debug(54, 0) ("ipcCreate: PARENT: hello read test failed\n"); - debug(54, 0) ("--> read: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: PARENT: hello read test failed"); + debugs(54, 0, "--> read: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } else if (strcmp(hello_buf, hello_string)) { - debug(54, 0) ("ipcCreate: PARENT: hello read test failed\n"); - debug(54, 0) ("--> read returned %d\n", x); - debug(54, 0) ("--> got '%s'\n", rfc1738_escape(hello_buf)); + debugs(54, 0, "ipcCreate: PARENT: hello read test failed"); + debugs(54, 0, "--> read returned " << x); + debugs(54, 0, "--> got '" << rfc1738_escape(hello_buf) << "'"); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } @@ -306,14 +306,14 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name pwfd = prfd = -1; if (type == IPC_TCP_SOCKET) { - debug(54, 3) ("ipcCreate: calling accept on FD %d\n", crfd); + debugs(54, 3, "ipcCreate: calling accept on FD " << crfd); if ((fd = accept(crfd, NULL, NULL)) < 0) { - debug(54, 0) ("ipcCreate: FD %d accept: %s\n", crfd, xstrerror()); + debugs(54, 0, "ipcCreate: FD " << crfd << " accept: " << xstrerror()); _exit(1); } - debug(54, 3) ("ipcCreate: CHILD accepted new FD %d\n", fd); + debugs(54, 3, "ipcCreate: CHILD accepted new FD " << fd); close(crfd); cwfd = crfd = fd; } else if (type == IPC_UDP_SOCKET) { @@ -325,14 +325,14 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name x = comm_udp_send(cwfd, hello_string, strlen(hello_string) + 1, 0); if (x < 0) { - debug(54, 0) ("sendto FD %d: %s\n", cwfd, xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: hello write test failed\n"); + debugs(54, 0, "sendto FD " << cwfd << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: hello write test failed"); _exit(1); } } else { if (write(cwfd, hello_string, strlen(hello_string) + 1) < 0) { - debug(54, 0) ("write FD %d: %s\n", cwfd, xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: hello write test failed\n"); + debugs(54, 0, "write FD " << cwfd << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: hello write test failed"); _exit(1); } } @@ -390,7 +390,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name debug_log = fdopen(2, "a+"); - debug(54, 0) ("ipcCreate: %s: %s\n", prog, xstrerror()); + debugs(54, 0, "ipcCreate: " << prog << ": " << xstrerror()); _exit(1); diff --git a/src/ipc_win32.cc b/src/ipc_win32.cc index 0f195f65a8..6e7f0c4ef9 100755 --- a/src/ipc_win32.cc +++ b/src/ipc_win32.cc @@ -1,6 +1,6 @@ /* - * $Id: ipc_win32.cc,v 1.2 2006/09/09 15:29:59 serassio Exp $ + * $Id: ipc_win32.cc,v 1.3 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 54 Windows Interprocess Communication * AUTHOR: Andrey Shorin @@ -172,18 +172,16 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name 0, name); } else if (type == IPC_FIFO) { - debug(54, 0) - ("ipcCreate: %s: use IPC_TCP_SOCKET instead of IP_FIFO on Windows\n", - prog); + debugs(54, 0, "ipcCreate: " << prog << ": use IPC_TCP_SOCKET instead of IP_FIFO on Windows"); assert(0); } else { assert(IPC_NONE); } - debug(54, 3) ("ipcCreate: prfd FD %d\n", prfd); - debug(54, 3) ("ipcCreate: pwfd FD %d\n", pwfd); - debug(54, 3) ("ipcCreate: crfd FD %d\n", crfd); - debug(54, 3) ("ipcCreate: cwfd FD %d\n", cwfd); + debugs(54, 3, "ipcCreate: prfd FD " << prfd); + debugs(54, 3, "ipcCreate: pwfd FD " << pwfd); + debugs(54, 3, "ipcCreate: crfd FD " << crfd); + debugs(54, 3, "ipcCreate: cwfd FD " << cwfd); if (WIN32_OS_version != _WIN_OS_WINNT) { getsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *) &opt, &optlen); @@ -192,12 +190,12 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name } if (crfd < 0) { - debug(54, 0) ("ipcCreate: Failed to create child FD.\n"); + debugs(54, 0, "ipcCreate: Failed to create child FD."); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } if (pwfd < 0) { - debug(54, 0) ("ipcCreate: Failed to create server FD.\n"); + debugs(54, 0, "ipcCreate: Failed to create server FD."); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } @@ -206,31 +204,29 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name memset(&PS, '\0', len); if (getsockname(pwfd, (struct sockaddr *) &PS, &len) < 0) { - debug(54, 0) ("ipcCreate: getsockname: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: getsockname: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } - debug(54, 3) ("ipcCreate: FD %d sockaddr %s:%d\n", - pwfd, inet_ntoa(PS.sin_addr), ntohs(PS.sin_port)); + debugs(54, 3, "ipcCreate: FD " << pwfd << " sockaddr " << inet_ntoa(PS.sin_addr) << ":" << ntohs(PS.sin_port)); len = sizeof(CS); memset(&CS, '\0', len); if (getsockname(crfd, (struct sockaddr *) &CS, &len) < 0) { - debug(54, 0) ("ipcCreate: getsockname: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: getsockname: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } - debug(54, 3) ("ipcCreate: FD %d sockaddr %s:%d\n", - crfd, inet_ntoa(CS.sin_addr), ntohs(CS.sin_port)); + debugs(54, 3, "ipcCreate: FD " << crfd << " sockaddr " << inet_ntoa(CS.sin_addr) << ":" << ntohs(CS.sin_port)); } if (type == IPC_TCP_SOCKET) { if (listen(crfd, 1) < 0) { - debug(54, 1) ("ipcCreate: listen FD %d: %s\n", crfd, xstrerror()); + debugs(54, 1, "ipcCreate: listen FD " << crfd << ": " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } - debug(54, 3) ("ipcCreate: FD %d listening...\n", crfd); + debugs(54, 3, "ipcCreate: FD " << crfd << " listening..."); } /* flush or else we get dup data if unbuffered_logs is set */ @@ -251,7 +247,7 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name thread = _beginthreadex(NULL, 0, ipc_thread_1, ¶ms, 0, NULL); if (thread == 0) { - debug(54, 1) ("ipcCreate: _beginthread: %s\n", xstrerror()); + debugs(54, 1, "ipcCreate: _beginthread: " << xstrerror()); return ipcCloseAllFD(prfd, pwfd, crfd, cwfd); } @@ -264,14 +260,14 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name x = recv(prfd, (void *)hello_buf, HELLO_BUF_SZ - 1, 0); if (x < 0) { - debug(54, 0) ("ipcCreate: PARENT: hello read test failed\n"); - debug(54, 0) ("--> read: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: PARENT: hello read test failed"); + debugs(54, 0, "--> read: " << xstrerror()); CloseHandle((HANDLE) thread); return ipcCloseAllFD(prfd, pwfd, -1, -1); } else if (strcmp(hello_buf, hello_string)) { - debug(54, 0) ("ipcCreate: PARENT: hello read test failed\n"); - debug(54, 0) ("--> read returned %d\n", x); - debug(54, 0) ("--> got '%s'\n", rfc1738_escape(hello_buf)); + debugs(54, 0, "ipcCreate: PARENT: hello read test failed"); + debugs(54, 0, "--> read returned " << x); + debugs(54, 0, "--> got '" << rfc1738_escape(hello_buf) << "'"); CloseHandle((HANDLE) thread); return ipcCloseAllFD(prfd, pwfd, -1, -1); } @@ -279,8 +275,8 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name x = send(pwfd, (const void *)ok_string, strlen(ok_string), 0); if (x < 0) { - debug(54, 0) ("ipcCreate: PARENT: OK write test failed\n"); - debug(54, 0) ("--> read: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: PARENT: OK write test failed"); + debugs(54, 0, "--> read: " << xstrerror()); CloseHandle((HANDLE) thread); return ipcCloseAllFD(prfd, pwfd, -1, -1); } @@ -289,14 +285,14 @@ ipcCreate(int type, const char *prog, const char *const args[], const char *name x = recv(prfd, (void *)hello_buf, HELLO_BUF_SZ - 1, 0); if (x < 0) { - debug(54, 0) ("ipcCreate: PARENT: OK read test failed\n"); - debug(54, 0) ("--> read: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: PARENT: OK read test failed"); + debugs(54, 0, "--> read: " << xstrerror()); CloseHandle((HANDLE) thread); return ipcCloseAllFD(prfd, pwfd, -1, -1); } else if (!strcmp(hello_buf, err_string)) { - debug(54, 0) ("ipcCreate: PARENT: OK read test failed\n"); - debug(54, 0) ("--> read returned %d\n", x); - debug(54, 0) ("--> got '%s'\n", rfc1738_escape(hello_buf)); + debugs(54, 0, "ipcCreate: PARENT: OK read test failed"); + debugs(54, 0, "--> read returned " << x); + debugs(54, 0, "--> got '" << rfc1738_escape(hello_buf) << "'"); CloseHandle((HANDLE) thread); return ipcCloseAllFD(prfd, pwfd, -1, -1); } @@ -353,8 +349,8 @@ ipcSend(int cwfd, const char *buf, int len) x = send(cwfd, (const void *)buf, len, 0); if (x < 0) { - debug(54, 0) ("sendto FD %d: %s\n", cwfd, xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: hello write test failed\n"); + debugs(54, 0, "sendto FD " << cwfd << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: hello write test failed"); } return x; @@ -405,14 +401,14 @@ ipc_thread_1(void *in_params) prog = xstrdup(prog); if (type == IPC_TCP_SOCKET) { - debug(54, 3) ("ipcCreate: calling accept on FD %d\n", crfd); + debugs(54, 3, "ipcCreate: calling accept on FD " << crfd); if ((fd = accept(crfd, NULL, NULL)) < 0) { - debug(54, 0) ("ipcCreate: FD %d accept: %s\n", crfd, xstrerror()); + debugs(54, 0, "ipcCreate: FD " << crfd << " accept: " << xstrerror()); goto cleanup; } - debug(54, 3) ("ipcCreate: CHILD accepted new FD %d\n", fd); + debugs(54, 3, "ipcCreate: CHILD accepted new FD " << fd); comm_close(crfd); snprintf(buf1, 8191, "%s CHILD socket", prog); fd_open(fd, FD_SOCKET, buf1); @@ -426,8 +422,8 @@ ipc_thread_1(void *in_params) x = send(cwfd, (const void *)hello_string, strlen(hello_string) + 1, 0); if (x < 0) { - debug(54, 0) ("sendto FD %d: %s\n", cwfd, xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: hello write test failed\n"); + debugs(54, 0, "sendto FD " << cwfd << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: hello write test failed"); goto cleanup; } @@ -436,25 +432,25 @@ ipc_thread_1(void *in_params) x = recv(crfd, (void *)buf1, 8191, 0); if (x < 0) { - debug(54, 0) ("ipcCreate: CHILD: OK read test failed\n"); - debug(54, 0) ("--> read: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: OK read test failed"); + debugs(54, 0, "--> read: " << xstrerror()); goto cleanup; } else if (strcmp(buf1, ok_string)) { - debug(54, 0) ("ipcCreate: CHILD: OK read test failed\n"); - debug(54, 0) ("--> read returned %d\n", x); - debug(54, 0) ("--> got '%s'\n", rfc1738_escape(hello_buf)); + debugs(54, 0, "ipcCreate: CHILD: OK read test failed"); + debugs(54, 0, "--> read returned " << x); + debugs(54, 0, "--> got '" << rfc1738_escape(hello_buf) << "'"); goto cleanup; } /* assign file descriptors to child process */ if (_pipe(p2c, 1024, _O_BINARY | _O_NOINHERIT) < 0) { - debug(54, 0) ("ipcCreate: CHILD: pipe: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: pipe: " << xstrerror()); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } if (_pipe(c2p, 1024, _O_BINARY | _O_NOINHERIT) < 0) { - debug(54, 0) ("ipcCreate: CHILD: pipe: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: pipe: " << xstrerror()); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -464,8 +460,7 @@ ipc_thread_1(void *in_params) crfd_ipc = cwfd_ipc = comm_open(SOCK_DGRAM, IPPROTO_UDP, local_addr, 0, 0, buf1); if (crfd_ipc < 0) { - debug(54, 0) ("ipcCreate: CHILD: Failed to create child FD for %s.\n", - prog); + debugs(54, 0, "ipcCreate: CHILD: Failed to create child FD for " << prog << "."); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -474,8 +469,7 @@ ipc_thread_1(void *in_params) prfd_ipc = pwfd_ipc = comm_open(SOCK_DGRAM, IPPROTO_UDP, local_addr, 0, 0, buf1); if (pwfd_ipc < 0) { - debug(54, 0) ("ipcCreate: CHILD: Failed to create server FD for %s.\n", - prog); + debugs(54, 0, "ipcCreate: CHILD: Failed to create server FD for " << prog << "."); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -484,24 +478,23 @@ ipc_thread_1(void *in_params) memset(&PS_ipc, '\0', tmp_s); if (getsockname(pwfd_ipc, (struct sockaddr *) &PS_ipc, &tmp_s) < 0) { - debug(54, 0) ("ipcCreate: getsockname: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: getsockname: " << xstrerror()); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } - debug(54, 3) ("ipcCreate: FD %d sockaddr %s:%d\n", - pwfd_ipc, inet_ntoa(PS_ipc.sin_addr), ntohs(PS_ipc.sin_port)); + debugs(54, 3, "ipcCreate: FD " << pwfd_ipc << " sockaddr " << inet_ntoa(PS_ipc.sin_addr) << ":" << ntohs(PS_ipc.sin_port)); + tmp_s = sizeof(CS_ipc); memset(&CS_ipc, '\0', tmp_s); if (getsockname(crfd_ipc, (struct sockaddr *) &CS_ipc, &tmp_s) < 0) { - debug(54, 0) ("ipcCreate: getsockname: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: getsockname: " << xstrerror()); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } - debug(54, 3) ("ipcCreate: FD %d sockaddr %s:%d\n", - crfd_ipc, inet_ntoa(CS_ipc.sin_addr), ntohs(CS_ipc.sin_port)); + debugs(54, 3, "ipcCreate: FD " << crfd_ipc << " sockaddr " << inet_ntoa(CS_ipc.sin_addr) << ":" << ntohs(CS_ipc.sin_port)); if (comm_connect_addr(pwfd_ipc, &CS_ipc) == COMM_ERROR) { ipcSend(cwfd, err_string, strlen(err_string)); @@ -589,7 +582,8 @@ ipc_thread_1(void *in_params) if (pid == -1) { errno = x; - debug(54, 0) ("ipcCreate: CHILD: %s: %s\n", params->prog, xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: " << params->prog << ": " << xstrerror()); + ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -600,8 +594,8 @@ ipc_thread_1(void *in_params) memset(&wpi, 0, sizeof(wpi)); if (SOCKET_ERROR == WSADuplicateSocket(crfd_ipc, pid, &wpi)) { - debug(54, 0) ("ipcCreate: CHILD: WSADuplicateSocket: %s\n", - xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: WSADuplicateSocket: " << xstrerror()); + ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -609,10 +603,9 @@ ipc_thread_1(void *in_params) x = write(c2p[1], (const char *) &wpi, sizeof(wpi)); if (x < (ssize_t)sizeof(wpi)) { - debug(54, 0) ("ipcCreate: CHILD: write FD %d: %s\n", c2p[1], - xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: %s: socket exchange failed\n", - prog); + debugs(54, 0, "ipcCreate: CHILD: write FD " << c2p[1] << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: " << prog << ": socket exchange failed"); + ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -620,18 +613,16 @@ ipc_thread_1(void *in_params) x = read(p2c[0], buf1, 8192); if (x < 0) { - debug(54, 0) ("ipcCreate: CHILD: read FD %d: %s\n", p2c[0], - xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: %s: socket exchange failed\n", - prog); + debugs(54, 0, "ipcCreate: CHILD: read FD " << p2c[0] << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: " << prog << ": socket exchange failed"); + ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } else if (strncmp(buf1, ok_string, strlen(ok_string))) { - debug(54, 0) ("ipcCreate: CHILD: %s: socket exchange failed\n", - prog); - debug(54, 0) ("--> read returned %d\n", x); + debugs(54, 0, "ipcCreate: CHILD: " << prog << ": socket exchange failed"); + debugs(54, 0, "--> read returned " << x); buf1[x] = '\0'; - debug(54, 0) ("--> got '%s'\n", rfc1738_escape(buf1)); + debugs(54, 0, "--> got '" << rfc1738_escape(buf1) << "'"); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -639,10 +630,9 @@ ipc_thread_1(void *in_params) x = write(c2p[1], (const char *) &PS_ipc, sizeof(PS_ipc)); if (x < (ssize_t)sizeof(PS_ipc)) { - debug(54, 0) ("ipcCreate: CHILD: write FD %d: %s\n", c2p[1], - xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: %s: socket exchange failed\n", - prog); + debugs(54, 0, "ipcCreate: CHILD: write FD " << c2p[1] << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: " << prog << ": socket exchange failed"); + ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -650,18 +640,16 @@ ipc_thread_1(void *in_params) x = read(p2c[0], buf1, 8192); if (x < 0) { - debug(54, 0) ("ipcCreate: CHILD: read FD %d: %s\n", p2c[0], - xstrerror()); - debug(54, 0) ("ipcCreate: CHILD: %s: socket exchange failed\n", - prog); + debugs(54, 0, "ipcCreate: CHILD: read FD " << p2c[0] << ": " << xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: " << prog << ": socket exchange failed"); + ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } else if (strncmp(buf1, ok_string, strlen(ok_string))) { - debug(54, 0) ("ipcCreate: CHILD: %s: socket exchange failed\n", - prog); - debug(54, 0) ("--> read returned %d\n", x); + debugs(54, 0, "ipcCreate: CHILD: " << prog << ": socket exchange failed"); + debugs(54, 0, "--> read returned " << x); buf1[x] = '\0'; - debug(54, 0) ("--> got '%s'\n", rfc1738_escape(buf1)); + debugs(54, 0, "--> got '" << rfc1738_escape(buf1) << "'"); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -701,7 +689,7 @@ ipc_thread_1(void *in_params) (HANDLE) _beginthreadex(NULL, 0, ipc_thread_2, &thread_params, 0, NULL); if (!thread) { - debug(54, 0) ("ipcCreate: CHILD: _beginthreadex: %s\n", xstrerror()); + debugs(54, 0, "ipcCreate: CHILD: _beginthreadex: " << xstrerror()); ipcSend(cwfd, err_string, strlen(err_string)); goto cleanup; } @@ -711,30 +699,27 @@ ipc_thread_1(void *in_params) if (-1 == ipcSend(cwfd, buf1, strlen(buf1))) goto cleanup; - debug(54, 2) ("ipc(%s,%ld): started successfully\n", prog, (long int) pid); + debugs(54, 2, "ipc(" << prog << "," << (long int) pid << "): started successfully"); /* cycle */ for (;;) { x = recv(crfd, (void *)buf1, 8192, 0); if (x <= 0) { - debug(54, 3) ("ipc(%s,%d): %d bytes received from parent. Exiting...\n", - prog, pid, x); + debugs(54, 3, "ipc(" << prog << "," << pid << "): " << x << " bytes received from parent. Exiting..."); break; } buf1[x] = '\0'; if (type == IPC_UDP_SOCKET && !strcmp(buf1, shutdown_string)) { - debug(54, 3) - ("ipc(%s,%d): request for shutdown received from parent. Exiting...\n", - prog, pid); + debugs(54, 3, "ipc(" << prog << "," << pid << "): request for shutdown received from parent. Exiting..."); + TerminateProcess(hProcess, 0); break; } - debug(54, 5) ("ipc(%s,%d): received from parent: %s\n", prog, pid, - rfc1738_escape_unescaped(buf1)); + debugs(54, 5, "ipc(" << prog << "," << pid << "): received from parent: " << rfc1738_escape_unescaped(buf1)); if (type == IPC_TCP_SOCKET) x = write(c2p[1], buf1, x); @@ -742,8 +727,8 @@ ipc_thread_1(void *in_params) x = send(pwfd_ipc, (const void *)buf1, x, 0); if (x <= 0) { - debug(54, 3) ("ipc(%s,%d): %d bytes written to %s. Exiting...\n", - prog, pid, x, prog); + debugs(54, 3, "ipc(" << prog << "," << pid << "): " << x << " bytes written to " << prog << ". Exiting..."); + break; } } @@ -770,21 +755,21 @@ cleanup: WaitForSingleObject(hProcess, type == IPC_UDP_SOCKET ? 12000 : 5000)) { getCurrentTime(); - debug(54, 0) ("ipc(%s,%d): WARNING: %s didn't exit in %d seconds.\n", - prog, pid, prog, type == IPC_UDP_SOCKET ? 12 : 5); + debugs(54, 0, "ipc(" << prog << "," << pid << "): WARNING: " << prog << + " didn't exit in " << (type == IPC_UDP_SOCKET ? 12 : 5) << " seconds."); + } if (thread && WAIT_OBJECT_0 != WaitForSingleObject(thread, 3000)) { getCurrentTime(); - debug(54, 0) - ("ipc(%s,%d): WARNING: ipc_thread_2 didn't exit in 3 seconds.\n", - prog, pid); + debugs(54, 0, "ipc(" << prog << "," << pid << "): WARNING: ipc_thread_2 didn't exit in 3 seconds."); + } getCurrentTime(); if (!retval) - debug(54, 2) ("ipc(%s,%d): normal exit\n", prog, pid); + debugs(54, 2, "ipc(" << prog << "," << pid << "): normal exit"); if (buf1) xfree(buf1); @@ -825,16 +810,16 @@ ipc_thread_2(void *in_params) if ((x <= 0 && type == IPC_TCP_SOCKET) || (x < 0 && type == IPC_UDP_SOCKET)) { - debug(54, 3) ("ipc(%s,%d): %d bytes read from %s. Exiting...\n", - prog, pid, x, prog); + debugs(54, 3, "ipc(" << prog << "," << pid << "): " << x << " bytes read from " << prog << ". Exiting..."); + break; } buf2[x] = '\0'; if (type == IPC_UDP_SOCKET && !strcmp(buf2, shutdown_string)) { - debug(54, 3) ("ipc(%s,%d): request for shutdown received. Exiting...\n", - prog, pid); + debugs(54, 3, "ipc(" << prog << "," << pid << "): request for shutdown received. Exiting..."); + break; } @@ -846,14 +831,14 @@ ipc_thread_2(void *in_params) } } - debug(54, 5) ("ipc(%s,%d): received from child : %s\n", prog, pid, - rfc1738_escape_unescaped(buf2)); + debugs(54, 5, "ipc(" << prog << "," << pid << "): received from child : " << rfc1738_escape_unescaped(buf2)); + x = send(send_fd, (const void *)buf2, x, 0); if ((x <= 0 && type == IPC_TCP_SOCKET) || (x < 0 && type == IPC_UDP_SOCKET)) { - debug(54, 3) ("ipc(%s,%d): %d bytes sent to parent. Exiting...\n", - prog, pid, x); + debugs(54, 3, "ipc(" << prog << "," << pid << "): " << x << " bytes sent to parent. Exiting..."); + break; } } diff --git a/src/ipcache.cc b/src/ipcache.cc index 7f54344cc9..d9ef0c6239 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -1,6 +1,6 @@ /* - * $Id: ipcache.cc,v 1.258 2006/08/21 00:50:41 robertc Exp $ + * $Id: ipcache.cc,v 1.259 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 14 IP Cache * AUTHOR: Harvest Derived @@ -117,7 +117,7 @@ static int ipcache_testname(void) { wordlist *w = NULL; - debug(14, 1) ("Performing DNS Tests...\n"); + debugs(14, 1, "Performing DNS Tests..."); if ((w = Config.dns_testname_list) == NULL) return 1; @@ -134,7 +134,8 @@ ipcache_testname(void) static void ipcacheRelease(ipcache_entry * i) { - debug(14, 3) ("ipcacheRelease: Releasing entry for '%s'\n", (const char *) i->hash.key); + debugs(14, 3, "ipcacheRelease: Releasing entry for '" << (const char *) i->hash.key << "'"); + hash_remove_link(ip_table, (hash_link *) i); dlinkDelete(&i->lru, &lru_list); ipcacheFreeEntry(i); @@ -192,7 +193,7 @@ ipcache_purgelru(void *voidnotused) removed++; } - debug(14, 9) ("ipcache_purgelru: removed %d entries\n", removed); + debugs(14, 9, "ipcache_purgelru: removed " << removed << " entries"); } /* purges entries added from /etc/hosts (or whatever). */ @@ -290,17 +291,18 @@ ipcacheParse(ipcache_entry *i, const char *inbuf) i->addrs.count = 0; if (inbuf == NULL) { - debug(14, 1) ("ipcacheParse: Got reply\n"); + debugs(14, 1, "ipcacheParse: Got reply"); i->error_message = xstrdup("Internal Error"); return -1; } xstrncpy(buf, inbuf, DNS_INBUF_SZ); - debug(14, 5) ("ipcacheParse: parsing: {%s}\n", buf); + debugs(14, 5, "ipcacheParse: parsing: {" << buf << "}"); token = strtok(buf, w_space); if (NULL == token) { - debug(14, 1) ("ipcacheParse: expecting result, got '%s'\n", inbuf); + debugs(14, 1, "ipcacheParse: expecting result, got '" << inbuf << "'"); + i->error_message = xstrdup("Internal Error"); return -1; } @@ -313,7 +315,8 @@ ipcacheParse(ipcache_entry *i, const char *inbuf) } if (0 != strcmp(token, "$addr")) { - debug(14, 1) ("ipcacheParse: expecting '$addr', got '%s' in response to '%s'\n", inbuf, name); + debugs(14, 1, "ipcacheParse: expecting '$addr', got '" << inbuf << "' in response to '" << name << "'"); + i->error_message = xstrdup("Internal Error"); return -1; } @@ -321,7 +324,8 @@ ipcacheParse(ipcache_entry *i, const char *inbuf) token = strtok(NULL, w_space); if (NULL == token) { - debug(14, 1) ("ipcacheParse: expecting TTL, got '%s' in response to '%s'\n", inbuf, name); + debugs(14, 1, "ipcacheParse: expecting TTL, got '" << inbuf << "' in response to '" << name << "'"); + i->error_message = xstrdup("Internal Error"); return -1; } @@ -345,14 +349,14 @@ ipcacheParse(ipcache_entry *i, const char *inbuf) if (safe_inet_addr(A[k], &i->addrs.in_addrs[j])) j++; else - debug(14, 1) ("ipcacheParse: Invalid IP address '%s' in response to '%s'\n", A[k], name); + debugs(14, 1, "ipcacheParse: Invalid IP address '" << A[k] << "' in response to '" << name << "'"); } i->addrs.count = (unsigned char) j; } if (i->addrs.count <= 0) { - debug(14, 1) ("ipcacheParse: No addresses in response to '%s'\n", name); + debugs(14, 1, "ipcacheParse: No addresses in response to '" << name << "'"); return -1; } @@ -386,14 +390,13 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m i->addrs.count = 0; if (nr < 0) { - debug(14, 3) ("ipcacheParse: Lookup failed '%s' for '%s'\n", - error_message, (const char *)i->hash.key); + debugs(14, 3, "ipcacheParse: Lookup failed '" << error_message << "' for '" << (const char *)i->hash.key << "'"); i->error_message = xstrdup(error_message); return -1; } if (nr == 0) { - debug(14, 3) ("ipcacheParse: No DNS records in response to '%s'\n", name); + debugs(14, 3, "ipcacheParse: No DNS records in response to '" << name << "'"); i->error_message = xstrdup("No DNS records"); return 0; } @@ -408,7 +411,7 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m continue; if (answers[k].rdlength != 4) { - debug(14, 1)("ipcacheParse: Invalid IP address in response to '%s'\n", name); + debugs(14, 1, "ipcacheParse: Invalid IP address in response to '" << name << "'"); continue; } @@ -416,7 +419,7 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m } if (na == 0) { - debug(14, 1) ("ipcacheParse: No Address records in response to '%s'\n", name); + debugs(14, 1, "ipcacheParse: No Address records in response to '" << name << "'"); i->error_message = xstrdup("No Address records"); return 0; } @@ -434,9 +437,8 @@ ipcacheParse(ipcache_entry *i, rfc1035_rr * answers, int nr, const char *error_m xmemcpy(&i->addrs.in_addrs[j++], answers[k].rdata, 4); - debug(14, 3) ("ipcacheParse: #%d %s\n", - j - 1, - inet_ntoa(i->addrs.in_addrs[j - 1])); + debugs(14, 3, "ipcacheParse: #" << j - 1 << " " << inet_ntoa(i->addrs.in_addrs[j - 1])); + } else if (answers[k].type != RFC1035_TYPE_CNAME) continue; @@ -498,11 +500,11 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData) const ipcache_addrs *addrs = NULL; generic_cbdata *c; assert(handler != NULL); - debug(14, 4) ("ipcache_nbgethostbyname: Name '%s'.\n", name); + debugs(14, 4, "ipcache_nbgethostbyname: Name '" << name << "'."); IpcacheStats.requests++; if (name == NULL || name[0] == '\0') { - debug(14, 4) ("ipcache_nbgethostbyname: Invalid name!\n"); + debugs(14, 4, "ipcache_nbgethostbyname: Invalid name!"); dns_error_message = "Invalid hostname"; handler(NULL, handlerData); return; @@ -525,7 +527,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData) i = NULL; } else { /* hit */ - debug(14, 4) ("ipcache_nbgethostbyname: HIT for '%s'\n", name); + debugs(14, 4, "ipcache_nbgethostbyname: HIT for '" << name << "'"); if (i->flags.negcached) IpcacheStats.negative_hits++; @@ -541,7 +543,7 @@ ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData) return; } - debug(14, 5) ("ipcache_nbgethostbyname: MISS for '%s'\n", name); + debugs(14, 5, "ipcache_nbgethostbyname: MISS for '" << name << "'"); IpcacheStats.misses++; i = ipcacheCreateEntry(name); i->handler = handler; @@ -562,17 +564,17 @@ void ipcache_init(void) { int n; - debug(14, 3) ("Initializing IP Cache...\n"); + debugs(14, 3, "Initializing IP Cache..."); memset(&IpcacheStats, '\0', sizeof(IpcacheStats)); memset(&lru_list, '\0', sizeof(lru_list)); /* test naming lookup */ if (!opt_dns_tests) { - debug(14, 4) ("ipcache_init: Skipping DNS name lookup tests.\n"); + debugs(14, 4, "ipcache_init: Skipping DNS name lookup tests."); } else if (!ipcache_testname()) { fatal("ipcache_init: DNS name lookup tests failed."); } else { - debug(14, 1) ("Successful DNS name lookup tests...\n"); + debugs(14, 1, "Successful DNS name lookup tests..."); } memset(&static_addrs, '\0', sizeof(ipcache_addrs)); @@ -602,7 +604,7 @@ ipcache_gethostbyname(const char *name, int flags) ipcache_entry *i = NULL; ipcache_addrs *addrs; assert(name); - debug(14, 3) ("ipcache_gethostbyname: '%s', flags=%x\n", name, flags); + debugs(14, 3, "ipcache_gethostbyname: '" << name << "', flags=" << std::hex << flags); IpcacheStats.requests++; i = ipcache_get(name); @@ -794,8 +796,7 @@ ipcacheCycleAddr(const char *name, ipcache_addrs * ia) if (k == ia->count) { /* All bad, reset to All good */ - debug(14, 3) ("ipcacheCycleAddr: Changing ALL %s addrs from BAD to OK\n", - name); + debugs(14, 3, "ipcacheCycleAddr: Changing ALL " << name << " addrs from BAD to OK"); for (k = 0; k < ia->count; k++) ia->bad_mask[k] = 0; @@ -805,8 +806,7 @@ ipcacheCycleAddr(const char *name, ipcache_addrs * ia) ia->cur = 0; } - debug(14, 3) ("ipcacheCycleAddr: %s now at %s\n", name, - inet_ntoa(ia->in_addrs[ia->cur])); + debugs(14, 3, "ipcacheCycleAddr: " << name << " now at " << inet_ntoa(ia->in_addrs[ia->cur])); } /* @@ -840,7 +840,7 @@ ipcacheMarkBadAddr(const char *name, struct IN_ADDR addr) ia->bad_mask[k] = TRUE; ia->badcount++; i->expires = XMIN(squid_curtime + XMAX((time_t)60, Config.negativeDnsTtl), i->expires); - debug(14, 2) ("ipcacheMarkBadAddr: %s [%s]\n", name, inet_ntoa(addr)); + debugs(14, 2, "ipcacheMarkBadAddr: " << name << " [" << inet_ntoa(addr) << "]"); } ipcacheCycleAddr(name, ia); @@ -875,7 +875,7 @@ ipcacheMarkGoodAddr(const char *name, struct IN_ADDR addr) ia->badcount--; - debug(14, 2) ("ipcacheMarkGoodAddr: %s [%s]\n", name, inet_ntoa(addr)); + debugs(14, 2, "ipcacheMarkGoodAddr: " << name << " [" << inet_ntoa(addr) << "]"); } static void @@ -921,10 +921,9 @@ ipcacheAddEntryFromHosts(const char *name, const char *ipaddr) if (!safe_inet_addr(ipaddr, &ip)) { if (strchr(ipaddr, ':') && strspn(ipaddr, "0123456789abcdefABCDEF:") == strlen(ipaddr)) { - debug(14, 3) ("ipcacheAddEntryFromHosts: Skipping IPv6 address '%s'\n", ipaddr); + debugs(14, 3, "ipcacheAddEntryFromHosts: Skipping IPv6 address '" << ipaddr << "'"); } else { - debug(14, 1) ("ipcacheAddEntryFromHosts: Bad IP address '%s'\n", - ipaddr); + debugs(14, 1, "ipcacheAddEntryFromHosts: Bad IP address '" << ipaddr << "'"); } return 1; @@ -934,8 +933,7 @@ ipcacheAddEntryFromHosts(const char *name, const char *ipaddr) if (1 == i->flags.fromhosts) { ipcacheUnlockEntry(i); } else if (i->locks > 0) { - debug(14, 1) ("ipcacheAddEntryFromHosts: can't add static entry" - " for locked name '%s'\n", name); + debugs(14, 1, "ipcacheAddEntryFromHosts: can't add static entry for locked name '" << name << "'"); return 1; } else { ipcacheRelease(i); @@ -966,7 +964,7 @@ variable_list * snmp_netIpFn(variable_list * Var, snint * ErrP) { variable_list *Answer = NULL; - debug(49, 5) ("snmp_netIpFn: Processing request:\n"); + debugs(49, 5, "snmp_netIpFn: Processing request:"); snmpDebugOid(5, Var->name, Var->name_length); *ErrP = SNMP_ERR_NOERROR; diff --git a/src/logfile.cc b/src/logfile.cc index 5b0ac7d60b..7547232c30 100644 --- a/src/logfile.cc +++ b/src/logfile.cc @@ -1,5 +1,5 @@ /* - * $Id: logfile.cc,v 1.21 2006/06/05 21:08:15 serassio Exp $ + * $Id: logfile.cc,v 1.22 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 50 Log file handling * AUTHOR: Duane Wessels @@ -129,7 +129,7 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag) "\tuser '%s', which is the cache_effective_user\n" "\tset in squid.conf.", path, Config.effectiveUser); } else { - debug(50, 1) ("logfileOpen: %s: %s\n", path, xstrerror()); + debugs(50, 1, "logfileOpen: " << path << ": " << xstrerror()); return NULL; } } @@ -186,7 +186,7 @@ logfileRotate(Logfile * lf) #endif - debug(0, 1) ("logfileRotate: %s\n", lf->path); + debugs(0, 1, "logfileRotate: " << lf->path); /* Rotate numbers 0 through N up one */ for (i = Config.Log.rotateNumber; i > 1;) { @@ -210,7 +210,7 @@ logfileRotate(Logfile * lf) lf->fd = file_open(lf->path, O_WRONLY | O_CREAT | O_TEXT); if (DISK_ERROR == lf->fd && lf->flags.fatal) { - debug(50, 1) ("logfileRotate: %s: %s\n", lf->path, xstrerror()); + debugs(50, 1, "logfileRotate: " << lf->path << ": " << xstrerror()); fatalf("Cannot open %s: %s", lf->path, xstrerror()); } } diff --git a/src/main.cc b/src/main.cc index b69d380951..ac90e48f19 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,6 +1,6 @@ /* - * $Id: main.cc,v 1.445 2007/04/15 14:46:17 serassio Exp $ + * $Id: main.cc,v 1.446 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -174,10 +174,8 @@ SignalDispatcher::dispatch() do_rotate = 0; } else if (do_shutdown) { time_t wait = do_shutdown > 0 ? (int) Config.shutdownLifetime : 0; - debug(1, 1) ("Preparing for shutdown after %d requests\n", - statCounter.client_http.requests); - debug(1, 1) ("Waiting %d seconds for active connections to finish\n", - (int) wait); + debugs(1, 1, "Preparing for shutdown after " << statCounter.client_http.requests << " requests"); + debugs(1, 1, "Waiting " << (int) wait << " seconds for active connections to finish"); do_shutdown = 0; shutting_down = 1; #if USE_WIN32_SERVICE @@ -604,7 +602,7 @@ serverConnectionsClose(void) static void mainReconfigure(void) { - debug(1, 1) ("Reconfiguring Squid Cache (version %s)...\n", version_string); + debugs(1, 1, "Reconfiguring Squid Cache (version " << version_string << ")..."); reconfiguring = 1; /* Already called serverConnectionsClose and ipcacheShutdownServers() */ serverConnectionsClose(); @@ -686,7 +684,7 @@ mainReconfigure(void) writePidFile(); /* write PID file */ - debug(1, 1) ("Ready to serve requests.\n"); + debugs(1, 1, "Ready to serve requests."); reconfiguring = 0; } @@ -736,10 +734,10 @@ setEffectiveUser(void) #endif if (geteuid() == 0) { - debug(0, 0) ("Squid is not safe to run as root! If you must\n"); - debug(0, 0) ("start Squid as root, then you must configure\n"); - debug(0, 0) ("it to run as a non-priveledged user with the\n"); - debug(0, 0) ("'cache_effective_user' option in the config file.\n"); + debugs(0, 0, "Squid is not safe to run as root! If you must"); + debugs(0, 0, "start Squid as root, then you must configure"); + debugs(0, 0, "it to run as a non-priveledged user with the"); + debugs(0, 0, "'cache_effective_user' option in the config file."); fatal("Don't run Squid as root, set 'cache_effective_user'!"); } } @@ -753,18 +751,18 @@ mainSetCwd(void) if (0 == strcmp("none", Config.coredump_dir)) { (void) 0; } else if (chdir(Config.coredump_dir) == 0) { - debug(0, 1) ("Set Current Directory to %s\n", Config.coredump_dir); + debugs(0, 1, "Set Current Directory to " << Config.coredump_dir); return; } else { - debug(50, 0) ("chdir: %s: %s\n", Config.coredump_dir, xstrerror()); + debugs(50, 0, "chdir: " << Config.coredump_dir << ": " << xstrerror()); } } /* If we don't have coredump_dir or couldn't cd there, report current dir */ if (getcwd(pathbuf, MAXPATHLEN)) { - debug(0, 1) ("Current Directory is %s\n", pathbuf); + debugs(0, 1, "Current Directory is " << pathbuf); } else { - debug(50, 0) ("WARNING: Can't find current directory, getcwd: %s\n", xstrerror()); + debugs(50, 0, "WARNING: Can't find current directory, getcwd: " << xstrerror()); } } @@ -804,30 +802,28 @@ mainInitialize(void) #endif - debug(1, 0) ("Starting Squid Cache version %s for %s...\n", - version_string, - CONFIG_HOST_TYPE); + debugs(1, 0, "Starting Squid Cache version " << version_string << " for " << CONFIG_HOST_TYPE << "..."); #ifdef _SQUID_WIN32_ if (WIN32_run_mode == _WIN_SQUID_RUN_MODE_SERVICE) { - debug(1, 0) ("Running as %s Windows System Service on %s\n", WIN32_Service_name, WIN32_OS_string); - debug(1, 0) ("Service command line is: %s\n", WIN32_Service_Command_Line); + debugs(1, 0, "Running as " << WIN32_Service_name << " Windows System Service on " << WIN32_OS_string); + debugs(1, 0, "Service command line is: " << WIN32_Service_Command_Line); } else - debug(1, 0) ("Running on %s\n",WIN32_OS_string); + debugs(1, 0, "Running on " << WIN32_OS_string); #endif debugs(1, 1, "Process ID " << getpid()); - debug(1, 1) ("With %d file descriptors available\n", Squid_MaxFD); + debugs(1, 1, "With " << Squid_MaxFD << " file descriptors available"); #ifdef _SQUID_MSWIN_ - debug(1, 1) ("With %d CRT stdio descriptors available\n", _getmaxstdio()); + debugs(1, 1, "With " << _getmaxstdio() << " CRT stdio descriptors available"); if (WIN32_Socks_initialized) - debug(1, 1)("Windows sockets initialized\n"); + debugs(1, 1, "Windows sockets initialized"); #endif @@ -1028,7 +1024,7 @@ mainInitialize(void) memCheckInit(); - debug(1, 1) ("Ready to serve requests.\n"); + debugs(1, 1, "Ready to serve requests."); if (!configured_once) { eventAdd("storeMaintain", Store::Maintain, NULL, 1.0, 1); @@ -1251,7 +1247,7 @@ main(int argc, char **argv) } setEffectiveUser(); - debug(0, 0) ("Creating Swap Directories\n"); + debugs(0, 0, "Creating Swap Directories"); Store::Root().create(); return 0; @@ -1340,7 +1336,7 @@ sendSignal(void) debug_log = stderr; if (strcmp(Config.pidFilename, "none") == 0) { - debug(0, 1) ("No pid_filename specified. Trusting you know what you are doing.\n"); + debugs(0, 1, "No pid_filename specified. Trusting you know what you are doing."); } pid = readPidFile(); @@ -1601,7 +1597,7 @@ SquidShutdown() WIN32_svcstatusupdate(SERVICE_STOP_PENDING, 10000); #endif - debug(1, 1) ("Shutting down...\n"); + debugs(1, 1, "Shutting down..."); #if USE_DNSSERVERS dnsShutdown(); @@ -1700,7 +1696,7 @@ SquidShutdown() xmalloc_find_leaks(); - debug(1, 0) ("Memory used after shutdown: %d\n", xmalloc_total); + debugs(1, 0, "Memory used after shutdown: " << xmalloc_total); #endif #if MEM_GEN_TRACE @@ -1715,8 +1711,7 @@ SquidShutdown() leave_suid(); } - debug(1, 1) ("Squid Cache (Version %s): Exiting normally.\n", - version_string); + debugs(1, 1, "Squid Cache (Version " << version_string << "): Exiting normally."); /* * DPW 2006-10-23 diff --git a/src/mem.cc b/src/mem.cc index 4030cc2699..45506bd3eb 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -1,6 +1,6 @@ /* - * $Id: mem.cc,v 1.103 2007/04/20 07:29:47 wessels Exp $ + * $Id: mem.cc,v 1.104 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -143,9 +143,9 @@ Mem::Stats(StoreEntry * sentry) long int leaked = 0, dubious = 0, reachable = 0, suppressed = 0; stream << "Valgrind Report:\n"; stream << "Type\tAmount\n"; - debug(13, 1) ("Asking valgrind for memleaks\n"); + debugs(13, 1, "Asking valgrind for memleaks"); VALGRIND_DO_LEAK_CHECK; - debug(13, 1) ("Getting valgrind statistics\n"); + debugs(13, 1, "Getting valgrind statistics"); VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed); stream << "Leaked\t" << leaked << "\n"; stream << "Dubious\t" << dubious << "\n"; @@ -362,7 +362,7 @@ memConfigure(void) * stderr when doing things like 'squid -k reconfigure' */ if (MemPools::GetInstance().idleLimit() > new_pool_limit) - debug(13, 1) ("Shrinking idle mem pools to %.2f MB\n", toMB(new_pool_limit)); + debugs(13, 1, "Shrinking idle mem pools to "<< std::setprecision(3) << toMB(new_pool_limit) << " MB"); #endif MemPools::GetInstance().setIdleLimit(new_pool_limit); @@ -382,8 +382,8 @@ Mem::Init(void) * debug messages here at level 0 or 1 will always be printed * on stderr. */ - debug(13, 3) ("Memory pools are '%s'; limit: %.2f MB\n", - (Config.onoff.mem_pools ? "on" : "off"), toMB(MemPools::GetInstance().idleLimit())); + debugs(13, 3, "Memory pools are '" << ((Config.onoff.mem_pools ? "on" : "off")) << "'; limit: "<< + std::setprecision(3) << toMB(MemPools::GetInstance().idleLimit()) << " MB"); /* set all pointers to null */ memset(MemPools, '\0', sizeof(MemPools)); @@ -474,8 +474,9 @@ memClean(void) memPoolGetGlobalStats(&stats); if (stats.tot_items_inuse) - debug(13, 2) ("memCleanModule: %d items in %d chunks and %d pools are left dirty\n", stats.tot_items_inuse, - stats.tot_chunks_inuse, stats.tot_pools_inuse); + debugs(13, 2, "memCleanModule: " << stats.tot_items_inuse << + " items in " << stats.tot_chunks_inuse << " chunks and " << + stats.tot_pools_inuse << " pools are left dirty"); } int diff --git a/src/mime.cc b/src/mime.cc index c9175c206e..97bf0a3fbf 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -1,6 +1,6 @@ /* - * $Id: mime.cc,v 1.130 2007/04/21 07:14:14 wessels Exp $ + * $Id: mime.cc,v 1.131 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -125,7 +125,7 @@ mime_get_header_field(const char *mime, const char *name, const char *prefix) assert(NULL != name); - debug(25, 5) ("mime_get_header: looking for '%s'\n", name); + debugs(25, 5, "mime_get_header: looking for '" << name << "'"); for (p = mime; *p; p += strcspn(p, "\n\r")) { if (strcmp(p, "\r\n\r\n") == 0 || strcmp(p, "\n\n") == 0) @@ -147,7 +147,7 @@ mime_get_header_field(const char *mime, const char *name, const char *prefix) xstrncpy(header, p, l); - debug(25, 5) ("mime_get_header: checking '%s'\n", header); + debugs(25, 5, "mime_get_header: checking '" << header << "'"); q = header; @@ -166,7 +166,7 @@ mime_get_header_field(const char *mime, const char *name, const char *prefix) } if (got) { - debug(25, 5) ("mime_get_header: returning '%s'\n", q); + debugs(25, 5, "mime_get_header: returning '" << q << "'"); return q; } } @@ -397,7 +397,7 @@ mimeInit(char *filename) return; if ((fp = fopen(filename, "r")) == NULL) { - debug(25, 1) ("mimeInit: %s: %s\n", filename, xstrerror()); + debugs(25, 1, "mimeInit: " << filename << ": " << xstrerror()); return; } @@ -424,27 +424,27 @@ mimeInit(char *filename) xstrncpy(chopbuf, buf, BUFSIZ); if ((pattern = strtok(chopbuf, w_space)) == NULL) { - debug(25, 1) ("mimeInit: parse error: '%s'\n", buf); + debugs(25, 1, "mimeInit: parse error: '" << buf << "'"); continue; } if ((type = strtok(NULL, w_space)) == NULL) { - debug(25, 1) ("mimeInit: parse error: '%s'\n", buf); + debugs(25, 1, "mimeInit: parse error: '" << buf << "'"); continue; } if ((icon = strtok(NULL, w_space)) == NULL) { - debug(25, 1) ("mimeInit: parse error: '%s'\n", buf); + debugs(25, 1, "mimeInit: parse error: '" << buf << "'"); continue; } if ((encoding = strtok(NULL, w_space)) == NULL) { - debug(25, 1) ("mimeInit: parse error: '%s'\n", buf); + debugs(25, 1, "mimeInit: parse error: '" << buf << "'"); continue; } if ((mode = strtok(NULL, w_space)) == NULL) { - debug(25, 1) ("mimeInit: parse error: '%s'\n", buf); + debugs(25, 1, "mimeInit: parse error: '" << buf << "'"); continue; } @@ -457,11 +457,11 @@ mimeInit(char *filename) else if (!strcmp(option, "+view")) view_option = 1; else - debug(25, 1) ("mimeInit: unknown option: '%s' (%s)\n", buf, option); + debugs(25, 1, "mimeInit: unknown option: '" << buf << "' (" << option << ")"); } if (regcomp(&re, pattern, re_flags) != 0) { - debug(25, 1) ("mimeInit: regcomp error: '%s'\n", buf); + debugs(25, 1, "mimeInit: regcomp error: '" << buf << "'"); continue; } @@ -487,7 +487,7 @@ mimeInit(char *filename) MimeTableTail = &m->next; - debug(25, 5) ("mimeInit: added '%s'\n", buf); + debugs(25, 5, "mimeInit: added '" << buf << "'"); } fclose(fp); @@ -498,7 +498,7 @@ mimeInit(char *filename) for (m = MimeTable; m != NULL; m = m->next) m->theIcon.load(); - debug(25, 1) ("Loaded Icons.\n"); + debugs(25, 1, "Loaded Icons."); } void @@ -555,12 +555,12 @@ MimeIcon::created (StoreEntry *newEntry) fd = file_open(path, O_RDONLY | O_BINARY); if (fd < 0) { - debug(25, 0) ("mimeLoadIconFile: %s: %s\n", path, xstrerror()); + debugs(25, 0, "mimeLoadIconFile: " << path << ": " << xstrerror()); return; } if (fstat(fd, &sb) < 0) { - debug(25, 0) ("mimeLoadIconFile: FD %d: fstat: %s\n", fd, xstrerror()); + debugs(25, 0, "mimeLoadIconFile: FD " << fd << ": fstat: " << xstrerror()); file_close(fd); return; } @@ -610,7 +610,7 @@ MimeIcon::created (StoreEntry *newEntry) e->timestampsSet(); - debug(25, 3) ("Loaded icon %s\n", url); + debugs(25, 3, "Loaded icon " << url); e->unlock(); diff --git a/src/multicast.cc b/src/multicast.cc index 2c57fd1adf..b43d0c072b 100644 --- a/src/multicast.cc +++ b/src/multicast.cc @@ -1,6 +1,6 @@ /* - * $Id: multicast.cc,v 1.11 2003/02/21 22:50:10 robertc Exp $ + * $Id: multicast.cc,v 1.12 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 7 Multicast * AUTHOR: Martin Hamilton @@ -42,8 +42,7 @@ mcastSetTtl(int fd, int mcast_ttl) char ttl = (char) mcast_ttl; if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, 1) < 0) - debug(50, 1) ("comm_set_mcast_ttl: FD %d, TTL: %d: %s\n", - fd, mcast_ttl, xstrerror()); + debugs(50, 1, "comm_set_mcast_ttl: FD " << fd << ", TTL: " << mcast_ttl << ": " << xstrerror()); #endif @@ -62,13 +61,12 @@ mcastJoinGroups(const ipcache_addrs * ia, void *datanotused) char c = 0; if (ia == NULL) { - debug(7, 0) ("comm_join_mcast_groups: Unknown host\n"); + debugs(7, 0, "comm_join_mcast_groups: Unknown host"); return; } for (i = 0; i < (int) ia->count; i++) { - debug(7, 10) ("Listening for ICP requests on %s\n", - inet_ntoa(*(ia->in_addrs + i))); + debugs(7, 10, "Listening for ICP requests on " << inet_ntoa(*(ia->in_addrs + i))); mr.imr_multiaddr.s_addr = (ia->in_addrs + i)->s_addr; mr.imr_interface.s_addr = INADDR_ANY; x = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, @@ -76,13 +74,12 @@ mcastJoinGroups(const ipcache_addrs * ia, void *datanotused) (char *) &mr, sizeof(struct ip_mreq)); if (x < 0) - debug(7, 1) ("comm_join_mcast_groups: FD %d, [%s]\n", - fd, inet_ntoa(*(ia->in_addrs + i))); + debugs(7, 1, "comm_join_mcast_groups: FD " << fd << ", [" << inet_ntoa(*(ia->in_addrs + i)) << "]"); x = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, &c, 1); if (x < 0) - debug(7, 1) ("Can't disable multicast loopback: %s\n", xstrerror()); + debugs(7, 1, "Can't disable multicast loopback: " << xstrerror()); } #endif diff --git a/src/neighbors.cc b/src/neighbors.cc index ec2cf0e54a..db004b36ed 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.347 2007/04/21 07:14:14 wessels Exp $ + * $Id: neighbors.cc,v 1.348 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -102,7 +102,7 @@ whichPeer(const struct sockaddr_in * from) struct IN_ADDR ip = from->sin_addr; peer *p = NULL; - debug(15, 3) ("whichPeer: from %s port %d\n", inet_ntoa(ip), port); + debugs(15, 3, "whichPeer: from " << inet_ntoa(ip) << " port " << port); for (p = Config.peers; p; p = p->next) { @@ -273,7 +273,7 @@ neighborsCount(HttpRequest * request) if (peerWouldBePinged(p, request)) count++; - debug(15, 3) ("neighborsCount: %d\n", count); + debugs(15, 3, "neighborsCount: " << count); return count; } @@ -296,7 +296,7 @@ getFirstUpParent(HttpRequest * request) break; } - debug(15, 3) ("getFirstUpParent: returning %s\n", p ? p->host : "NULL"); + debugs(15, 3, "getFirstUpParent: returning " << (p ? p->host : "NULL")); return p; } @@ -329,7 +329,7 @@ getRoundRobinParent(HttpRequest * request) if (q) q->rr_count++; - debug(15, 3) ("getRoundRobinParent: returning %s\n", q ? q->host : "NULL"); + debugs(15, 3, "getRoundRobinParent: returning " << (q ? q->host : "NULL")); return q; } @@ -376,10 +376,10 @@ getWeightedRoundRobinParent(HttpRequest * request) q->rr_count += weighted_rtt; - debug(15, 3) ("getWeightedRoundRobinParent: weighted_rtt %d\n", (int) weighted_rtt); + debugs(15, 3, "getWeightedRoundRobinParent: weighted_rtt " << (int) weighted_rtt); } - debug(15, 3) ("getWeightedRoundRobinParent: returning %s\n", q ? q->host : "NULL"); + debugs(15, 3, "getWeightedRoundRobinParent: returning " << (q ? q->host : "NULL")); return q; } @@ -413,12 +413,12 @@ getDefaultParent(HttpRequest * request) if (!peerHTTPOkay(p, request)) continue; - debug(15, 3) ("getDefaultParent: returning %s\n", p->host); + debugs(15, 3, "getDefaultParent: returning " << p->host); return p; } - debug(15, 3) ("getDefaultParent: returning NULL\n"); + debugs(15, 3, "getDefaultParent: returning NULL"); return NULL; } @@ -440,12 +440,12 @@ getAnyParent(HttpRequest * request) if (!peerHTTPOkay(p, request)) continue; - debug(15, 3) ("getAnyParent: returning %s\n", p->host); + debugs(15, 3, "getAnyParent: returning " << p->host); return p; } - debug(15, 3) ("getAnyParent: returning NULL\n"); + debugs(15, 3, "getAnyParent: returning NULL"); return NULL; } @@ -506,7 +506,7 @@ neighbors_init(void) memset(&name, '\0', sizeof(struct sockaddr_in)); if (getsockname(fd, (struct sockaddr *) &name, &len) < 0) - debug(15, 1) ("getsockname(%d,%p,%p) failed.\n", fd, &name, &len); + debugs(15, 1, "getsockname(" << fd << "," << &name << "," << &len << ") failed."); for (thisPeer = Config.peers; thisPeer; thisPeer = next) { http_port_list *s; @@ -519,11 +519,13 @@ neighbors_init(void) if (thisPeer->http_port != ntohs(s->s.sin_port)) continue; - debug(15, 1) ("WARNING: Peer looks like this host\n"); + debugs(15, 1, "WARNING: Peer looks like this host"); + + debugs(15, 1, " Ignoring " << + neighborTypeStr(thisPeer) << " " << thisPeer->host << + "/" << thisPeer->http_port << "/" << + thisPeer->icp.port); - debug(15, 1) (" Ignoring %s %s/%d/%d\n", - neighborTypeStr(thisPeer), thisPeer->host, thisPeer->http_port, - thisPeer->icp.port); neighborRemove(thisPeer); } @@ -610,32 +612,31 @@ neighborsUdpPing(HttpRequest * request, if (p == NULL) p = Config.peers; - debug(15, 5) ("neighborsUdpPing: Peer %s\n", p->host); + debugs(15, 5, "neighborsUdpPing: Peer " << p->host); if (!peerWouldBePinged(p, request)) continue; /* next peer */ peers_pinged++; - debug(15, 4) ("neighborsUdpPing: pinging peer %s for '%s'\n", - p->host, url); + debugs(15, 4, "neighborsUdpPing: pinging peer " << p->host << " for '" << url << "'"); if (p->type == PEER_MULTICAST) mcastSetTtl(theOutIcpConnection, p->mcast.ttl); - debug(15, 3) ("neighborsUdpPing: key = '%s'\n", entry->getMD5Text()); + debugs(15, 3, "neighborsUdpPing: key = '" << entry->getMD5Text() << "'"); - debug(15, 3) ("neighborsUdpPing: reqnum = %d\n", reqnum); + debugs(15, 3, "neighborsUdpPing: reqnum = " << reqnum); #if USE_HTCP if (p->options.htcp) { - debug(15, 3) ("neighborsUdpPing: sending HTCP query\n"); + debugs(15, 3, "neighborsUdpPing: sending HTCP query"); htcpQuery(entry, request, p); } else #endif if (p->icp.port == echo_port) { - debug(15, 4) ("neighborsUdpPing: Looks like a dumb cache, send DECHO ping\n"); + debugs(15, 4, "neighborsUdpPing: Looks like a dumb cache, send DECHO ping"); echo_hdr.reqnum = reqnum; query = _icp_common_t::createMessage(ICP_DECHO, 0, url, reqnum, 0); icpUdpSend(theOutIcpConnection, @@ -681,8 +682,7 @@ neighborsUdpPing(HttpRequest * request, /* log it once at the threshold */ if (p->stats.logged_state == PEER_ALIVE) { - debug(15, 1) ("Detected DEAD %s: %s\n", - neighborTypeStr(p), p->name); + debugs(15, 1, "Detected DEAD " << neighborTypeStr(p) << ": " << p->name); p->stats.logged_state = PEER_DEAD; } } @@ -710,10 +710,9 @@ neighborsUdpPing(HttpRequest * request, char *host = request->host; if (!Config.onoff.source_ping) { - debug(15, 6) ("neighborsUdpPing: Source Ping is disabled.\n"); + debugs(15, 6, "neighborsUdpPing: Source Ping is disabled."); } else if ((ia = ipcache_gethostbyname(host, 0))) { - debug(15, 6) ("neighborsUdpPing: Source Ping: to %s for '%s'\n", - host, url); + debugs(15, 6, "neighborsUdpPing: Source Ping: to " << host << " for '" << url << "'"); echo_hdr.reqnum = reqnum; if (icmp_sock != -1) { @@ -730,8 +729,7 @@ neighborsUdpPing(HttpRequest * request, 0); } } else { - debug(15, 6) ("neighborsUdpPing: Source Ping: unknown host: %s\n", - host); + debugs(15, 6, "neighborsUdpPing: Source Ping: unknown host: " << host); } } @@ -776,33 +774,32 @@ peerDigestLookup(peer * p, HttpRequest * request) const cache_key *key = request ? storeKeyPublicByRequest(request) : NULL; assert(p); assert(request); - debug(15, 5) ("peerDigestLookup: peer %s\n", p->host); + debugs(15, 5, "peerDigestLookup: peer " << p->host); /* does the peeer have a valid digest? */ if (!p->digest) { - debug(15, 5) ("peerDigestLookup: gone!\n"); + debugs(15, 5, "peerDigestLookup: gone!"); return LOOKUP_NONE; } else if (!peerHTTPOkay(p, request)) { - debug(15, 5) ("peerDigestLookup: !peerHTTPOkay\n"); + debugs(15, 5, "peerDigestLookup: !peerHTTPOkay"); return LOOKUP_NONE; } else if (!p->digest->flags.needed) { - debug(15, 5) ("peerDigestLookup: note need\n"); + debugs(15, 5, "peerDigestLookup: note need"); peerDigestNeeded(p->digest); return LOOKUP_NONE; } else if (!p->digest->flags.usable) { - debug(15, 5) ("peerDigestLookup: !ready && %srequested\n", - p->digest->flags.requested ? "" : "!"); + debugs(15, 5, "peerDigestLookup: !ready && " << (p->digest->flags.requested ? "" : "!") << "requested"); return LOOKUP_NONE; } - debug(15, 5) ("peerDigestLookup: OK to lookup peer %s\n", p->host); + debugs(15, 5, "peerDigestLookup: OK to lookup peer " << p->host); assert(p->digest->cd); /* does digest predict a hit? */ if (!cacheDigestTest(p->digest->cd, key)) return LOOKUP_MISS; - debug(15, 5) ("peerDigestLookup: peer %s says HIT!\n", p->host); + debugs(15, 5, "peerDigestLookup: peer " << p->host << " says HIT!"); return LOOKUP_HIT; @@ -852,8 +849,7 @@ neighborsDigestSelect(HttpRequest * request) p_rtt = netdbHostRtt(p->host); - debug(15, 5) ("neighborsDigestSelect: peer %s rtt: %d\n", - p->host, p_rtt); + debugs(15, 5, "neighborsDigestSelect: peer " << p->host << " rtt: " << p_rtt); /* is this peer better than others in terms of rtt ? */ if (!best_p || (p_rtt && p_rtt < best_rtt)) { @@ -863,13 +859,11 @@ neighborsDigestSelect(HttpRequest * request) if (p_rtt) /* informative choice (aka educated guess) */ ichoice_count++; - debug(15, 4) ("neighborsDigestSelect: peer %s leads with rtt %d\n", - p->host, best_rtt); + debugs(15, 4, "neighborsDigestSelect: peer " << p->host << " leads with rtt " << best_rtt); } } - debug(15, 4) ("neighborsDigestSelect: choices: %d (%d)\n", - choice_count, ichoice_count); + debugs(15, 4, "neighborsDigestSelect: choices: " << choice_count << " (" << ichoice_count << ")"); peerNoteDigestLookup(request, best_p, best_p ? LOOKUP_HIT : (choice_count ? LOOKUP_MISS : LOOKUP_NONE)); request->hier.n_choices = choice_count; @@ -891,8 +885,9 @@ peerNoteDigestLookup(HttpRequest * request, peer * p, lookup_t lookup) request->hier.cd_lookup = lookup; - debug(15, 4) ("peerNoteDigestLookup: peer %s, lookup: %s\n", - p ? p->host : "", lookup_t_str[lookup]); + debugs(15, 4, "peerNoteDigestLookup: peer " << + (p ? p->host : "") << ", lookup: " << + lookup_t_str[lookup] ); #endif } @@ -901,8 +896,7 @@ static void neighborAlive(peer * p, const MemObject * mem, const icp_common_t * header) { if (p->stats.logged_state == PEER_DEAD && p->tcp_up) { - debug(15, 1) ("Detected REVIVED %s: %s\n", - neighborTypeStr(p), p->name); + debugs(15, 1, "Detected REVIVED " << neighborTypeStr(p) << ": " << p->name); p->stats.logged_state = PEER_ALIVE; } @@ -946,8 +940,7 @@ static void neighborAliveHtcp(peer * p, const MemObject * mem, const htcpReplyData * htcp) { if (p->stats.logged_state == PEER_DEAD && p->tcp_up) { - debug(15, 1) ("Detected REVIVED %s: %s\n", - neighborTypeStr(p), p->name); + debugs(15, 1, "Detected REVIVED " << neighborTypeStr(p) << ": " << p->name); p->stats.logged_state = PEER_ALIVE; } @@ -1005,8 +998,7 @@ neighborIgnoreNonPeer(const struct sockaddr_in *from, icp_opcode opcode) np->icp.counts[opcode]++; if (isPowTen(++np->stats.ignored_replies)) - debug(15, 1) ("WARNING: Ignored %d replies from non-peer %s\n", - np->stats.ignored_replies, np->host); + debugs(15, 1, "WARNING: Ignored " << np->stats.ignored_replies << " replies from non-peer " << np->host); } /* ignoreMulticastReply @@ -1047,8 +1039,7 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct socka char *opcode_d; icp_opcode opcode = (icp_opcode) header->opcode; - debug(15, 6) ("neighborsUdpAck: opcode %d '%s'\n", - (int) opcode, storeKeyText(key)); + debugs(15, 6, "neighborsUdpAck: opcode " << (int) opcode << " '" << storeKeyText(key) << "'"); if (NULL != (entry = Store::Root().get(key))) mem = entry->mem_obj; @@ -1067,8 +1058,7 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct socka /* Does the entry exist? */ if (NULL == entry) { - debug(12, 3) ("neighborsUdpAck: Cache key '%s' not found\n", - storeKeyText(key)); + debugs(12, 3, "neighborsUdpAck: Cache key '" << storeKeyText(key) << "' not found"); neighborCountIgnored(p); return; } @@ -1076,38 +1066,33 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct socka /* check if someone is already fetching it */ if (EBIT_TEST(entry->flags, ENTRY_DISPATCHED)) { - debug(15, 3) ("neighborsUdpAck: '%s' already being fetched.\n", - storeKeyText(key)); + debugs(15, 3, "neighborsUdpAck: '" << storeKeyText(key) << "' already being fetched."); neighborCountIgnored(p); return; } if (mem == NULL) { - debug(15, 2) ("Ignoring %s for missing mem_obj: %s\n", - opcode_d, storeKeyText(key)); + debugs(15, 2, "Ignoring " << opcode_d << " for missing mem_obj: " << storeKeyText(key)); neighborCountIgnored(p); return; } if (entry->ping_status != PING_WAITING) { - debug(15, 2) ("neighborsUdpAck: Late %s for %s\n", - opcode_d, storeKeyText(key)); + debugs(15, 2, "neighborsUdpAck: Late " << opcode_d << " for " << storeKeyText(key)); neighborCountIgnored(p); return; } if (entry->lock_count == 0) { - debug(12, 1) ("neighborsUdpAck: '%s' has no locks\n", - storeKeyText(key)); + debugs(12, 1, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks"); neighborCountIgnored(p); return; } - debug(15, 3) ("neighborsUdpAck: %s for '%s' from %s \n", - opcode_d, storeKeyText(key), p ? p->host : "source"); + debugs(15, 3, "neighborsUdpAck: " << opcode_d << " for '" << storeKeyText(key) << "' from " << (p ? p->host : "source") << " "); if (p) { @@ -1145,7 +1130,7 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct socka } else if (opcode == ICP_SECHO) { if (p) { - debug(15, 1) ("Ignoring SECHO from neighbor %s\n", p->host); + debugs(15, 1, "Ignoring SECHO from neighbor " << p->host); neighborCountIgnored(p); #if ALLOW_SOURCE_PING @@ -1154,7 +1139,7 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct socka #endif } else { - debug(15, 1) ("Unsolicited SECHO from %s\n", inet_ntoa(from->sin_addr)); + debugs(15, 1, "Unsolicited SECHO from " << inet_ntoa(from->sin_addr)); } } else if (opcode == ICP_DENIED) { @@ -1162,8 +1147,8 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct socka neighborIgnoreNonPeer(from, opcode); } else if (p->stats.pings_acked > 100) { if (100 * p->icp.counts[ICP_DENIED] / p->stats.pings_acked > 95) { - debug(15, 0) ("95%% of replies from '%s' are UDP_DENIED\n", p->host); - debug(15, 0) ("Disabling '%s', please check your configuration.\n", p->host); + debugs(15, 0, "95%% of replies from '" << p->host << "' are UDP_DENIED"); + debugs(15, 0, "Disabling '" << p->host << "', please check your configuration."); neighborRemove(p); p = NULL; } else { @@ -1175,7 +1160,7 @@ neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct socka mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); } else { - debug(15, 0) ("neighborsUdpAck: Unexpected ICP reply: %s\n", opcode_d); + debugs(15, 0, "neighborsUdpAck: Unexpected ICP reply: " << opcode_d); } } @@ -1279,22 +1264,21 @@ peerDNSConfigure(const ipcache_addrs * ia, void *data) int j; if (p->n_addresses == 0) { - debug(15, 1) ("Configuring %s %s/%d/%d\n", neighborTypeStr(p), - p->host, p->http_port, p->icp.port); + debugs(15, 1, "Configuring " << neighborTypeStr(p) << " " << p->host << "/" << p->http_port << "/" << p->icp.port); if (p->type == PEER_MULTICAST) - debug(15, 1) (" Multicast TTL = %d\n", p->mcast.ttl); + debugs(15, 1, " Multicast TTL = " << p->mcast.ttl); } p->n_addresses = 0; if (ia == NULL) { - debug(0, 0) ("WARNING: DNS lookup for '%s' failed!\n", p->host); + debugs(0, 0, "WARNING: DNS lookup for '" << p->host << "' failed!"); return; } if ((int) ia->count < 1) { - debug(0, 0) ("WARNING: No IP address found for '%s'!\n", p->host); + debugs(0, 0, "WARNING: No IP address found for '" << p->host << "'!"); return; } @@ -1302,7 +1286,7 @@ peerDNSConfigure(const ipcache_addrs * ia, void *data) for (j = 0; j < (int) ia->count && j < PEER_MAX_ADDRESSES; j++) { p->addresses[j] = ia->in_addrs[j]; - debug(15, 2) ("--> IP address #%d: %s\n", j, inet_ntoa(p->addresses[j])); + debugs(15, 2, "--> IP address #" << j << ": " << inet_ntoa(p->addresses[j])); p->n_addresses++; } @@ -1348,15 +1332,15 @@ peerConnectFailedSilent(peer * p) p->stats.last_connect_failure = squid_curtime; if (!p->tcp_up) { - debug(15, 2) ("TCP connection to %s/%d dead\n", p->host, p->http_port); + debugs(15, 2, "TCP connection to " << p->host << "/" << p->http_port << + " dead"); return; } p->tcp_up--; if (!p->tcp_up) { - debug(15, 1) ("Detected DEAD %s: %s\n", - neighborTypeStr(p), p->name); + debugs(15, 1, "Detected DEAD " << neighborTypeStr(p) << ": " << p->name); p->stats.logged_state = PEER_DEAD; } } @@ -1364,7 +1348,7 @@ peerConnectFailedSilent(peer * p) void peerConnectFailed(peer *p) { - debug(15, 1) ("TCP connection to %s/%d failed\n", p->host, p->http_port); + debugs(15, 1, "TCP connection to " << p->host << "/" << p->http_port << " failed"); peerConnectFailedSilent(p); } @@ -1372,9 +1356,8 @@ void peerConnectSucceded(peer * p) { if (!p->tcp_up) { - debug(15, 2) ("TCP connection to %s/%d succeded\n", p->host, p->http_port); - debug(15, 1) ("Detected REVIVED %s: %s\n", - neighborTypeStr(p), p->name); + debugs(15, 2, "TCP connection to " << p->host << "/" << p->http_port << " succeded"); + debugs(15, 1, "Detected REVIVED " << neighborTypeStr(p) << ": " << p->name); p->stats.logged_state = PEER_ALIVE; if (!p->n_addresses) ipcache_nbgethostbyname(p->host, peerDNSConfigure, p); @@ -1517,11 +1500,9 @@ peerCountMcastPeersDone(void *data) (double) psstate->ping.n_recv, ++p->mcast.n_times_counted, 10); - debug(15, 1) ("Group %s: %d replies, %4.1f average, RTT %d\n", - p->host, - psstate->ping.n_recv, - p->mcast.avg_n_members, - p->stats.rtt); + debugs(15, 1, "Group " << p->host << ": " << psstate->ping.n_recv << + " replies, "<< std::setw(4)<< std::setprecision(2) << + p->mcast.avg_n_members <<" average, RTT " << p->stats.rtt); p->mcast.n_replies_expected = (int) p->mcast.avg_n_members; } @@ -1767,8 +1748,9 @@ neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const struct soc MemObject *mem = NULL; peer *p; peer_t ntype = PEER_NONE; - debug(15, 6) ("neighborsHtcpReply: %s %s\n", - htcp->hit ? "HIT" : "MISS", storeKeyText(key)); + debugs(15, 6, "neighborsHtcpReply: " << + (htcp->hit ? "HIT" : "MISS") << " " << + storeKeyText(key) ); if (NULL != e) mem = e->mem_obj; @@ -1779,8 +1761,7 @@ neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const struct soc /* Does the entry exist? */ if (NULL == e) { - debug(12, 3) ("neighyborsHtcpReply: Cache key '%s' not found\n", - storeKeyText(key)); + debugs(12, 3, "neighyborsHtcpReply: Cache key '" << storeKeyText(key) << "' not found"); neighborCountIgnored(p); return; } @@ -1788,32 +1769,28 @@ neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const struct soc /* check if someone is already fetching it */ if (EBIT_TEST(e->flags, ENTRY_DISPATCHED)) { - debug(15, 3) ("neighborsUdpAck: '%s' already being fetched.\n", - storeKeyText(key)); + debugs(15, 3, "neighborsUdpAck: '" << storeKeyText(key) << "' already being fetched."); neighborCountIgnored(p); return; } if (mem == NULL) { - debug(15, 2) ("Ignoring reply for missing mem_obj: %s\n", - storeKeyText(key)); + debugs(15, 2, "Ignoring reply for missing mem_obj: " << storeKeyText(key)); neighborCountIgnored(p); return; } if (e->ping_status != PING_WAITING) { - debug(15, 2) ("neighborsUdpAck: Entry %s is not PING_WAITING\n", - storeKeyText(key)); + debugs(15, 2, "neighborsUdpAck: Entry " << storeKeyText(key) << " is not PING_WAITING"); neighborCountIgnored(p); return; } if (e->lock_count == 0) { - debug(12, 1) ("neighborsUdpAck: '%s' has no locks\n", - storeKeyText(key)); + debugs(12, 1, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks"); neighborCountIgnored(p); return; } @@ -1830,7 +1807,7 @@ neighborsHtcpReply(const cache_key * key, htcpReplyData * htcp, const struct soc return; } - debug(15, 3) ("neighborsHtcpReply: e = %p\n", e); + debugs(15, 3, "neighborsHtcpReply: e = " << e); mem->ping_reply_callback(p, ntype, PROTO_HTCP, htcp, mem->ircb_data); } diff --git a/src/net_db.cc b/src/net_db.cc index 8464b5251a..97a15b8b03 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.192 2007/04/21 07:14:14 wessels Exp $ + * $Id: net_db.cc,v 1.193 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -306,13 +306,12 @@ netdbSendPing(const ipcache_addrs * ia, void *data) if (na == NULL) na = netdbAdd(addr); - debug(38, 3) ("netdbSendPing: %s moved from %s to %s\n", - hostname, n->network, na->network); + debugs(38, 3, "netdbSendPing: " << hostname << " moved from " << n->network << " to " << na->network); x = (net_db_name *) hash_lookup(host_table, hostname); if (x == NULL) { - debug(38, 1) ("netdbSendPing: net_db_name list bug: %s not found", hostname); + debugs(38, 1, "netdbSendPing: net_db_name list bug: " << hostname << " not found"); xfree(hostname); return; } @@ -336,7 +335,7 @@ netdbSendPing(const ipcache_addrs * ia, void *data) } if (n->next_ping_time <= squid_curtime) { - debug(38, 3) ("netdbSendPing: pinging %s\n", hostname); + debugs(38, 3, "netdbSendPing: pinging " << hostname); icmpDomainPing(addr, hostname); n->pings_sent++; n->next_ping_time = squid_curtime + Config.Netdb.period; @@ -418,8 +417,7 @@ netdbPeerAdd(netdbEntry * n, peer * e) else n->n_peers_alloc <<= 1; - debug(38, 3) ("netdbPeerAdd: Growing peer list for '%s' to %d\n", - n->network, n->n_peers_alloc); + debugs(38, 3, "netdbPeerAdd: Growing peer list for '" << n->network << "' to " << n->n_peers_alloc); n->peers = (net_db_peer *)xcalloc(n->n_peers_alloc, sizeof(net_db_peer)); @@ -486,7 +484,7 @@ netdbSaveState(void *foo) lf = logfileOpen(path, 4096, 0); if (NULL == lf) { - debug(50, 1) ("netdbSaveState: %s: %s\n", path, xstrerror()); + debugs(50, 1, "netdbSaveState: " << path << ": " << xstrerror()); return; } @@ -518,8 +516,9 @@ netdbSaveState(void *foo) logfileClose(lf); getCurrentTime(); - debug(38, 1) ("NETDB state saved; %d entries, %d msec\n", - count, tvSubMsec(start, current_time)); + debugs(38, 1, "NETDB state saved; " << + count << " entries, " << + tvSubMsec(start, current_time) << " msec" ); eventAddIsh("netdbSaveState", netdbSaveState, NULL, 3600.0, 1); } @@ -639,8 +638,9 @@ netdbReloadState(void) xfree(buf); getCurrentTime(); - debug(38, 1) ("NETDB state reloaded; %d entries, %d msec\n", - count, tvSubMsec(start, current_time)); + debugs(38, 1, "NETDB state reloaded; " << + count << " entries, " << + tvSubMsec(start, current_time) << " msec" ); } static const char * @@ -695,19 +695,19 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer recievedData) rec_sz += 1 + sizeof(addr.s_addr); rec_sz += 1 + sizeof(int); rec_sz += 1 + sizeof(int); - debug(38, 3) ("netdbExchangeHandleReply: %d read bytes\n", (int) recievedData.length); + debugs(38, 3, "netdbExchangeHandleReply: " << (int) recievedData.length << " read bytes"); if (!cbdataReferenceValid(ex->p)) { - debug(38, 3) ("netdbExchangeHandleReply: Peer became invalid\n"); + debugs(38, 3, "netdbExchangeHandleReply: Peer became invalid"); netdbExchangeDone(ex); return; } - debug(38, 3) ("netdbExchangeHandleReply: for '%s:%d'\n", ex->p->host, ex->p->http_port); + debugs(38, 3, "netdbExchangeHandleReply: for '" << ex->p->host << ":" << ex->p->http_port << "'"); if (recievedData.length == 0 && !recievedData.flags.error) { - debug(38, 3) ("netdbExchangeHandleReply: Done\n"); + debugs(38, 3, "netdbExchangeHandleReply: Done"); netdbExchangeDone(ex); return; } @@ -730,8 +730,7 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer recievedData) debugs(38, 5, "netdbExchangeHandleReply: hdr_sz = " << hdr_sz); rep = ex->e->getReply(); assert (0 != rep->sline.status); - debug(38, 3) ("netdbExchangeHandleReply: reply status %d\n", - rep->sline.status); + debugs(38, 3, "netdbExchangeHandleReply: reply status " << rep->sline.status); if (HTTP_OK != rep->sline.status) { netdbExchangeDone(ex); @@ -766,12 +765,10 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer recievedData) assert(ex->connstate == STATE_BODY); /* If we get here, we have some body to parse .. */ - debug(38, 5) ("netdbExchangeHandleReply: start parsing loop, size = %d\n", - size); + debugs(38, 5, "netdbExchangeHandleReply: start parsing loop, size = " << size); while (size >= rec_sz) { - debug(38, 5) ("netdbExchangeHandleReply: in parsing loop, size = %d\n", - size); + debugs(38, 5, "netdbExchangeHandleReply: in parsing loop, size = " << size); addr.s_addr = any_addr.s_addr; hops = rtt = 0.0; @@ -799,7 +796,7 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer recievedData) break; default: - debug(38, 1) ("netdbExchangeHandleReply: corrupt data, aborting\n"); + debugs(38, 1, "netdbExchangeHandleReply: corrupt data, aborting"); netdbExchangeDone(ex); return; } @@ -846,22 +843,23 @@ netdbExchangeHandleReply(void *data, StoreIOBuffer recievedData) */ ex->used -= oldbufofs; - debug(38, 3) ("netdbExchangeHandleReply: size left over in this buffer: %d bytes\n", size); + debugs(38, 3, "netdbExchangeHandleReply: size left over in this buffer: " << size << " bytes"); - debug(38, 3) ("netdbExchangeHandleReply: used %d entries, (x %d bytes) == %d bytes total\n", - nused, rec_sz, nused * rec_sz); + debugs(38, 3, "netdbExchangeHandleReply: used " << nused << + " entries, (x " << rec_sz << " bytes) == " << nused * rec_sz << + " bytes total"); - debug(38, 3) ("netdbExchangeHandleReply: used %ld\n", (long int) ex->used); + debugs(38, 3, "netdbExchangeHandleReply: used " << (long int) ex->used); if (EBIT_TEST(ex->e->flags, ENTRY_ABORTED)) { - debug(38, 3) ("netdbExchangeHandleReply: ENTRY_ABORTED\n"); + debugs(38, 3, "netdbExchangeHandleReply: ENTRY_ABORTED"); netdbExchangeDone(ex); } else if (ex->e->store_status == STORE_PENDING) { StoreIOBuffer tempBuffer; tempBuffer.offset = ex->used; tempBuffer.length = ex->buf_sz - ex->buf_ofs; tempBuffer.data = ex->buf + ex->buf_ofs; - debug(38, 3) ("netdbExchangeHandleReply: EOF not recieved\n"); + debugs(38, 3, "netdbExchangeHandleReply: EOF not recieved"); storeClientCopy(ex->sc, ex->e, tempBuffer, netdbExchangeHandleReply, ex); } @@ -871,7 +869,7 @@ static void netdbExchangeDone(void *data) { netdbExchangeState *ex = (netdbExchangeState *)data; - debug(38, 3) ("netdbExchangeDone: %s\n", ex->e->url()); + debugs(38, 3, "netdbExchangeDone: " << ex->e->url() ); HTTPMSGUNLOCK(ex->r); storeUnregister(ex->sc, ex->e, ex); ex->e->unlock(); @@ -941,7 +939,7 @@ netdbHandlePingReply(const struct sockaddr_in *from, int hops, int rtt) #if USE_ICMP netdbEntry *n; int N; - debug(38, 3) ("netdbHandlePingReply: from %s\n", inet_ntoa(from->sin_addr)); + debugs(38, 3, "netdbHandlePingReply: from " << inet_ntoa(from->sin_addr)); if ((n = netdbLookupAddr(from->sin_addr)) == NULL) return; @@ -958,10 +956,9 @@ netdbHandlePingReply(const struct sockaddr_in *from, int hops, int rtt) n->rtt = ((n->rtt * (N - 1)) + rtt) / N; - debug(38, 3) ("netdbHandlePingReply: %s; rtt=%5.1f hops=%4.1f\n", - n->network, - n->rtt, - n->hops); + debugs(38, 3, "netdbHandlePingReply: " << n->network << "; rtt="<< + std::setw(5)<< std::setprecision(2) << n->rtt << " hops="<< + std::setw(4) << n->hops); #endif } @@ -1024,8 +1021,8 @@ netdbDump(StoreEntry * sentry) *(list + i++) = n; if (i != memInUse(MEM_NETDBENTRY)) - debug(38, 0) ("WARNING: netdb_addrs count off, found %d, expected %d\n", - i, memInUse(MEM_NETDBENTRY)); + debugs(38, 0, "WARNING: netdb_addrs count off, found " << i << + ", expected " << memInUse(MEM_NETDBENTRY)); qsort((char *) list, i, @@ -1122,11 +1119,11 @@ netdbUpdatePeer(HttpRequest * r, peer * e, int irtt, int ihops) double rtt = (double) irtt; double hops = (double) ihops; net_db_peer *p; - debug(38, 3) ("netdbUpdatePeer: '%s', %d hops, %d rtt\n", r->host, ihops, irtt); + debugs(38, 3, "netdbUpdatePeer: '" << r->host << "', " << ihops << " hops, " << irtt << " rtt"); n = netdbLookupHost(r->host); if (n == NULL) { - debug(38, 3) ("netdbUpdatePeer: host '%s' not found\n", r->host); + debugs(38, 3, "netdbUpdatePeer: host '" << r->host << "' not found"); return; } @@ -1157,8 +1154,10 @@ netdbExchangeUpdatePeer(struct IN_ADDR addr, peer * e, double rtt, double hops) #if USE_ICMP netdbEntry *n; net_db_peer *p; - debug(38, 5) ("netdbExchangeUpdatePeer: '%s', %0.1f hops, %0.1f rtt\n", - inet_ntoa(addr), hops, rtt); + debugs(38, 5, "netdbExchangeUpdatePeer: '" << inet_ntoa(addr) << "', "<< + std::setfill('0')<< std::setprecision(2) << hops << " hops, " << + rtt << " rtt"); + n = netdbLookupAddr(addr); if (n == NULL) @@ -1196,7 +1195,7 @@ netdbDeleteAddrNetwork(struct IN_ADDR addr) if (n == NULL) return; - debug(38, 3) ("netdbDeleteAddrNetwork: %s\n", n->network); + debugs(38, 3, "netdbDeleteAddrNetwork: " << n->network); netdbRelease(n); @@ -1302,12 +1301,12 @@ netdbExchangeStart(void *data) ex = cbdataAlloc(netdbExchangeState); ex->p = cbdataReference(p); uri = internalRemoteUri(p->host, p->http_port, "/squid-internal-dynamic/", "netdb"); - debug(38, 3) ("netdbExchangeStart: Requesting '%s'\n", uri); + debugs(38, 3, "netdbExchangeStart: Requesting '" << uri << "'"); assert(NULL != uri); ex->r = HttpRequest::CreateFromUrl(uri); if (NULL == ex->r) { - debug(38, 1) ("netdbExchangeStart: Bad URI %s\n", uri); + debugs(38, 1, "netdbExchangeStart: Bad URI " << uri); return; } diff --git a/src/pconn.cc b/src/pconn.cc index 7d072ae93f..37f0b4716e 100644 --- a/src/pconn.cc +++ b/src/pconn.cc @@ -1,6 +1,6 @@ /* - * $Id: pconn.cc,v 1.48 2007/04/15 14:46:17 serassio Exp $ + * $Id: pconn.cc,v 1.49 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 48 Persistent Connections * AUTHOR: Duane Wessels @@ -87,13 +87,13 @@ IdleConnList::removeFD(int fd) { int index = findFDIndex(fd); assert(index >= 0); - debug(48, 3) ("IdleConnList::removeFD: found FD %d at index %d\n", fd, index); + debugs(48, 3, "IdleConnList::removeFD: found FD " << fd << " at index " << index); for (; index < nfds - 1; index++) fds[index] = fds[index + 1]; if (--nfds == 0) { - debug(48, 3) ("IdleConnList::removeFD: deleting %s\n", hashKeyStr(&hash)); + debugs(48, 3, "IdleConnList::removeFD: deleting " << hashKeyStr(&hash)); delete this; } } @@ -109,7 +109,7 @@ void IdleConnList::push(int fd) { if (nfds == nfds_alloc) { - debug(48, 3) ("IdleConnList::push: growing FD array\n"); + debugs(48, 3, "IdleConnList::push: growing FD array"); nfds_alloc <<= 1; int *old = fds; fds = (int *)xmalloc(nfds_alloc * sizeof(int)); @@ -151,7 +151,7 @@ IdleConnList::findUseableFD() void IdleConnList::read(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void *data) { - debug(48, 3) ("IdleConnList::read: %d bytes from FD %d\n", (int) len, fd); + debugs(48, 3, "IdleConnList::read: " << (int) len << " bytes from FD " << fd); if (flag == COMM_ERR_CLOSING) { /* Bail out early on COMM_ERR_CLOSING - close handlers will tidy up for us */ @@ -166,7 +166,7 @@ IdleConnList::read(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, v void IdleConnList::timeout(int fd, void *data) { - debug(48, 3) ("IdleConnList::timeout: FD %d\n", fd); + debugs(48, 3, "IdleConnList::timeout: FD " << fd); IdleConnList *list = (IdleConnList *) data; list->removeFD(fd); /* might delete list */ comm_close(fd); @@ -237,7 +237,7 @@ PconnPool::push(int fd, const char *host, u_short port, const char *domain, stru if (fdUsageHigh()) { - debug(48, 3) ("PconnPool::push: Not many unused FDs\n"); + debugs(48, 3, "PconnPool::push: Not many unused FDs"); comm_close(fd); return; } else if (shutting_down) @@ -253,7 +253,7 @@ PconnPool::push(int fd, const char *host, u_short port, const char *domain, stru if (list == NULL) { list = new IdleConnList(aKey, this); - debug(48, 3) ("pconnNew: adding %s\n", hashKeyStr(&list->hash)); + debugs(48, 3, "pconnNew: adding " << hashKeyStr(&list->hash)); hash_join(table, &list->hash); } @@ -262,7 +262,7 @@ PconnPool::push(int fd, const char *host, u_short port, const char *domain, stru assert(!comm_has_incomplete_write(fd)); snprintf(desc, FD_DESC_SZ, "%s idle connection", host); fd_note(fd, desc); - debug(48, 3) ("PconnPool::push: pushed FD %d for %s\n", fd, aKey); + debugs(48, 3, "PconnPool::push: pushed FD " << fd << " for " << aKey); } /* @@ -315,7 +315,7 @@ PconnModule::PconnModule() : pools(NULL), poolCount(0) { pools = (PconnPool **) xcalloc(MAX_NUM_PCONN_POOLS, sizeof(*pools)); pconn_fds_pool = memPoolCreate("pconn_fds", PCONN_FDS_SZ * sizeof(int)); - debug(48, 0) ("persistent connection module initialized\n"); + debugs(48, 0, "persistent connection module initialized"); } PconnModule * diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 21b50e46b9..52c6ae6a45 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.121 2007/04/21 07:14:14 wessels Exp $ + * $Id: peer_digest.cc,v 1.122 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -187,8 +187,7 @@ peerDigestNeeded(PeerDigest * pd) static void peerDigestDisable(PeerDigest * pd) { - debug(72, 2) ("peerDigestDisable: peer %s disabled for good\n", - pd->host.buf()); + debugs(72, 2, "peerDigestDisable: peer " << pd->host.buf() << " disabled for good"); pd->times.disabled = squid_curtime; pd->times.next_check = -1; /* never */ pd->flags.usable = 0; @@ -232,8 +231,7 @@ peerDigestSetCheck(PeerDigest * pd, time_t delay) { 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", - pd->host.buf(), (int) delay); + debugs(72, 3, "peerDigestSetCheck: will check peer " << pd->host.buf() << " in " << (int) delay << " secs"); } /* @@ -243,12 +241,10 @@ void peerDigestNotePeerGone(PeerDigest * pd) { if (pd->flags.requested) { - debug(72, 2) ("peerDigest: peer %s gone, will destroy after fetch.\n", - pd->host.buf()); + debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " gone, will destroy after fetch."); /* do nothing now, the fetching chain will notice and take action */ } else { - debug(72, 2) ("peerDigest: peer %s is gone, destroying now.\n", - pd->host.buf()); + debugs(72, 2, "peerDigest: peer " << pd->host.buf() << " is gone, destroying now."); peerDigestDestroy(pd); } } @@ -271,9 +267,10 @@ peerDigestCheck(void *data) return; } - debug(72, 3) ("peerDigestCheck: peer %s:%d\n", pd->peer->host, pd->peer->http_port); - debug(72, 3) ("peerDigestCheck: time: %ld, last received: %ld (%+d)\n", - (long int) squid_curtime, (long int) pd->times.received, (int) (squid_curtime - pd->times.received)); + debugs(72, 3, "peerDigestCheck: peer " << pd->peer->host << ":" << pd->peer->http_port); + debugs(72, 3, "peerDigestCheck: time: " << (long int) squid_curtime << + ", last received: " << (long int) pd->times.received << " (" << + std::showpos << (int) (squid_curtime - pd->times.received) << ")"); /* decide when we should send the request: * request now unless too close to other requests */ @@ -282,17 +279,21 @@ peerDigestCheck(void *data) /* per-peer limit */ if (req_time - pd->times.received < PeerDigestReqMinGap) { - debug(72, 2) ("peerDigestCheck: %s, avoiding close peer requests (%d < %d secs).\n", - pd->host.buf(), (int) (req_time - pd->times.received), - (int) PeerDigestReqMinGap); + debugs(72, 2, "peerDigestCheck: " << pd->host.buf() << + ", avoiding close peer requests (" << + (int) (req_time - pd->times.received) << " < " << + (int) PeerDigestReqMinGap << " secs)."); + 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", - pd->host.buf(), (int) (req_time - pd_last_req_time), - (int) GlobDigestReqMinGap); + debugs(72, 2, "peerDigestCheck: " << pd->host.buf() << + ", avoiding close requests (" << + (int) (req_time - pd_last_req_time) << " < " << + (int) GlobDigestReqMinGap << " secs)."); + req_time = pd_last_req_time + GlobDigestReqMinGap; } @@ -333,7 +334,7 @@ peerDigestRequest(PeerDigest * pd) key = storeKeyPublicByRequest(req); - debug(72, 2) ("peerDigestRequest: %s key: %s\n", url, storeKeyText(key)); + debugs(72, 2, "peerDigestRequest: " << url << " key: " << storeKeyText(key)); /* add custom headers */ assert(!req->header.len); @@ -373,7 +374,7 @@ peerDigestRequest(PeerDigest * pd) old_e = fetch->old_entry = Store::Root().get(key); if (old_e) { - debug(72, 5) ("peerDigestRequest: found old entry\n"); + debugs(72, 5, "peerDigestRequest: found old entry"); old_e->lock() @@ -392,7 +393,7 @@ peerDigestRequest(PeerDigest * pd) e->lastmod = old_e->lastmod; /* push towards peer cache */ - debug(72, 3) ("peerDigestRequest: forwarding to fwdStart...\n"); + debugs(72, 3, "peerDigestRequest: forwarding to fwdStart..."); FwdState::fwdStart(-1, e, req); @@ -545,9 +546,9 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) assert(reply); assert (reply->sline.status != 0); status = reply->sline.status; - debug(72, 3) ("peerDigestFetchReply: %s status: %d, expires: %ld (%+d)\n", - pd->host.buf(), status, - (long int) reply->expires, (int) (reply->expires - squid_curtime)); + debugs(72, 3, "peerDigestFetchReply: " << pd->host.buf() << " status: " << status << + ", expires: " << (long int) reply->expires << " (" << std::showpos << + (int) (reply->expires - squid_curtime) << ")"); /* this "if" is based on clientHandleIMSReply() */ @@ -584,7 +585,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) /* get rid of old entry if any */ if (fetch->old_entry) { - debug(72, 3) ("peerDigestFetchReply: got new digest, releasing old one\n"); + debugs(72, 3, "peerDigestFetchReply: got new digest, releasing old one"); storeUnregister(fetch->old_sc, fetch->old_entry, fetch); fetch->old_entry->releaseRequest(); fetch->old_entry->unlock(); @@ -635,8 +636,10 @@ peerDigestSwapInHeaders(void *data, char *buf, ssize_t size) assert (fetch->entry->getReply()->sline.status != 0); if (fetch->entry->getReply()->sline.status != HTTP_OK) { - debug(72, 1) ("peerDigestSwapInHeaders: %s status %d got cached!\n", - fetch->pd->host.buf(), fetch->entry->getReply()->sline.status); + debugs(72, 1, "peerDigestSwapInHeaders: " << fetch->pd->host.buf() << + " status " << fetch->entry->getReply()->sline.status << + " got cached!"); + peerDigestFetchAbort(fetch, buf, "internal status error"); return -1; } @@ -795,8 +798,7 @@ peerDigestFetchedEnough(DigestFetchState * fetch, char *buf, ssize_t size, const /* finish if we have a reason */ if (reason) { const int level = strstr(reason, "?!") ? 1 : 3; - debug(72, level) ("%s: peer %s, exiting after '%s'\n", - step_name, host, reason); + debugs(72, level, "" << step_name << ": peer " << host << ", exiting after '" << reason << "'"); peerDigestReqFinish(fetch, buf, 1, pdcb_valid, pcb_valid, reason, !no_bug); } else { @@ -813,8 +815,7 @@ static void peerDigestFetchStop(DigestFetchState * fetch, char *buf, const char *reason) { assert(reason); - debug(72, 2) ("peerDigestFetchStop: peer %s, reason: %s\n", - fetch->pd->host.buf(), reason); + debugs(72, 2, "peerDigestFetchStop: peer " << fetch->pd->host.buf() << ", reason: " << reason); peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 0); } @@ -823,8 +824,7 @@ static void peerDigestFetchAbort(DigestFetchState * fetch, char *buf, const char *reason) { assert(reason); - debug(72, 2) ("peerDigestFetchAbort: peer %s, reason: %s\n", - fetch->pd->host.buf(), reason); + debugs(72, 2, "peerDigestFetchAbort: peer " << fetch->pd->host.buf() << ", reason: " << reason); peerDigestReqFinish(fetch, buf, 1, 1, 1, reason, 1); } @@ -884,9 +884,7 @@ peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, int err) pd->stats.recv.msgs += fetch->recv.msg; if (err) { - debug(72, 1) ("%sdisabling (%s) digest from %s\n", - pcb_valid ? "temporary " : "", - pd->req_result, host); + debugs(72, 1, "" << (pcb_valid ? "temporary " : "" ) << "disabling (" << pd->req_result << ") digest from " << host); if (pd->cd) { cacheDigestDestroy(pd->cd); @@ -905,9 +903,9 @@ peerDigestPDFinish(DigestFetchState * fetch, int pcb_valid, int err) /* XXX: ugly condition, but how? */ if (fetch->entry->store_status == STORE_OK) - debug(72, 2) ("re-used old digest from %s\n", host); + debugs(72, 2, "re-used old digest from " << host); else - debug(72, 2) ("received valid digest from %s\n", host); + debugs(72, 2, "received valid digest from " << host); } cbdataReferenceDone(fetch->pd); @@ -921,7 +919,7 @@ peerDigestFetchFinish(DigestFetchState * fetch, int err) assert(fetch->entry && fetch->request); if (fetch->old_entry) { - debug(72, 2) ("peerDigestFetchFinish: deleting old entry\n"); + debugs(72, 2, "peerDigestFetchFinish: deleting old entry"); storeUnregister(fetch->old_sc, fetch->old_entry, fetch); fetch->old_entry->releaseRequest(); fetch->old_entry->unlock(); @@ -972,11 +970,16 @@ peerDigestFetchSetStats(DigestFetchState * fetch) fetch->expires = fetch->entry->expires; fetch->resp_time = squid_curtime - fetch->start_time; - debug(72, 3) ("peerDigestFetchFinish: recv %d bytes in %d secs\n", - fetch->recv.bytes, (int) fetch->resp_time); - debug(72, 3) ("peerDigestFetchFinish: expires: %ld (%+d), lmt: %ld (%+d)\n", - (long int) fetch->expires, (int) (fetch->expires - squid_curtime), - (long int) fetch->entry->lastmod, (int) (fetch->entry->lastmod - squid_curtime)); + debugs(72, 3, "peerDigestFetchFinish: recv " << fetch->recv.bytes << + " bytes in " << (int) fetch->resp_time << " secs"); + + debugs(72, 3, "peerDigestFetchFinish: expires: " << + (long int) fetch->expires << " (" << std::showpos << + (int) (fetch->expires - squid_curtime) << "), lmt: " << + std::noshowpos << (long int) fetch->entry->lastmod << " (" << + std::showpos << (int) (fetch->entry->lastmod - squid_curtime) << + ")"); + } @@ -995,22 +998,28 @@ peerDigestSetCBlock(PeerDigest * pd, const char *buf) 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) ("\t size: %d bytes, e-cnt: %d, e-util: %d%%\n", - cblock.mask_size, cblock.count, - xpercentInt(cblock.count, cblock.capacity)); + debugs(72, 2, "got digest cblock from " << host << "; ver: " << + (int) cblock.ver.current << " (req: " << (int) cblock.ver.required << + ")"); + + debugs(72, 2, "\t size: " << + cblock.mask_size << " bytes, e-cnt: " << + cblock.count << ", e-util: " << + 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); + debugs(72, 1, "" << host << " digest requires version " << + cblock.ver.required << "; have: " << 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); + debugs(72, 1, "" << host << " digest is version " << + cblock.ver.current << "; we require: " << + CacheDigestVer.required); + return 0; } @@ -1018,7 +1027,7 @@ peerDigestSetCBlock(PeerDigest * pd, const char *buf) 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); + debugs(72, 0, "" << host << " digest cblock is corrupted."); return 0; } @@ -1033,8 +1042,8 @@ peerDigestSetCBlock(PeerDigest * pd, const char *buf) /* 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); + debugs(72, 0, "" << host << " digest: unsupported #hash functions: " << + cblock.hash_func_count << " ? " << CacheDigestHashFuncCount << "."); return 0; } @@ -1051,8 +1060,8 @@ peerDigestSetCBlock(PeerDigest * pd, const char *buf) } if (!pd->cd) { - debug(72, 2) ("creating %s digest; size: %d (%+d) bytes\n", - host, cblock.mask_size, (int) (cblock.mask_size - freed_size)); + debugs(72, 2, "creating " << host << " digest; size: " << cblock.mask_size << " (" << + std::showpos << (int) (cblock.mask_size - freed_size) << ") bytes"); pd->cd = cacheDigestCreate(cblock.capacity, cblock.bits_per_entry); if (cblock.mask_size >= freed_size) @@ -1073,8 +1082,9 @@ peerDigestUseful(const PeerDigest * pd) 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", - pd->host.buf(), bit_util); + debugs(72, 0, "Warning: " << pd->host.buf() << + " peer digest has too many bits on (" << bit_util << "%%)."); + return 0; } diff --git a/src/peer_select.cc b/src/peer_select.cc index 96de3d698f..84bf37dfba 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.145 2007/04/21 07:14:15 wessels Exp $ + * $Id: peer_select.cc,v 1.146 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -109,7 +109,7 @@ static void peerSelectStateFree(ps_state * psstate) { if (psstate->acl_checklist) { - debug(44, 1) ("calling aclChecklistFree() from peerSelectStateFree\n"); + debugs(44, 1, "calling aclChecklistFree() from peerSelectStateFree"); delete (psstate->acl_checklist); } @@ -131,7 +131,7 @@ peerSelectIcpPing(HttpRequest * request, int direct, StoreEntry * entry) assert(entry); assert(entry->ping_status == PING_NONE); assert(direct != DIRECT_YES); - debug(44, 3) ("peerSelectIcpPing: %s\n", entry->url()); + debugs(44, 3, "peerSelectIcpPing: " << entry->url() ); if (!request->flags.hierarchical && direct != DIRECT_NO) return 0; @@ -142,7 +142,7 @@ peerSelectIcpPing(HttpRequest * request, int direct, StoreEntry * entry) n = neighborsCount(request); - debug(44, 3) ("peerSelectIcpPing: counted %d neighbors\n", n); + debugs(44, 3, "peerSelectIcpPing: counted " << n << " neighbors"); return n; } @@ -157,9 +157,9 @@ peerSelect(HttpRequest * request, ps_state *psstate; if (entry) - debug(44, 3) ("peerSelect: %s\n", entry->url()); + debugs(44, 3, "peerSelect: " << entry->url() ); else - debug(44, 3) ("peerSelect: %s\n", RequestMethodStr[request->method]); + debugs(44, 3, "peerSelect: " << RequestMethodStr[request->method]); psstate = new ps_state; @@ -192,7 +192,7 @@ peerCheckNeverDirectDone(int answer, void *data) { ps_state *psstate = (ps_state *) data; psstate->acl_checklist = NULL; - debug(44, 3) ("peerCheckNeverDirectDone: %d\n", answer); + debugs(44, 3, "peerCheckNeverDirectDone: " << answer); psstate->never_direct = answer ? 1 : -1; peerSelectFoo(psstate); } @@ -202,7 +202,7 @@ peerCheckAlwaysDirectDone(int answer, void *data) { ps_state *psstate = (ps_state *)data; psstate->acl_checklist = NULL; - debug(44, 3) ("peerCheckAlwaysDirectDone: %d\n", answer); + debugs(44, 3, "peerCheckAlwaysDirectDone: " << answer); psstate->always_direct = answer ? 1 : -1; peerSelectFoo(psstate); } @@ -216,7 +216,7 @@ peerSelectCallback(ps_state * psstate) void *cbdata; if (entry) { - debug(44, 3) ("peerSelectCallback: %s\n", entry->url()); + debugs(44, 3, "peerSelectCallback: " << entry->url() ); if (entry->ping_status == PING_WAITING) eventDelete(peerPingTimeout, psstate); @@ -225,10 +225,10 @@ peerSelectCallback(ps_state * psstate) } if (fs == NULL) { - debug(44, 1) ("Failed to select source for '%s'\n", entry->url()); - debug(44, 1) (" always_direct = %d\n", psstate->always_direct); - debug(44, 1) (" never_direct = %d\n", psstate->never_direct); - debug(44, 1) (" timedout = %d\n", psstate->ping.timedout); + debugs(44, 1, "Failed to select source for '" << entry->url() << "'" ); + debugs(44, 1, " always_direct = " << psstate->always_direct ); + debugs(44, 1, " never_direct = " << psstate->never_direct ); + debugs(44, 1, " timedout = " << psstate->ping.timedout ); } psstate->ping.stop = current_time; @@ -256,20 +256,18 @@ peerCheckNetdbDirect(ps_state * psstate) myrtt = netdbHostRtt(psstate->request->host); - debug(44, 3) ("peerCheckNetdbDirect: MY RTT = %d msec\n", myrtt); + debugs(44, 3, "peerCheckNetdbDirect: MY RTT = " << myrtt << " msec"); + debugs(44, 3, "peerCheckNetdbDirect: minimum_direct_rtt = " << Config.minDirectRtt << " msec"); - debug(44, 3) ("peerCheckNetdbDirect: minimum_direct_rtt = %d msec\n", - Config.minDirectRtt); if (myrtt && myrtt <= Config.minDirectRtt) return 1; myhops = netdbHostHops(psstate->request->host); - debug(44, 3) ("peerCheckNetdbDirect: MY hops = %d\n", myhops); + debugs(44, 3, "peerCheckNetdbDirect: MY hops = " << myhops); + debugs(44, 3, "peerCheckNetdbDirect: minimum_direct_hops = " << Config.minDirectHops); - debug(44, 3) ("peerCheckNetdbDirect: minimum_direct_hops = %d\n", - Config.minDirectHops); if (myhops && myhops <= Config.minDirectHops) return 1; @@ -279,8 +277,7 @@ peerCheckNetdbDirect(ps_state * psstate) if (p == NULL) return 0; - debug(44, 3) ("peerCheckNetdbDirect: closest_parent_miss RTT = %d msec\n", - psstate->ping.p_rtt); + debugs(44, 3, "peerCheckNetdbDirect: closest_parent_miss RTT = " << psstate->ping.p_rtt << " msec"); if (myrtt && myrtt <= psstate->ping.p_rtt) return 1; @@ -293,9 +290,7 @@ peerSelectFoo(ps_state * ps) { StoreEntry *entry = ps->entry; HttpRequest *request = ps->request; - debug(44, 3) ("peerSelectFoo: '%s %s'\n", - RequestMethodStr[request->method], - request->host); + debugs(44, 3, "peerSelectFoo: '" << RequestMethodStr[request->method] << " " << request->host << "'"); if (ps->direct == DIRECT_UNKNOWN) { if (ps->always_direct == 0 && Config.accessList.AlwaysDirect) { @@ -328,8 +323,7 @@ peerSelectFoo(ps_state * ps) ps->direct = DIRECT_MAYBE; } - debug(44, 3) ("peerSelectFoo: direct = %s\n", - DirectStr[ps->direct]); + debugs(44, 3, "peerSelectFoo: direct = " << DirectStr[ps->direct]); } if (entry == NULL) { @@ -407,7 +401,7 @@ peerGetSomeNeighbor(ps_state * ps) if ((p = netdbClosestParent(request))) { code = CLOSEST_PARENT; } else if (peerSelectIcpPing(request, ps->direct, entry)) { - debug(44, 3) ("peerSelect: Doing ICP pings\n"); + debugs(44, 3, "peerSelect: Doing ICP pings"); ps->ping.start = current_time; ps->ping.n_sent = neighborsUdpPing(request, entry, @@ -417,10 +411,11 @@ peerGetSomeNeighbor(ps_state * ps) &ps->ping.timeout); if (ps->ping.n_sent == 0) - debug(44, 0) ("WARNING: neighborsUdpPing returned 0\n"); + debugs(44, 0, "WARNING: neighborsUdpPing returned 0"); + debugs(44, 3, "peerSelect: " << ps->ping.n_replies_expected << + " ICP replies expected, RTT " << ps->ping.timeout << + " msec"); - debug(44, 3) ("peerSelect: %d ICP replies expected, RTT %d msec\n", - ps->ping.n_replies_expected, ps->ping.timeout); if (ps->ping.n_replies_expected > 0) { entry->ping_status = PING_WAITING; @@ -435,7 +430,7 @@ peerGetSomeNeighbor(ps_state * ps) if (code != HIER_NONE) { assert(p); - debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host); + debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host); peerAddFwdServer(&ps->servers, p, code); } @@ -458,7 +453,7 @@ peerGetSomeNeighborReplies(ps_state * ps) if (peerCheckNetdbDirect(ps)) { code = CLOSEST_DIRECT; - debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], request->host); + debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << request->host); peerAddFwdServer(&ps->servers, NULL, code); return; } @@ -480,7 +475,7 @@ peerGetSomeNeighborReplies(ps_state * ps) } if (p && code != HIER_NONE) { - debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host); + debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host); peerAddFwdServer(&ps->servers, p, code); } } @@ -511,9 +506,7 @@ peerGetSomeParent(ps_state * ps) peer *p; HttpRequest *request = ps->request; hier_code code = HIER_NONE; - debug(44, 3) ("peerGetSomeParent: %s %s\n", - RequestMethodStr[request->method], - request->host); + debugs(44, 3, "peerGetSomeParent: " << RequestMethodStr[request->method] << " " << request->host); if (ps->direct == DIRECT_YES) return; @@ -537,7 +530,7 @@ peerGetSomeParent(ps_state * ps) } if (code != HIER_NONE) { - debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host); + debugs(44, 3, "peerSelect: " << hier_strings[code] << "/" << p->host); peerAddFwdServer(&ps->servers, p, code); } } @@ -562,7 +555,7 @@ peerGetAllParents(ps_state * ps) if (!peerHTTPOkay(p, request)) continue; - debug(15, 3) ("peerGetAllParents: adding alive parent %s\n", p->host); + debugs(15, 3, "peerGetAllParents: adding alive parent " << p->host); peerAddFwdServer(&ps->servers, p, ANY_OLD_PARENT); } @@ -584,7 +577,7 @@ peerPingTimeout(void *data) StoreEntry *entry = psstate->entry; if (entry) - debug(44, 3) ("peerPingTimeout: '%s'\n", entry->url()); + debugs(44, 3, "peerPingTimeout: '" << entry->url() << "'" ); if (!cbdataReferenceValid(psstate->callback_data)) { /* request aborted */ @@ -652,9 +645,7 @@ peerHandleIcpReply(peer * p, peer_t type, icp_common_t * header, void *data) { ps_state *psstate = (ps_state *)data; icp_opcode op = header->getOpCode(); - debug(44, 3) ("peerHandleIcpReply: %s %s\n", - icp_opcode_str[op], - psstate->entry->url()); + debugs(44, 3, "peerHandleIcpReply: " << icp_opcode_str[op] << " " << psstate->entry->url() ); #if USE_CACHE_DIGESTS && 0 /* do cd lookup to count false misses */ @@ -695,9 +686,9 @@ static void peerHandleHtcpReply(peer * p, peer_t type, htcpReplyData * htcp, void *data) { ps_state *psstate = (ps_state *)data; - debug(44, 3) ("peerHandleHtcpReply: %s %s\n", - htcp->hit ? "HIT" : "MISS", - psstate->entry->url()); + debugs(44, 3, "peerHandleHtcpReply: " << + (htcp->hit ? "HIT" : "MISS") << " " << + psstate->entry->url() ); psstate->ping.n_recv++; if (htcp->hit) { @@ -771,16 +762,16 @@ peerHandlePingReply(peer * p, peer_t type, protocol_t proto, void *pingdata, voi #endif else - debug(44, 1) ("peerHandlePingReply: unknown protocol_t %d\n", (int) proto); + debugs(44, 1, "peerHandlePingReply: unknown protocol_t " << (int) proto); } static void peerAddFwdServer(FwdServer ** FSVR, peer * p, hier_code code) { FwdServer *fs = (FwdServer *)memAllocate(MEM_FWD_SERVER); - debug(44, 5) ("peerAddFwdServer: adding %s %s\n", - p ? p->host : "DIRECT", - hier_strings[code]); + debugs(44, 5, "peerAddFwdServer: adding " << + (p ? p->host : "DIRECT") << " " << + hier_strings[code] ); fs->_peer = cbdataReference(p); fs->code = code; diff --git a/src/pinger.cc b/src/pinger.cc index dbb93d5676..369ffaa91a 100644 --- a/src/pinger.cc +++ b/src/pinger.cc @@ -1,6 +1,6 @@ /* - * $Id: pinger.cc,v 1.57 2007/04/24 15:04:22 hno Exp $ + * $Id: pinger.cc,v 1.58 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 42 ICMP Pinger program * AUTHOR: Duane Wessels @@ -248,7 +248,7 @@ pingerOpen(void) if (x < (int)sizeof(wpi)) { getCurrentTime(); - debug(42, 0) ("pingerOpen: read: FD 0: %s\n", xstrerror()); + debugs(42, 0, "pingerOpen: read: FD 0: " << xstrerror()); write(1, "ERR\n", 4); exit(1); } @@ -260,7 +260,7 @@ pingerOpen(void) if (x < (int)sizeof(PS)) { getCurrentTime(); - debug(42, 0) ("pingerOpen: read: FD 0: %s\n", xstrerror()); + debugs(42, 0, "pingerOpen: read: FD 0: " << xstrerror()); write(1, "ERR\n", 4); exit(1); } @@ -269,19 +269,19 @@ pingerOpen(void) #endif if ((proto = getprotobyname("icmp")) == 0) { - debug(42, 0) ("pingerOpen: unknown protocol: icmp\n"); + debugs(42, 0, "pingerOpen: unknown protocol: icmp"); exit(1); } icmp_sock = socket(PF_INET, SOCK_RAW, proto->p_proto); if (icmp_sock < 0) { - debug(50, 0) ("pingerOpen: icmp_sock: %s\n", xstrerror()); + debugs(50, 0, "pingerOpen: icmp_sock: " << xstrerror()); exit(1); } icmp_ident = getpid() & 0xffff; - debug(42, 0) ("pinger: ICMP socket opened\n"); + debugs(42, 0, "pinger: ICMP socket opened"); #ifdef _SQUID_MSWIN_ socket_to_squid = @@ -290,7 +290,7 @@ pingerOpen(void) if (socket_to_squid == -1) { getCurrentTime(); - debug(42, 0) ("pingerOpen: WSASocket: %s\n", xstrerror()); + debugs(42, 0, "pingerOpen: WSASocket: " << xstrerror()); write(1, "ERR\n", 4); exit(1); } @@ -299,7 +299,7 @@ pingerOpen(void) if (SOCKET_ERROR == x) { getCurrentTime(); - debug(42, 0) ("pingerOpen: connect: %s\n", xstrerror()); + debugs(42, 0, "pingerOpen: connect: " << xstrerror()); write(1, "ERR\n", 4); exit(1); } @@ -309,19 +309,19 @@ pingerOpen(void) x = recv(socket_to_squid, (void *) buf, sizeof(buf), 0); if (x < 3) { - debug(42, 0) ("icmpOpen: recv: %s\n", xstrerror()); + debugs(42, 0, "icmpOpen: recv: " << xstrerror()); exit(1); } x = send(socket_to_squid, (const void *) buf, strlen(buf), 0); if (x < 3 || strncmp("OK\n", buf, 3)) { - debug(42, 0) ("icmpOpen: recv: %s\n", xstrerror()); + debugs(42, 0, "icmpOpen: recv: " << xstrerror()); exit(1); } getCurrentTime(); - debug(42, 0) ("pinger: Squid socket opened\n"); + debugs(42, 0, "pinger: Squid socket opened"); #endif } @@ -447,7 +447,8 @@ pingerRecv(void) #endif - debug(42, 9) ("pingerRecv: %d bytes from %s\n", n, inet_ntoa(from.sin_addr)); + debugs(42, 9, "pingerRecv: " << n << " bytes from " << + inet_ntoa(from.sin_addr)); ip = (struct iphdr *) (void *) pkt; @@ -522,14 +523,12 @@ static void pingerLog(struct icmphdr *icmp, struct IN_ADDR addr, int rtt, int hops) { - debug(42, 2) ("pingerLog: %9d.%06d %-16s %d %-15.15s %dms %d hops\n", - (int) current_time.tv_sec, - (int) current_time.tv_usec, - inet_ntoa(addr), - (int) icmp->icmp_type, - icmpPktStr[icmp->icmp_type], - rtt, - hops); + debugs(42, 2, "pingerLog: " << std::setw(9) << (int) current_time.tv_sec << + "."<< std::setfill('0') << std::setw(6) << + (int) current_time.tv_usec << " "<< std::left << std::setfill(' ')<< + std::setw(16) << inet_ntoa(addr) << " "<< (int) icmp->icmp_type << + " " << std::setw(15) << icmpPktStr[icmp->icmp_type] << " " << rtt << + "ms " << hops << " hops"); } static int @@ -594,7 +593,7 @@ pingerSendtoSquid(pingerReplyData * preply) int len = sizeof(pingerReplyData) - MAX_PKT_SZ + preply->psize; if (send(socket_to_squid, preply, len, 0) < 0) { - debug(50, 0) ("pinger: send: %s\n", xstrerror()); + debugs(50, 0, "pinger: send: " << xstrerror()); pingerClose(); exit(1); } @@ -642,7 +641,7 @@ main(int argc, char *argv[]) if (FD_ISSET(socket_from_squid, &R)) if (pingerReadRequest() < 0) { - debug(42, 0) ("Pinger exiting.\n"); + debugs(42, 0, "Pinger exiting."); pingerClose(); exit(1); } diff --git a/src/redirect.cc b/src/redirect.cc index 27f58352b7..eaa351b1ad 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.116 2007/04/20 22:11:34 wessels Exp $ + * $Id: redirect.cc,v 1.117 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 61 Redirector * AUTHOR: Duane Wessels @@ -70,7 +70,7 @@ redirectHandleReply(void *data, char *reply) redirectStateData *r = static_cast(data); char *t; void *cbdata; - debug(61, 5) ("redirectHandleRead: {%s}\n", reply ? reply : ""); + debugs(61, 5, "redirectHandleRead: {" << (reply ? reply : "") << "}"); if (reply) { if ((t = strchr(reply, ' '))) @@ -120,7 +120,7 @@ redirectStart(ClientHttpRequest * http, RH * handler, void *data) char buf[8192]; assert(http); assert(handler); - debug(61, 5) ("redirectStart: '%s'\n", http->uri); + debugs(61, 5, "redirectStart: '" << http->uri << "'"); if (Config.onoff.redirector_bypass && redirectors->stats.queue_size) { /* Skip redirector if there is one request queued */ diff --git a/src/referer.cc b/src/referer.cc index 83bd40ce74..8c9d69cbc9 100644 --- a/src/referer.cc +++ b/src/referer.cc @@ -1,6 +1,6 @@ /* - * $Id: referer.cc,v 1.8 2007/04/25 11:30:18 adrian Exp $ + * $Id: referer.cc,v 1.9 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 40 Referer Logging * AUTHOR: Joe Ramey (useragent) @@ -47,7 +47,7 @@ refererOpenLog(void) assert(NULL == refererlog); if (!Config.Log.referer || (0 == strcmp(Config.Log.referer, "none"))) { - debug(40, 1) ("Referer logging is disabled.\n"); + debugs(40, 1, "Referer logging is disabled."); return; } diff --git a/src/refresh.cc b/src/refresh.cc index 83e60f6c74..9d4a1fedcb 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -1,6 +1,6 @@ /* - * $Id: refresh.cc,v 1.73 2006/09/13 15:42:15 adrian Exp $ + * $Id: refresh.cc,v 1.74 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 22 Refresh Calculation * AUTHOR: Harvest Derived @@ -168,12 +168,14 @@ refreshStaleness(const StoreEntry * entry, time_t check_time, time_t age, const sf->expires = true; if (entry->expires > check_time) { - debug(22, 3) ("FRESH: expires %d >= check_time %d \n", - (int) entry->expires, (int) check_time); + debugs(22, 3, "FRESH: expires " << (int) entry->expires << + " >= check_time " << (int) check_time << " "); + return -1; } else { - debug(22, 3) ("STALE: expires %d < check_time %d \n", - (int) entry->expires, (int) check_time); + debugs(22, 3, "STALE: expires " << (int) entry->expires << + " < check_time " << (int) check_time << " "); + return (check_time - entry->expires); } } @@ -185,7 +187,7 @@ refreshStaleness(const StoreEntry * entry, time_t check_time, time_t age, const */ if (age > R->max) { - debug(22, 3) ("STALE: age %d > max %d \n", (int) age, (int) R->max); + debugs(22, 3, "STALE: age " << (int) age << " > max " << (int) R->max << " "); sf->max = true; return (age - R->max); } @@ -202,12 +204,10 @@ refreshStaleness(const StoreEntry * entry, time_t check_time, time_t age, const sf->lmfactor = true; if (age >= stale_age) { - debug(22, 3) ("STALE: age %d > stale_age %d\n", - (int) age, (int) stale_age); + debugs(22, 3, "STALE: age " << (int) age << " > stale_age " << (int) stale_age); return (age - stale_age); } else { - debug(22, 3) ("FRESH: age %d <= stale_age %d\n", - (int) age, (int) stale_age); + debugs(22, 3, "FRESH: age " << (int) age << " <= stale_age " << (int) stale_age); return -1; } } @@ -217,12 +217,12 @@ refreshStaleness(const StoreEntry * entry, time_t check_time, time_t age, const * configured minimum age. */ if (age <= R->min) { - debug(22, 3) ("FRESH: age %d <= min %d\n", (int) age, (int) R->min); + debugs(22, 3, "FRESH: age " << (int) age << " <= min " << (int) R->min); sf->min = true; return -1; } - debug(22, 3) ("STALE: age %d > min %d\n", (int) age, (int) R->min); + debugs(22, 3, "STALE: age " << (int) age << " > min " << (int) R->min); return (age - R->min); } @@ -246,7 +246,7 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) else if (request) uri = urlCanonical(request); - debug(22, 3) ("refreshCheck: '%s'\n", uri ? uri : ""); + debugs(22, 3, "refreshCheck: '" << (uri ? uri : "") << "'"); if (check_time > entry->timestamp) age = check_time - entry->timestamp; @@ -260,19 +260,21 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) staleness = refreshStaleness(entry, check_time, age, R, &sf); - debug(22, 3) ("Staleness = %d\n", staleness); + debugs(22, 3, "Staleness = " << staleness); + + debugs(22, 3, "refreshCheck: Matched '" << R->pattern << " " << + (int) R->min << " " << (int) (100.0 * R->pct) << "%% " << + (int) R->max << "'"); - debug(22, 3) ("refreshCheck: Matched '%s %d %d%% %d'\n", - R->pattern, (int) R->min, (int) (100.0 * R->pct), (int) R->max); - debug(22, 3) ("refreshCheck: age = %d\n", (int) age); + debugs(22, 3, "refreshCheck: age = " << (int) age); - debug(22, 3) ("\tcheck_time:\t%s\n", mkrfc1123(check_time)); + debugs(22, 3, "\tcheck_time:\t" << mkrfc1123(check_time)); - debug(22, 3) ("\tentry->timestamp:\t%s\n", mkrfc1123(entry->timestamp)); + debugs(22, 3, "\tentry->timestamp:\t" << mkrfc1123(entry->timestamp)); if (EBIT_TEST(entry->flags, ENTRY_REVALIDATE) && staleness > -1) { - debug(22, 3) ("refreshCheck: YES: Must revalidate stale response\n"); + debugs(22, 3, "refreshCheck: YES: Must revalidate stale response"); return STALE_MUST_REVALIDATE; } @@ -282,7 +284,7 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) if (request->flags.ims && (R->flags.refresh_ims || Config.onoff.refresh_all_ims)) { /* The clients no-cache header is changed into a IMS query */ - debug(22, 3) ("refreshCheck: YES: refresh-ims\n"); + debugs(22, 3, "refreshCheck: YES: refresh-ims"); return STALE_FORCED_RELOAD; } @@ -292,14 +294,14 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) (void) 0; } else if (R->flags.ignore_reload) { /* The clients no-cache header is ignored */ - debug(22, 3) ("refreshCheck: MAYBE: ignore-reload\n"); + debugs(22, 3, "refreshCheck: MAYBE: ignore-reload"); } else if (R->flags.reload_into_ims || Config.onoff.reload_into_ims) { /* The clients no-cache header is changed into a IMS query */ - debug(22, 3) ("refreshCheck: YES: reload-into-ims\n"); + debugs(22, 3, "refreshCheck: YES: reload-into-ims"); return STALE_RELOAD_INTO_IMS; } else { /* The clients no-cache header is not overridden on this request */ - debug(22, 3) ("refreshCheck: YES: client reload\n"); + debugs(22, 3, "refreshCheck: YES: client reload"); request->flags.nocache = 1; return STALE_FORCED_RELOAD; } @@ -314,13 +316,13 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) #if 0 if (cc->max_age == 0) { - debug (22,3) ("refreshCheck: YES: client-max-age = 0\n"); + debugs(22, 3, "refreshCheck: YES: client-max-age = 0"); return STALE_EXCEEDS_REQUEST_MAX_AGE_VALUE; } #endif if (age > cc->max_age) { - debug(22, 3) ("refreshCheck: YES: age > client-max-age\n"); + debugs(22, 3, "refreshCheck: YES: age > client-max-age"); return STALE_EXCEEDS_REQUEST_MAX_AGE_VALUE; } } @@ -329,10 +331,10 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) if (EBIT_TEST(cc->mask, CC_MAX_STALE) && staleness > -1) { if (cc->max_stale < 0) { /* max-stale directive without a value */ - debug(22, 3) ("refreshCheck: NO: max-stale wildcard\n"); + debugs(22, 3, "refreshCheck: NO: max-stale wildcard"); return FRESH_REQUEST_MAX_STALE_ALL; } else if (staleness < cc->max_stale) { - debug(22, 3) ("refreshCheck: NO: staleness < max-stale\n"); + debugs(22, 3, "refreshCheck: NO: staleness < max-stale"); return FRESH_REQUEST_MAX_STALE_VALUE; } } @@ -340,22 +342,22 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) } if (-1 == staleness) { - debug(22, 3) ("refreshCheck: object isn't stale..\n"); + debugs(22, 3, "refreshCheck: object isn't stale.."); if (sf.expires) { - debug(22, 3) ("refreshCheck: returning FRESH_EXPIRES\n"); + debugs(22, 3, "refreshCheck: returning FRESH_EXPIRES"); return FRESH_EXPIRES; } assert(!sf.max); if (sf.lmfactor) { - debug(22, 3) ("refreshCheck: returning FRESH_LMFACTOR_RULE\n"); + debugs(22, 3, "refreshCheck: returning FRESH_LMFACTOR_RULE"); return FRESH_LMFACTOR_RULE; } assert(sf.min); - debug(22, 3) ("refreshCheck: returning FRESH_MIN_RULE\n"); + debugs(22, 3, "refreshCheck: returning FRESH_MIN_RULE"); return FRESH_MIN_RULE; } @@ -367,7 +369,7 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) #if HTTP_VIOLATIONS if (R->flags.override_expire && age < R->min) { - debug(22, 3) ("refreshCheck: NO: age < min && override-expire\n"); + debugs(22, 3, "refreshCheck: NO: age < min && override-expire"); return FRESH_OVERRIDE_EXPIRES; } @@ -382,7 +384,7 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) #if HTTP_VIOLATIONS if (R->flags.override_lastmod && age < R->min) { - debug(22, 3) ("refreshCheck: NO: age < min && override-lastmod\n"); + debugs(22, 3, "refreshCheck: NO: age < min && override-lastmod"); return FRESH_OVERRIDE_LASTMOD; } @@ -390,7 +392,7 @@ refreshCheck(const StoreEntry * entry, HttpRequest * request, time_t delta) return STALE_LMFACTOR_RULE; } - debug(22, 3) ("refreshCheck: returning STALE_DEFAULT\n"); + debugs(22, 3, "refreshCheck: returning STALE_DEFAULT"); return STALE_DEFAULT; } @@ -483,7 +485,7 @@ time_t getMaxAge(const char *url) { const refresh_t *R; - debug(22, 3) ("getMaxAge: '%s'\n", url); + debugs(22, 3, "getMaxAge: '" << url << "'"); if ((R = refreshLimits(url))) return R->max; diff --git a/src/repl/heap/store_heap_replacement.cc b/src/repl/heap/store_heap_replacement.cc index b8f932037b..08fb4e98dc 100644 --- a/src/repl/heap/store_heap_replacement.cc +++ b/src/repl/heap/store_heap_replacement.cc @@ -1,6 +1,6 @@ /* - * $Id: store_heap_replacement.cc,v 1.14 2006/05/08 23:38:35 robertc Exp $ + * $Id: store_heap_replacement.cc,v 1.15 2007/04/28 22:26:51 hno Exp $ * * DEBUG: section 20 Storage Manager Heap-based replacement * AUTHOR: John Dilley @@ -89,8 +89,7 @@ HeapKeyGen_StoreEntry_LFUDA(void *entry, double heap_age) " heap_age=" << heap_age << " tie=" << tie << " -> " << key); if (e->mem_obj && e->mem_obj->url) - debug(81, 3) ("HeapKeyGen_StoreEntry_LFUDA: url=%s\n", - e->mem_obj->url); + debugs(81, 3, "HeapKeyGen_StoreEntry_LFUDA: url=" << e->mem_obj->url); return (double) key; } @@ -129,8 +128,7 @@ HeapKeyGen_StoreEntry_GDSF(void *entry, double heap_age) " -> " << key); if (e->mem_obj && e->mem_obj->url) - debug(81, 3) ("HeapKeyGen_StoreEntry_GDSF: url=%s\n", - e->mem_obj->url); + debugs(81, 3, "HeapKeyGen_StoreEntry_GDSF: url=" << e->mem_obj->url); return key; } @@ -146,12 +144,12 @@ heap_key HeapKeyGen_StoreEntry_LRU(void *entry, double heap_age) { StoreEntry *e = (StoreEntry *)entry; - debug(81, 3) ("HeapKeyGen_StoreEntry_LRU: %s heap_age=%f lastref=%f\n", - e->getMD5Text(), heap_age, (double) e->lastref); + debugs(81, 3, "HeapKeyGen_StoreEntry_LRU: " << + e->getMD5Text() << " heap_age=" << heap_age << + " lastref=" << (double) e->lastref ); if (e->mem_obj && e->mem_obj->url) - debug(81, 3) ("HeapKeyGen_StoreEntry_LRU: url=%s\n", - e->mem_obj->url); + debugs(81, 3, "HeapKeyGen_StoreEntry_LRU: url=" << e->mem_obj->url); return (heap_key) e->lastref; } diff --git a/src/repl/heap/store_repl_heap.cc b/src/repl/heap/store_repl_heap.cc index f686bcabd5..260c3e6f44 100644 --- a/src/repl/heap/store_repl_heap.cc +++ b/src/repl/heap/store_repl_heap.cc @@ -1,6 +1,6 @@ /* - * $Id: store_repl_heap.cc,v 1.23 2007/04/25 11:30:19 adrian Exp $ + * $Id: store_repl_heap.cc,v 1.24 2007/04/28 22:26:51 hno Exp $ * * DEBUG: section 81 Store HEAP Removal Policies * AUTHOR: Henrik Nordstrom @@ -260,8 +260,7 @@ heap_purgeDone(RemovalPurgeWalker * walker) if (heap_walker->min_age > 0) { heap->theHeap->age = heap_walker->min_age; - debug(81, 3) ("heap_purgeDone: Heap age set to %f\n", - (double) heap->theHeap->age); + debugs(81, 3, "heap_purgeDone: Heap age set to " << (double) heap->theHeap->age ); } /* @@ -326,7 +325,7 @@ createRemovalPolicy_heap(wordlist * args) keytype = args->key; args = args->next; } else { - debug(81, 1) ("createRemovalPolicy_heap: No key type specified. Using LRU\n"); + debugs(81, 1, "createRemovalPolicy_heap: No key type specified. Using LRU"); keytype = "LRU"; } @@ -337,8 +336,7 @@ createRemovalPolicy_heap(wordlist * args) else if (!strcmp(keytype, "LRU")) heap_data->keyfunc = HeapKeyGen_StoreEntry_LRU; else { - debug(81, 0) ("createRemovalPolicy_heap: Unknown key type \"%s\". Using LRU\n", - keytype); + debugs(81, 0, "createRemovalPolicy_heap: Unknown key type \"" << keytype << "\". Using LRU"); heap_data->keyfunc = HeapKeyGen_StoreEntry_LRU; } diff --git a/src/send-announce.cc b/src/send-announce.cc index bb7839f0d9..5e9a45d457 100644 --- a/src/send-announce.cc +++ b/src/send-announce.cc @@ -1,6 +1,6 @@ /* - * $Id: send-announce.cc,v 1.67 2006/08/07 02:28:22 robertc Exp $ + * $Id: send-announce.cc,v 1.68 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 27 Cache Announcer * AUTHOR: Duane Wessels @@ -70,11 +70,11 @@ send_announce(const ipcache_addrs * ia, void *junk) int x; if (ia == NULL) { - debug(27, 1) ("send_announce: Unknown host '%s'\n", host); + debugs(27, 1, "send_announce: Unknown host '" << host << "'"); return; } - debug(27, 1) ("Sending Announcement to %s\n", host); + debugs(27, 1, "Sending Announcement to " << host); sndbuf[0] = '\0'; snprintf(tbuf, 256, "cache_version SQUID/%s\n", version_string); strcat(sndbuf, tbuf); @@ -105,7 +105,7 @@ send_announce(const ipcache_addrs * ia, void *junk) sndbuf[l] = '\0'; file_close(fd); } else { - debug(50, 1) ("send_announce: %s: %s\n", file, xstrerror()); + debugs(50, 1, "send_announce: " << file << ": " << xstrerror()); } } @@ -119,6 +119,5 @@ send_announce(const ipcache_addrs * ia, void *junk) sndbuf, strlen(sndbuf) + 1); if (x < 0) - debug(27, 1) ("send_announce: FD %d: %s\n", theOutIcpConnection, - xstrerror()); + debugs(27, 1, "send_announce: FD " << theOutIcpConnection << ": " << xstrerror()); } diff --git a/src/snmp_agent.cc b/src/snmp_agent.cc index 538e731f83..d57bc55e81 100644 --- a/src/snmp_agent.cc +++ b/src/snmp_agent.cc @@ -1,6 +1,6 @@ /* - * $Id: snmp_agent.cc,v 1.95 2007/04/25 11:30:18 adrian Exp $ + * $Id: snmp_agent.cc,v 1.96 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 49 SNMP Interface * AUTHOR: Kostas Anagnostakis @@ -49,7 +49,7 @@ variable_list * snmp_sysFn(variable_list * Var, snint * ErrP) { variable_list *Answer = NULL; - debug(49, 5) ("snmp_sysFn: Processing request:\n"); + debugs(49, 5, "snmp_sysFn: Processing request:"); snmpDebugOid(5, Var->name, Var->name_length); *ErrP = SNMP_ERR_NOERROR; @@ -86,7 +86,7 @@ snmp_confFn(variable_list * Var, snint * ErrP) { variable_list *Answer = NULL; const char *cp = NULL; - debug(49, 5) ("snmp_confFn: Processing request with magic %d!\n", Var->name[8]); + debugs(49, 5, "snmp_confFn: Processing request with magic " << Var->name[8] << "!"); *ErrP = SNMP_ERR_NOERROR; switch (Var->name[LEN_SQ_CONF]) { @@ -192,7 +192,7 @@ snmp_meshPtblFn(variable_list * Var, snint * ErrP) char *cp = NULL; peer *p = NULL; int cnt = 0; - debug(49, 5) ("snmp_meshPtblFn: peer %d requested!\n", Var->name[LEN_SQ_MESH + 3]); + debugs(49, 5, "snmp_meshPtblFn: peer " << Var->name[LEN_SQ_MESH + 3] << " requested!"); *ErrP = SNMP_ERR_NOERROR; laddr = oid2addr(&Var->name[LEN_SQ_MESH + 3]); @@ -301,7 +301,7 @@ snmp_prfSysFn(variable_list * Var, snint * ErrP) variable_list *Answer = NULL; static struct rusage rusage; - debug(49, 5) ("snmp_prfSysFn: Processing request with magic %d!\n", Var->name[LEN_SQ_PRF + 1]); + debugs(49, 5, "snmp_prfSysFn: Processing request with magic " << Var->name[LEN_SQ_PRF + 1] << "!"); *ErrP = SNMP_ERR_NOERROR; switch (Var->name[LEN_SQ_PRF + 1]) { @@ -405,7 +405,7 @@ snmp_prfProtoFn(variable_list * Var, snint * ErrP) static StatCounters *l = NULL; double x; int minutes; - debug(49, 5) ("snmp_prfProtoFn: Processing request with magic %d!\n", Var->name[LEN_SQ_PRF]); + debugs(49, 5, "snmp_prfProtoFn: Processing request with magic " << Var->name[LEN_SQ_PRF] << "!"); *ErrP = SNMP_ERR_NOERROR; switch (Var->name[LEN_SQ_PRF + 1]) { @@ -525,10 +525,8 @@ snmp_prfProtoFn(variable_list * Var, snint * ErrP) l = snmpStatGet(minutes); - debug(49, 8) ("median: min= %d, %d l= %p , f = %p\n", minutes, - Var->name[LEN_SQ_PRF + 3], l, f); - - debug(49, 8) ("median: l= %p , f = %p\n", l, f); + debugs(49, 8, "median: min= " << minutes << ", " << Var->name[LEN_SQ_PRF + 3] << " l= " << l << " , f = " << f); + debugs(49, 8, "median: l= " << l << " , f = " << f); switch (Var->name[LEN_SQ_PRF + 3]) { diff --git a/src/snmp_core.cc b/src/snmp_core.cc index 1a93dceb65..70092771fd 100644 --- a/src/snmp_core.cc +++ b/src/snmp_core.cc @@ -1,6 +1,6 @@ /* - * $Id: snmp_core.cc,v 1.76 2007/04/20 07:29:47 wessels Exp $ + * $Id: snmp_core.cc,v 1.77 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 49 SNMP support * AUTHOR: Glenn Chisholm @@ -96,9 +96,7 @@ static void snmpSnmplibDebug(int lvl, char *buf); void snmpInit(void) { - debug(49, 5) ("snmpInit: Called.\n"); - - debug(49, 5) ("snmpInit: Building SNMP mib tree structure\n"); + debugs(49, 5, "snmpInit: Building SNMP mib tree structure"); snmplib_debug_hook = snmpSnmplibDebug; @@ -354,7 +352,7 @@ snmpInit(void) ) ); - debug(49, 9) ("snmpInit: Completed SNMP mib tree structure\n"); + debugs(49, 9, "snmpInit: Completed SNMP mib tree structure"); } void @@ -366,7 +364,7 @@ snmpConnectionOpen(void) socklen_t len; int x; - debug(49, 5) ("snmpConnectionOpen: Called\n"); + debugs(49, 5, "snmpConnectionOpen: Called"); if ((port = Config.Port.snmp) > (u_short) 0) { enter_suid(); @@ -383,8 +381,7 @@ snmpConnectionOpen(void) commSetSelect(theInSnmpConnection, COMM_SELECT_READ, snmpHandleUdp, NULL, 0); - debug(1, 1) ("Accepting SNMP messages on port %d, FD %d.\n", - (int) port, theInSnmpConnection); + debugs(1, 1, "Accepting SNMP messages on port " << (int) port << ", FD " << theInSnmpConnection << "."); if (Config.Addrs.snmp_outgoing.s_addr != no_addr.s_addr) { enter_suid(); @@ -404,8 +401,7 @@ snmpConnectionOpen(void) snmpHandleUdp, NULL, 0); - debug(1, 1) ("Outgoing SNMP messages on port %d, FD %d.\n", - (int) port, theOutSnmpConnection); + debugs(1, 1, "Outgoing SNMP messages on port " << (int) port << ", FD " << theOutSnmpConnection << "."); fd_note(theOutSnmpConnection, "Outgoing SNMP socket"); @@ -423,8 +419,7 @@ snmpConnectionOpen(void) (struct sockaddr *) &xaddr, &len); if (x < 0) - debug(51, 1) ("theOutSnmpConnection FD %d: getsockname: %s\n", - theOutSnmpConnection, xstrerror()); + debugs(51, 1, "theOutSnmpConnection FD " << theOutSnmpConnection << ": getsockname: " << xstrerror()); else theOutSNMPAddr = xaddr.sin_addr; } @@ -437,7 +432,7 @@ snmpConnectionShutdown(void) return; if (theInSnmpConnection != theOutSnmpConnection) { - debug(49, 1) ("FD %d Closing SNMP socket\n", theInSnmpConnection); + debugs(49, 1, "FD " << theInSnmpConnection << " Closing SNMP socket"); comm_close(theInSnmpConnection); } @@ -465,7 +460,7 @@ snmpConnectionClose(void) snmpConnectionShutdown(); if (theOutSnmpConnection > -1) { - debug(49, 1) ("FD %d Closing SNMP socket\n", theOutSnmpConnection); + debugs(49, 1, "FD " << theOutSnmpConnection << " Closing SNMP socket"); comm_close(theOutSnmpConnection); } } @@ -487,7 +482,7 @@ snmpHandleUdp(int sock, void *not_used) snmp_request_t *snmp_rq; int len; - debug(49, 5) ("snmpHandleUdp: Called.\n"); + debugs(49, 5, "snmpHandleUdp: Called."); commSetSelect(sock, COMM_SELECT_READ, snmpHandleUdp, NULL, 0); @@ -505,10 +500,7 @@ snmpHandleUdp(int sock, void *not_used) if (len > 0) { buf[len] = '\0'; - debug(49, 3) ("snmpHandleUdp: FD %d: received %d bytes from %s.\n", - sock, - len, - inet_ntoa(from.sin_addr)); + debugs(49, 3, "snmpHandleUdp: FD " << sock << ": received " << len << " bytes from " << inet_ntoa(from.sin_addr) << "."); snmp_rq = (snmp_request_t *)xcalloc(1, sizeof(snmp_request_t)); snmp_rq->buf = (u_char *) buf; @@ -521,7 +513,7 @@ snmpHandleUdp(int sock, void *not_used) xfree(snmp_rq->outbuf); xfree(snmp_rq); } else { - debug(49, 1) ("snmpHandleUdp: FD %d recvfrom: %s\n", sock, xstrerror()); + debugs(49, 1, "snmpHandleUdp: FD " << sock << " recvfrom: " << xstrerror()); } } @@ -539,7 +531,7 @@ snmpDecodePacket(snmp_request_t * rq) int len = rq->len; int allow = 0; - debug(49, 5) ("snmpDecodePacket: Called.\n"); + debugs(49, 5, "snmpDecodePacket: Called."); /* Now that we have the data, turn it into a PDU */ PDU = snmp_pdu_create(0); rq->session.Version = SNMP_VERSION_1; @@ -557,11 +549,10 @@ snmpDecodePacket(snmp_request_t * rq) if ((snmp_coexist_V2toV1(PDU)) && (Community) && (allow)) { rq->community = Community; rq->PDU = PDU; - debug(49, 5) ("snmpAgentParse: reqid=[%d]\n", PDU->reqid); + debugs(49, 5, "snmpAgentParse: reqid=[" << PDU->reqid << "]"); snmpConstructReponse(rq); } else { - debug(49, 1) ("Failed SNMP agent query from : %s.\n", - inet_ntoa(rq->from.sin_addr)); + debugs(49, 1, "Failed SNMP agent query from : " << inet_ntoa(rq->from.sin_addr) << "."); snmp_free_pdu(PDU); } @@ -578,7 +569,7 @@ snmpConstructReponse(snmp_request_t * rq) struct snmp_pdu *RespPDU; - debug(49, 5) ("snmpConstructReponse: Called.\n"); + debugs(49, 5, "snmpConstructReponse: Called."); RespPDU = snmpAgentResponse(rq->PDU); snmp_free_pdu(rq->PDU); @@ -601,7 +592,7 @@ static struct snmp_pdu * struct snmp_pdu *Answer = NULL; - debug(49, 5) ("snmpAgentResponse: Called.\n"); + debugs(49, 5, "snmpAgentResponse: Called."); if ((Answer = snmp_pdu_create(SNMP_PDU_RESPONSE))) { @@ -633,7 +624,7 @@ static struct snmp_pdu * if (ParseFn == NULL) { Answer->errstat = SNMP_ERR_NOSUCHNAME; - debug(49, 5) ("snmpAgentResponse: No such oid. "); + debugs(49, 5, "snmpAgentResponse: No such oid. "); } else { if (get_next) { VarPtr = snmp_var_new(NextOidName, NextOidNameLen); @@ -651,7 +642,7 @@ static struct snmp_pdu * /* Was there an error? */ if ((Answer->errstat != SNMP_ERR_NOERROR) || (VarNew == NULL)) { Answer->errindex = index; - debug(49, 5) ("snmpAgentResponse: error.\n"); + debugs(49, 5, "snmpAgentResponse: error."); if (VarNew) snmp_var_free(VarNew); @@ -689,9 +680,9 @@ snmpTreeGet(oid * Current, snint CurrentLen) mib_tree_entry *mibTreeEntry = NULL; int count = 0; - debug(49, 5) ("snmpTreeGet: Called\n"); + debugs(49, 5, "snmpTreeGet: Called"); - debug(49, 6) ("snmpTreeGet: Current : \n"); + debugs(49, 6, "snmpTreeGet: Current : "); snmpDebugOid(6, Current, CurrentLen); mibTreeEntry = mib_tree_head; @@ -708,7 +699,7 @@ snmpTreeGet(oid * Current, snint CurrentLen) if (mibTreeEntry && mibTreeEntry->parsefunction) Fn = mibTreeEntry->parsefunction; - debug(49, 5) ("snmpTreeGet: return\n"); + debugs(49, 5, "snmpTreeGet: return"); return (Fn); } @@ -720,9 +711,9 @@ snmpTreeNext(oid * Current, snint CurrentLen, oid ** Next, snint * NextLen) mib_tree_entry *mibTreeEntry = NULL, *nextoid = NULL; int count = 0; - debug(49, 5) ("snmpTreeNext: Called\n"); + debugs(49, 5, "snmpTreeNext: Called"); - debug(49, 6) ("snmpTreeNext: Current : \n"); + debugs(49, 6, "snmpTreeNext: Current : "); snmpDebugOid(6, Current, CurrentLen); mibTreeEntry = mib_tree_head; @@ -741,7 +732,7 @@ snmpTreeNext(oid * Current, snint CurrentLen, oid ** Next, snint * NextLen) count++; } - debug(49, 5) ("snmpTreeNext: Recursed down to requested object\n"); + debugs(49, 5, "snmpTreeNext: Recursed down to requested object"); } else { return NULL; } @@ -762,11 +753,11 @@ snmpTreeNext(oid * Current, snint CurrentLen, oid ** Next, snint * NextLen) nextoid = snmpTreeSiblingEntry(Current[count], count, mibTreeEntry->parent); if (nextoid) { - debug(49, 5) ("snmpTreeNext: Next OID found for sibling\n"); + debugs(49, 5, "snmpTreeNext: Next OID found for sibling"); mibTreeEntry = nextoid; count++; } else { - debug(49, 5) ("snmpTreeNext: Attempting to recurse up for next object\n"); + debugs(49, 5, "snmpTreeNext: Attempting to recurse up for next object"); while (!nextoid) { count--; @@ -1041,7 +1032,7 @@ va_dcl children = va_arg(args, int); #endif - debug(49, 6) ("snmpAddNode: Children : %d, Oid : \n", children); + debugs(49, 6, "snmpAddNode: Children : " << children << ", Oid : "); snmpDebugOid(6, name, len); va_start(args, children); @@ -1118,7 +1109,7 @@ snmpDebugOid(int lvl, oid * Name, snint Len) strncat(objid, mbuf, sizeof(objid)); } - debug(49, lvl) (" oid = %s\n", objid); + debugs(49, lvl, " oid = " << objid); } static void diff --git a/src/ssl_support.cc b/src/ssl_support.cc index 82b8ac5353..3267df06a5 100644 --- a/src/ssl_support.cc +++ b/src/ssl_support.cc @@ -1,6 +1,6 @@ /* - * $Id: ssl_support.cc,v 1.34 2006/07/02 19:52:49 hno Exp $ + * $Id: ssl_support.cc,v 1.35 2007/04/28 22:26:37 hno Exp $ * * AUTHOR: Benno Rice * DEBUG: section 83 SSL accelerator support @@ -101,12 +101,12 @@ ssl_temp_rsa_cb(SSL * ssl, int anInt, int keylen) break; default: - debug(83,1)("ssl_temp_rsa_cb: Unexpected key length %d\n", keylen); + debugs(83, 1, "ssl_temp_rsa_cb: Unexpected key length " << keylen); return NULL; } if (rsa == NULL) { - debug(83,1)("ssl_temp_rsa_cb: Failed to generate key %d\n", keylen); + debugs(83, 1, "ssl_temp_rsa_cb: Failed to generate key " << keylen); return NULL; } @@ -114,7 +114,7 @@ ssl_temp_rsa_cb(SSL * ssl, int anInt, int keylen) if (do_debug(83, 5)) PEM_write_RSAPrivateKey(debug_log, rsa, NULL, NULL, 0, NULL, NULL); - debug(83,1)("Generated ephemeral RSA key of length %d\n", keylen); + debugs(83, 1, "Generated ephemeral RSA key of length " << keylen); } return rsa; @@ -134,15 +134,14 @@ ssl_verify_cb(int ok, X509_STORE_CTX * ctx) sizeof(buffer)); if (ok) { - debug(83, 5) ("SSL Certificate signature OK: %s\n", buffer); + debugs(83, 5, "SSL Certificate signature OK: " << buffer); if (server) { int i; int found = 0; char cn[1024]; X509_NAME *name = X509_get_subject_name(peer_cert); - debug(83, 3) ("Verifying server domain %s to certificate dn %s\n", - server, buffer); + debugs(83, 3, "Verifying server domain " << server << " to certificate dn " << buffer); for (i = X509_NAME_get_index_by_NID(name, NID_commonName, -1); i >= 0; i = X509_NAME_get_index_by_NID(name, NID_commonName, i)) { ASN1_STRING *data = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(name, i)); @@ -154,8 +153,7 @@ ssl_verify_cb(int ok, X509_STORE_CTX * ctx) cn[data->length] = '\0'; - debug(83, 4) ("Verifying server domain %s to certificate cn %s\n", - server, cn); + debugs(83, 4, "Verifying server domain " << server << " to certificate cn " << cn); if (matchDomainName(server, cn[0] == '*' ? cn + 1 : cn) == 0) { found = 1; @@ -164,7 +162,7 @@ ssl_verify_cb(int ok, X509_STORE_CTX * ctx) } if (!found) { - debug(83, 2) ("ERROR: Certificate %s does not match domainname %s\n", buffer, server); + debugs(83, 2, "ERROR: Certificate " << buffer << " does not match domainname " << server); ok = 0; } } @@ -172,28 +170,29 @@ ssl_verify_cb(int ok, X509_STORE_CTX * ctx) switch (ctx->error) { case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: - debug(83, 5) ("SSL Certficate error: CA not known: %s\n", buffer); + debugs(83, 5, "SSL Certficate error: CA not known: " << buffer); break; case X509_V_ERR_CERT_NOT_YET_VALID: - debug(83, 5) ("SSL Certficate not yet valid: %s\n", buffer); + debugs(83, 5, "SSL Certficate not yet valid: " << buffer); break; case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD: - debug(83, 5) ("SSL Certificate has illegal \'not before\' field: %s\n", buffer); + debugs(83, 5, "SSL Certificate has illegal \'not before\' field: " << + buffer); + break; case X509_V_ERR_CERT_HAS_EXPIRED: - debug(83, 5) ("SSL Certificate expired: %s\n", buffer); + debugs(83, 5, "SSL Certificate expired: " << buffer); break; case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD: - debug(83, 5) ("SSL Certificate has invalid \'not after\' field: %s\n", buffer); + debugs(83, 5, "SSL Certificate has invalid \'not after\' field: " << buffer); break; default: - debug(83, 1) ("SSL unknown certificate error %d in %s\n", - ctx->error, buffer); + debugs(83, 1, "SSL unknown certificate error " << ctx->error << " in " << buffer); break; } } @@ -509,13 +508,13 @@ ssl_load_crl(SSL_CTX *sslContext, const char *CRLfile) int count = 0; if (!in) { - debug(83, 2)("WARNING: Failed to open CRL file '%s'\n", CRLfile); + debugs(83, 2, "WARNING: Failed to open CRL file '" << CRLfile << "'"); return 0; } while ((crl = PEM_read_bio_X509_CRL(in,NULL,NULL,NULL))) { if (!X509_STORE_add_crl(st, crl)) - debug(83, 2)("WARNING: Failed to add CRL from file '%s'\n", CRLfile); + debugs(83, 2, "WARNING: Failed to add CRL from file '" << CRLfile << "'"); else count++; @@ -548,24 +547,24 @@ sslCreateServerContext(const char *certfile, const char *keyfile, int version, c switch (version) { case 2: - debug(83, 5) ("Using SSLv2.\n"); + debugs(83, 5, "Using SSLv2."); method = SSLv2_server_method(); break; case 3: - debug(83, 5) ("Using SSLv3.\n"); + debugs(83, 5, "Using SSLv3."); method = SSLv3_server_method(); break; case 4: - debug(83, 5) ("Using TLSv1.\n"); + debugs(83, 5, "Using TLSv1."); method = TLSv1_server_method(); break; case 1: default: - debug(83, 5) ("Using SSLv2/SSLv3.\n"); + debugs(83, 5, "Using SSLv2/SSLv3."); method = SSLv23_server_method(); break; } @@ -589,13 +588,13 @@ sslCreateServerContext(const char *certfile, const char *keyfile, int version, c } if (Config.SSL.unclean_shutdown) { - debug(83, 5) ("Enabling quiet SSL shutdowns (RFC violation).\n"); + debugs(83, 5, "Enabling quiet SSL shutdowns (RFC violation)."); SSL_CTX_set_quiet_shutdown(sslContext, 1); } if (cipher) { - debug(83, 5) ("Using chiper suite %s.\n", cipher); + debugs(83, 5, "Using chiper suite " << cipher << "."); if (!SSL_CTX_set_cipher_list(sslContext, cipher)) { ssl_error = ERR_get_error(); @@ -604,61 +603,58 @@ sslCreateServerContext(const char *certfile, const char *keyfile, int version, c } } - debug(83, 1) ("Using certificate in %s\n", certfile); + debugs(83, 1, "Using certificate in " << certfile); if (!SSL_CTX_use_certificate_chain_file(sslContext, certfile)) { ssl_error = ERR_get_error(); - debug(83, 0) ("Failed to acquire SSL certificate '%s': %s\n", - certfile, ERR_error_string(ssl_error, NULL)); + debugs(83, 0, "Failed to acquire SSL certificate '" << certfile << "': " << ERR_error_string(ssl_error, NULL) ); goto error; } - debug(83, 1) ("Using private key in %s\n", keyfile); + debugs(83, 1, "Using private key in " << keyfile); ssl_ask_password(sslContext, keyfile); if (!SSL_CTX_use_PrivateKey_file(sslContext, keyfile, SSL_FILETYPE_PEM)) { ssl_error = ERR_get_error(); - debug(83, 0) ("Failed to acquire SSL private key '%s': %s\n", - keyfile, ERR_error_string(ssl_error, NULL)); + debugs(83, 0, "Failed to acquire SSL private key '" << keyfile << "': " << ERR_error_string(ssl_error, NULL) ); goto error; } - debug(83, 5) ("Comparing private and public SSL keys.\n"); + debugs(83, 5, "Comparing private and public SSL keys."); if (!SSL_CTX_check_private_key(sslContext)) { ssl_error = ERR_get_error(); - debug(83, 0) ("SSL private key '%s' does not match public key '%s': %s\n", - certfile, keyfile, ERR_error_string(ssl_error, NULL)); + debugs(83, 0, "SSL private key '" << + certfile << "' does not match public key '" << + keyfile << "': " << ERR_error_string(ssl_error, NULL) ); goto error; } - debug(83, 9) ("Setting RSA key generation callback.\n"); + debugs(83, 9, "Setting RSA key generation callback."); SSL_CTX_set_tmp_rsa_callback(sslContext, ssl_temp_rsa_cb); - debug(83, 9) ("Setting CA certificate locations.\n"); + debugs(83, 9, "Setting CA certificate locations."); if ((CAfile || CApath) && !SSL_CTX_load_verify_locations(sslContext, CAfile, CApath)) { ssl_error = ERR_get_error(); - debug(83, 1) ("Error setting CA certificate locations: %s\n", - ERR_error_string(ssl_error, NULL)); - debug(83, 1) ("continuing anyway...\n"); + debugs(83, 1, "Error setting CA certificate locations: " << ERR_error_string(ssl_error, NULL) ); + debugs(83, 1, "continuing anyway..." ); } if (!(fl & SSL_FLAG_NO_DEFAULT_CA) && !SSL_CTX_set_default_verify_paths(sslContext)) { ssl_error = ERR_get_error(); - debug(83, 1) ("Error setting default CA certificate location: %s\n", - ERR_error_string(ssl_error, NULL)); - debug(83, 1) ("continuing anyway...\n"); + debugs(83, 1, "Error setting default CA certificate location: " << ERR_error_string(ssl_error, NULL) ); + debugs(83, 1, "continuing anyway..." ); } if (clientCA) { STACK_OF(X509_NAME) *cert_names; - debug(83, 9) ("Set client certifying authority list.\n"); + debugs(83, 9, "Set client certifying authority list."); cert_names = SSL_load_client_CA_file(clientCA); if (cert_names == NULL) { - debug(83, 1) ("Error loading the client CA certificates from '%s\': %s\n", clientCA, ERR_error_string(ERR_get_error(), NULL)); + debugs(83, 1, "Error loading the client CA certificates from '" << clientCA << "\': " << ERR_error_string(ERR_get_error(),NULL) ); goto error; } @@ -666,10 +662,10 @@ sslCreateServerContext(const char *certfile, const char *keyfile, int version, c SSL_CTX_set_client_CA_list(sslContext, cert_names); if (fl & SSL_FLAG_DELAYED_AUTH) { - debug(83, 9) ("Not requesting client certificates until acl processing requires one\n"); + debugs(83, 9, "Not requesting client certificates until acl processing requires one"); SSL_CTX_set_verify(sslContext, SSL_VERIFY_NONE, NULL); } else { - debug(83, 9) ("Requiring client certificates.\n"); + debugs(83, 9, "Requiring client certificates."); SSL_CTX_set_verify(sslContext, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, ssl_verify_cb); } @@ -687,7 +683,7 @@ sslCreateServerContext(const char *certfile, const char *keyfile, int version, c #endif } else { - debug(83, 9) ("Not requiring any client certificates\n"); + debugs(83, 9, "Not requiring any client certificates"); SSL_CTX_set_verify(sslContext, SSL_VERIFY_NONE, NULL); } @@ -702,10 +698,10 @@ sslCreateServerContext(const char *certfile, const char *keyfile, int version, c } if (!dh) - debug(83, 1) ("WARNING: Failed to read DH parameters '%s'\n", dhfile); + debugs(83, 1, "WARNING: Failed to read DH parameters '" << dhfile << "'"); else if (dh && DH_check(dh, &codes) == 0) { if (codes) { - debug(83, 1) ("WARNING: Failed to verify DH parameters '%s' (%x)\n", dhfile, codes); + debugs(83, 1, "WARNING: Failed to verify DH parameters '" << dhfile << "' (" << std::hex << codes << ")"); DH_free(dh); dh = NULL; } @@ -745,24 +741,24 @@ sslCreateClientContext(const char *certfile, const char *keyfile, int version, c switch (version) { case 2: - debug(83, 5) ("Using SSLv2.\n"); + debugs(83, 5, "Using SSLv2."); method = SSLv2_client_method(); break; case 3: - debug(83, 5) ("Using SSLv3.\n"); + debugs(83, 5, "Using SSLv3."); method = SSLv3_client_method(); break; case 4: - debug(83, 5) ("Using TLSv1.\n"); + debugs(83, 5, "Using TLSv1."); method = TLSv1_client_method(); break; case 1: default: - debug(83, 5) ("Using SSLv2/SSLv3.\n"); + debugs(83, 5, "Using SSLv2/SSLv3."); method = SSLv23_client_method(); break; } @@ -778,7 +774,7 @@ sslCreateClientContext(const char *certfile, const char *keyfile, int version, c SSL_CTX_set_options(sslContext, ssl_parse_options(options)); if (cipher) { - debug(83, 5) ("Using chiper suite %s.\n", cipher); + debugs(83, 5, "Using chiper suite " << cipher << "."); if (!SSL_CTX_set_cipher_list(sslContext, cipher)) { ssl_error = ERR_get_error(); @@ -788,7 +784,7 @@ sslCreateClientContext(const char *certfile, const char *keyfile, int version, c } if (certfile) { - debug(83, 1) ("Using certificate in %s\n", certfile); + debugs(83, 1, "Using certificate in " << certfile); if (!SSL_CTX_use_certificate_chain_file(sslContext, certfile)) { ssl_error = ERR_get_error(); @@ -796,7 +792,7 @@ sslCreateClientContext(const char *certfile, const char *keyfile, int version, c certfile, ERR_error_string(ssl_error, NULL)); } - debug(83, 1) ("Using private key in %s\n", keyfile); + debugs(83, 1, "Using private key in " << keyfile); ssl_ask_password(sslContext, keyfile); if (!SSL_CTX_use_PrivateKey_file(sslContext, keyfile, SSL_FILETYPE_PEM)) { @@ -805,7 +801,7 @@ sslCreateClientContext(const char *certfile, const char *keyfile, int version, c keyfile, ERR_error_string(ssl_error, NULL)); } - debug(83, 5) ("Comparing private and public SSL keys.\n"); + debugs(83, 5, "Comparing private and public SSL keys."); if (!SSL_CTX_check_private_key(sslContext)) { ssl_error = ERR_get_error(); @@ -814,24 +810,23 @@ sslCreateClientContext(const char *certfile, const char *keyfile, int version, c } } - debug(83, 9) ("Setting RSA key generation callback.\n"); + debugs(83, 9, "Setting RSA key generation callback."); SSL_CTX_set_tmp_rsa_callback(sslContext, ssl_temp_rsa_cb); if (fl & SSL_FLAG_DONT_VERIFY_PEER) { - debug(83, 1) ("NOTICE: Peer certificates are not verified for validity!\n"); + debugs(83, 1, "NOTICE: Peer certificates are not verified for validity!"); SSL_CTX_set_verify(sslContext, SSL_VERIFY_NONE, NULL); } else { - debug(83, 9) ("Setting certificate verification callback.\n"); + debugs(83, 9, "Setting certificate verification callback."); SSL_CTX_set_verify(sslContext, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, ssl_verify_cb); } - debug(83, 9) ("Setting CA certificate locations.\n"); + debugs(83, 9, "Setting CA certificate locations."); if ((CAfile || CApath) && !SSL_CTX_load_verify_locations(sslContext, CAfile, CApath)) { ssl_error = ERR_get_error(); - debug(83, 1) ("Error setting CA certificate locations: %s\n", - ERR_error_string(ssl_error, NULL)); - debug(83, 1) ("continuing anyway...\n"); + debugs(83, 1, "Error setting CA certificate locations: " << ERR_error_string(ssl_error, NULL)); + debugs(83, 1, "continuing anyway..." ); } if (CRLfile) { @@ -850,9 +845,8 @@ sslCreateClientContext(const char *certfile, const char *keyfile, int version, c if (!(fl & SSL_FLAG_NO_DEFAULT_CA) && !SSL_CTX_set_default_verify_paths(sslContext)) { ssl_error = ERR_get_error(); - debug(83, 1) ("Error setting default CA certificate location: %s\n", - ERR_error_string(ssl_error, NULL)); - debug(83, 1) ("continuing anyway...\n"); + debugs(83, 1, "Error setting default CA certificate location: " << ERR_error_string(ssl_error, NULL) ); + debugs(83, 1, "continuing anyway..."); } return sslContext; @@ -876,7 +870,7 @@ ssl_read_method(int fd, char *buf, int len) i = SSL_read(ssl, buf, len); if (i > 0 && SSL_pending(ssl) > 0) { - debug(83, 2) ("SSL FD %d is pending\n", fd); + debugs(83, 2, "SSL FD " << fd << " is pending"); fd_table[fd].flags.read_pending = 1; } else fd_table[fd].flags.read_pending = 0; @@ -924,7 +918,7 @@ ssl_get_attribute(X509_NAME * name, const char *attribute_name) nid = OBJ_txt2nid((char *) attribute_name); if (nid == 0) { - debug(83, 1) ("WARNING: Unknown SSL attribute name '%s'\n", attribute_name); + debugs(83, 1, "WARNING: Unknown SSL attribute name '" << attribute_name << "'"); return NULL; } diff --git a/src/stat.cc b/src/stat.cc index b5dd8fb47b..06bb8c9764 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.404 2007/04/21 07:14:15 wessels Exp $ + * $Id: stat.cc,v 1.405 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -840,8 +840,7 @@ statAvgDump(StoreEntry * sentry, int minutes, int hours) l = &CountHourHist[hours]; } else { - debug(18, 1) ("statAvgDump: Invalid args, minutes=%d, hours=%d\n", - minutes, hours); + debugs(18, 1, "statAvgDump: Invalid args, minutes=" << minutes << ", hours=" << hours); return; } @@ -1020,7 +1019,7 @@ void statInit(void) { int i; - debug(18, 5) ("statInit: Initializing...\n"); + debugs(18, 5, "statInit: Initializing..."); for (i = 0; i < N_COUNT_HIST; i++) statCountersInit(&CountHist[i]); @@ -1147,7 +1146,7 @@ statAvgTick(void *notused) int i = (int) statPctileSvc(0.5, 20, PCTILE_HTTP); if (Config.warnings.high_rptm < i) - debug(18, 0) ("WARNING: Median response time is %d milliseconds\n", i); + debugs(18, 0, "WARNING: Median response time is " << i << " milliseconds"); } if (Config.warnings.high_pf) { @@ -1158,7 +1157,7 @@ statAvgTick(void *notused) i /= (int) dt; if (Config.warnings.high_pf < i) - debug(18, 0) ("WARNING: Page faults occuring at %d/sec\n", i); + debugs(18, 0, "WARNING: Page faults occuring at " << i << "/sec"); } } @@ -1178,7 +1177,7 @@ statAvgTick(void *notused) #endif if (Config.warnings.high_memory < i) - debug(18, 0) ("WARNING: Memory usage at %lu MB\n", (unsigned long int)(i >> 20)); + debugs(18, 0, "WARNING: Memory usage at " << ((unsigned long int)(i >> 20)) << " MB"); } } @@ -1547,7 +1546,7 @@ statPctileSvc(double pctile, int interval, int which) break; default: - debug(49, 5) ("statPctileSvc: unknown type.\n"); + debugs(49, 5, "statPctileSvc: unknown type."); x = 0; } diff --git a/src/stmem.cc b/src/stmem.cc index be352e4bf3..c34eebe984 100644 --- a/src/stmem.cc +++ b/src/stmem.cc @@ -1,6 +1,6 @@ /* - * $Id: stmem.cc,v 1.89 2005/09/14 18:23:21 wessels Exp $ + * $Id: stmem.cc,v 1.90 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -91,7 +91,7 @@ bool mem_hdr::unlink(mem_node *aNode) { if (aNode->write_pending) { - debug(0,0)("cannot unlink mem_node %p while write_pending\n", aNode); + debugs(0, 0, "cannot unlink mem_node " << aNode << " while write_pending"); return false; } diff --git a/src/store.cc b/src/store.cc index aacfc5bca5..9c11c4c012 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.609 2007/04/21 07:14:15 wessels Exp $ + * $Id: store.cc,v 1.610 2007/04/28 22:26:37 hno Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -313,7 +313,7 @@ StoreEntry::storeClientType() const if (EBIT_TEST(flags, ENTRY_ABORTED)) { /* I don't think we should be adding clients to aborted entries */ - debug(20, 1) ("storeClientType: adding to ENTRY_ABORTED entry\n"); + debugs(20, 1, "storeClientType: adding to ENTRY_ABORTED entry"); return STORE_MEM_CLIENT; } @@ -406,8 +406,7 @@ destroyStoreEntry(void *data) void StoreEntry::hashInsert(const cache_key * someKey) { - debug(20, 3) ("StoreEntry::hashInsert: Inserting Entry %p key '%s'\n", - this, storeKeyText(someKey)); + debugs(20, 3, "StoreEntry::hashInsert: Inserting Entry " << this << " key '" << storeKeyText(someKey) << "'"); key = storeKeyDup(someKey); hash_join(store_table, this); } @@ -430,8 +429,7 @@ StoreEntry::purgeMem() if (mem_obj == NULL) return; - debug(20, 3) ("StoreEntry::purgeMem: Freeing memory-copy of %s\n", - getMD5Text()); + debugs(20, 3, "StoreEntry::purgeMem: Freeing memory-copy of " << getMD5Text()); destroyMemObject(); @@ -452,7 +450,7 @@ StoreEntry::lock() { lock_count++; debugs(20, 3, "StoreEntry::lock: key '" << getMD5Text() <<"' count=" << - lock_count << "\n"); + lock_count ); lastref = squid_curtime; Store::Root().reference(*this); } @@ -463,7 +461,7 @@ StoreEntry::setReleaseFlag() if (EBIT_TEST(flags, RELEASE_REQUEST)) return; - debug(20, 3) ("StoreEntry::setReleaseFlag: '%s'\n", getMD5Text()); + debugs(20, 3, "StoreEntry::setReleaseFlag: '" << getMD5Text() << "'"); EBIT_SET(flags, RELEASE_REQUEST); } @@ -492,8 +490,7 @@ int StoreEntry::unlock() { lock_count--; - debug(20, 3) ("StoreEntry::unlock: key '%s' count=%d\n", - getMD5Text(), lock_count); + debugs(20, 3, "StoreEntry::unlock: key '" << getMD5Text() << "' count=" << lock_count); if (lock_count) return (int) lock_count; @@ -513,7 +510,7 @@ StoreEntry::unlock() Store::Root().dereference(*this); if (EBIT_TEST(flags, KEY_PRIVATE)) - debug(20, 1) ("WARNING: %s:%d: found KEY_PRIVATE\n", __FILE__, __LINE__); + debugs(20, 1, "WARNING: " << __FILE__ << ":" << __LINE__ << ": found KEY_PRIVATE"); /* StoreEntry::purgeMem may free e */ purgeMem(); @@ -653,8 +650,7 @@ StoreEntry::setPublicKey() #if MORE_DEBUG_OUTPUT if (EBIT_TEST(flags, RELEASE_REQUEST)) - debug(20, 1) ("assertion failed: RELEASE key %s, url %s\n", - key, mem->url); + debugs(20, 1, "assertion failed: RELEASE key " << key << ", url " << mem->url); #endif @@ -729,7 +725,7 @@ StoreEntry::setPublicKey() newkey = storeKeyPublic(mem_obj->url, mem_obj->method); if ((e2 = (StoreEntry *) hash_lookup(store_table, newkey))) { - debug(20, 3) ("StoreEntry::setPublicKey: Making old '%s' private.\n", mem_obj->url); + debugs(20, 3, "StoreEntry::setPublicKey: Making old '" << mem_obj->url << "' private."); e2->setPrivateKey(); e2->release(); @@ -755,7 +751,7 @@ storeCreateEntry(const char *url, const char *log_url, request_flags flags, meth { StoreEntry *e = NULL; MemObject *mem = NULL; - debug(20, 3) ("storeCreateEntry: '%s'\n", url); + debugs(20, 3, "storeCreateEntry: '" << url << "'"); e = new StoreEntry(url, log_url); e->lock_count = 1; /* Note lock here w/o calling storeLock() */ @@ -792,7 +788,7 @@ storeCreateEntry(const char *url, const char *log_url, request_flags flags, meth void StoreEntry::expireNow() { - debug(20, 3) ("StoreEntry::expireNow: '%s'\n", getMD5Text()); + debugs(20, 3, "StoreEntry::expireNow: '" << getMD5Text() << "'"); expires = squid_curtime; } @@ -959,37 +955,34 @@ StoreEntry::checkCachable() #if CACHE_ALL_METHODS if (mem_obj->method != METHOD_GET) { - debug(20, 2) ("StoreEntry::checkCachable: NO: non-GET method\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: non-GET method"); store_check_cachable_hist.no.non_get++; } else #endif if (store_status == STORE_OK && EBIT_TEST(flags, ENTRY_BAD_LENGTH)) { - debug(20, 2) ("StoreEntry::checkCachable: NO: wrong content-length\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: wrong content-length"); store_check_cachable_hist.no.wrong_content_length++; } else if (!EBIT_TEST(flags, ENTRY_CACHABLE)) { - debug(20, 2) ("StoreEntry::checkCachable: NO: not cachable\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: not cachable"); store_check_cachable_hist.no.not_entry_cachable++; } else if (EBIT_TEST(flags, ENTRY_NEGCACHED)) { - debug(20, 3) ("StoreEntry::checkCachable: NO: negative cached\n"); + debugs(20, 3, "StoreEntry::checkCachable: NO: negative cached"); store_check_cachable_hist.no.negative_cached++; return 0; /* avoid release call below */ } else if ((getReply()->content_length > 0 && static_cast(getReply()->content_length) > Config.Store.maxObjectSize) || static_cast(mem_obj->endOffset()) > Config.Store.maxObjectSize) { - debug(20, 2) ("StoreEntry::checkCachable: NO: too big\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: too big"); store_check_cachable_hist.no.too_big++; } else if (getReply()->content_length > (int) Config.Store.maxObjectSize) { - debug(20, 2) - ("StoreEntry::checkCachable: NO: too big\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: too big"); store_check_cachable_hist.no.too_big++; } else if (checkTooSmall()) { - debug(20, 2) - ("StoreEntry::checkCachable: NO: too small\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: too small"); store_check_cachable_hist.no.too_small++; } else if (EBIT_TEST(flags, KEY_PRIVATE)) { - debug(20, 3) - ("StoreEntry::checkCachable: NO: private key\n"); + debugs(20, 3, "StoreEntry::checkCachable: NO: private key"); store_check_cachable_hist.no.private_key++; } else if (swap_status != SWAPOUT_NONE) { /* @@ -999,12 +992,10 @@ StoreEntry::checkCachable() */ return 1; } else if (storeTooManyDiskFilesOpen()) { - debug(20, 2) - ("StoreEntry::checkCachable: NO: too many disk files open\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: too many disk files open"); store_check_cachable_hist.no.too_many_open_files++; } else if (fdNFree() < RESERVED_FD) { - debug(20, 2) - ("StoreEntry::checkCachable: NO: too many FD's open\n"); + debugs(20, 2, "StoreEntry::checkCachable: NO: too many FD's open"); store_check_cachable_hist.no.too_many_open_fds++; } else { store_check_cachable_hist.yes.Default++; @@ -1050,7 +1041,7 @@ storeCheckCachableStats(StoreEntry *sentry) void StoreEntry::complete() { - debug(20, 3) ("storeComplete: '%s'\n", getMD5Text()); + debugs(20, 3, "storeComplete: '" << getMD5Text() << "'"); if (store_status != STORE_PENDING) { /* @@ -1101,7 +1092,7 @@ StoreEntry::abort() statCounter.aborted_requests++; assert(store_status == STORE_PENDING); assert(mem_obj != NULL); - debug(20, 6) ("storeAbort: %s\n", getMD5Text()); + debugs(20, 6, "storeAbort: " << getMD5Text()); lock() @@ -1190,9 +1181,9 @@ storeGetMemSpace(int size) } walker->Done(walker); - debug(20, 3) ("storeGetMemSpace stats:\n"); - debug(20, 3) (" %6d HOT objects\n", hot_obj_count); - debug(20, 3) (" %6d were released\n", released); + debugs(20, 3, "storeGetMemSpace stats:"); + debugs(20, 3, " " << std::setw(6) << hot_obj_count << " HOT objects"); + debugs(20, 3, " " << std::setw(6) << released << " were released"); PROF_stop(storeGetMemSpace); } @@ -1248,13 +1239,13 @@ void StoreEntry::release() { PROF_start(storeRelease); - debug(20, 3) ("storeRelease: Releasing: '%s'\n", getMD5Text()); + debugs(20, 3, "storeRelease: Releasing: '" << getMD5Text() << "'"); /* If, for any reason we can't discard this object because of an * outstanding request, mark it for pending release */ if (locked()) { expireNow(); - debug(20, 3) ("storeRelease: Only setting RELEASE_REQUEST bit\n"); + debugs(20, 3, "storeRelease: Only setting RELEASE_REQUEST bit"); releaseRequest(); PROF_stop(storeRelease); return; @@ -1323,7 +1314,7 @@ storeLateRelease(void *unused) if (e == NULL) { /* done! */ - debug(20, 1) ("storeLateRelease: released %d objects\n", n); + debugs(20, 1, "storeLateRelease: released " << n << " objects"); return; } @@ -1364,29 +1355,24 @@ StoreEntry::validLength() const const HttpReply *reply; assert(mem_obj != NULL); reply = getReply(); - debug(20, 3) ("storeEntryValidLength: Checking '%s'\n", getMD5Text()); + debugs(20, 3, "storeEntryValidLength: Checking '" << getMD5Text() << "'"); debugs(20, 5, "storeEntryValidLength: object_len = " << objectLen()); - debug(20, 5) ("storeEntryValidLength: hdr_sz = %d\n", - reply->hdr_sz); - debug(20, 5) ("storeEntryValidLength: content_length = %d\n", - reply->content_length); + debugs(20, 5, "storeEntryValidLength: hdr_sz = " << reply->hdr_sz); + debugs(20, 5, "storeEntryValidLength: content_length = " << reply->content_length); if (reply->content_length < 0) { - debug(20, 5) ("storeEntryValidLength: Unspecified content length: %s\n", - getMD5Text()); + debugs(20, 5, "storeEntryValidLength: Unspecified content length: " << getMD5Text()); return 1; } if (reply->hdr_sz == 0) { - debug(20, 5) ("storeEntryValidLength: Zero header size: %s\n", - getMD5Text()); + debugs(20, 5, "storeEntryValidLength: Zero header size: " << getMD5Text()); return 1; } if (mem_obj->method == METHOD_HEAD) { - debug(20, 5) ("storeEntryValidLength: HEAD request: %s\n", - getMD5Text()); + debugs(20, 5, "storeEntryValidLength: HEAD request: " << getMD5Text()); return 1; } @@ -1401,10 +1387,7 @@ StoreEntry::validLength() const if (diff == 0) return 1; - debug(20, 3) ("storeEntryValidLength: %d bytes too %s; '%s'\n", - diff < 0 ? -diff : diff, - diff < 0 ? "big" : "small", - getMD5Text()); + debugs(20, 3, "storeEntryValidLength: " << (diff < 0 ? -diff : diff) << " bytes too " << (diff < 0 ? "big" : "small") <<"; '" << getMD5Text() << "'" ); return 0; } @@ -1576,23 +1559,23 @@ StoreEntry::unregisterAbort() void StoreEntry::dump(int l) const { - debug(20, l) ("StoreEntry->key: %s\n", getMD5Text()); - debug(20, l) ("StoreEntry->next: %p\n", next); - debug(20, l) ("StoreEntry->mem_obj: %p\n", mem_obj); - debug(20, l) ("StoreEntry->timestamp: %d\n", (int) timestamp); - debug(20, l) ("StoreEntry->lastref: %d\n", (int) lastref); - debug(20, l) ("StoreEntry->expires: %d\n", (int) expires); - debug(20, l) ("StoreEntry->lastmod: %d\n", (int) lastmod); - debug(20, l) ("StoreEntry->swap_file_sz: %d\n", (int) swap_file_sz); - debug(20, l) ("StoreEntry->refcount: %d\n", refcount); - debug(20, l) ("StoreEntry->flags: %s\n", storeEntryFlags(this)); - debug(20, l) ("StoreEntry->swap_dirn: %d\n", (int) swap_dirn); - debug(20, l) ("StoreEntry->swap_filen: %d\n", (int) swap_filen); - debug(20, l) ("StoreEntry->lock_count: %d\n", (int) lock_count); - debug(20, l) ("StoreEntry->mem_status: %d\n", (int) mem_status); - debug(20, l) ("StoreEntry->ping_status: %d\n", (int) ping_status); - debug(20, l) ("StoreEntry->store_status: %d\n", (int) store_status); - debug(20, l) ("StoreEntry->swap_status: %d\n", (int) swap_status); + debugs(20, l, "StoreEntry->key: " << getMD5Text()); + debugs(20, l, "StoreEntry->next: " << next); + debugs(20, l, "StoreEntry->mem_obj: " << mem_obj); + debugs(20, l, "StoreEntry->timestamp: " << (int) timestamp); + debugs(20, l, "StoreEntry->lastref: " << (int) lastref); + debugs(20, l, "StoreEntry->expires: " << (int) expires); + debugs(20, l, "StoreEntry->lastmod: " << (int) lastmod); + debugs(20, l, "StoreEntry->swap_file_sz: " << (int) swap_file_sz); + debugs(20, l, "StoreEntry->refcount: " << refcount); + debugs(20, l, "StoreEntry->flags: " << storeEntryFlags(this)); + debugs(20, l, "StoreEntry->swap_dirn: " << (int) swap_dirn); + debugs(20, l, "StoreEntry->swap_filen: " << (int) swap_filen); + debugs(20, l, "StoreEntry->lock_count: " << (int) lock_count); + debugs(20, l, "StoreEntry->mem_status: " << (int) mem_status); + debugs(20, l, "StoreEntry->ping_status: " << (int) ping_status); + debugs(20, l, "StoreEntry->store_status: " << (int) store_status); + debugs(20, l, "StoreEntry->swap_status: " << (int) swap_status); } /* @@ -1610,23 +1593,19 @@ StoreEntry::setMemStatus(mem_status_t new_status) assert(mem_obj->inmem_lo == 0); if (EBIT_TEST(flags, ENTRY_SPECIAL)) { - debug(20, 4) ("StoreEntry::setMemStatus: not inserting special %s into policy\n", - mem_obj->url); + debugs(20, 4, "StoreEntry::setMemStatus: not inserting special " << mem_obj->url << " into policy"); } else { mem_policy->Add(mem_policy, this, &mem_obj->repl); - debug(20, 4) ("StoreEntry::setMemStatus: inserted mem node %s\n", - mem_obj->url); + debugs(20, 4, "StoreEntry::setMemStatus: inserted mem node " << mem_obj->url); } hot_obj_count++; } else { if (EBIT_TEST(flags, ENTRY_SPECIAL)) { - debug(20, 4) ("StoreEntry::setMemStatus: special entry %s\n", - mem_obj->url); + debugs(20, 4, "StoreEntry::setMemStatus: special entry " << mem_obj->url); } else { mem_policy->Remove(mem_policy, this, &mem_obj->repl); - debug(20, 4) ("StoreEntry::setMemStatus: removed mem node %s\n", - mem_obj->url); + debugs(20, 4, "StoreEntry::setMemStatus: removed mem node " << mem_obj->url); } hot_obj_count--; @@ -1700,7 +1679,7 @@ void StoreEntry::reset() { assert (mem_obj); - debug(20, 3) ("StoreEntry::reset: %s\n", url()); + debugs(20, 3, "StoreEntry::reset: " << url()); mem_obj->reset(); HttpReply *rep = (HttpReply *) getReply(); // bypass const rep->reset(); @@ -1756,9 +1735,9 @@ createRemovalPolicy(RemovalPolicySettings * settings) return r->create(settings->args); } - debug(20, 1) ("ERROR: Unknown policy %s\n", settings->type); - debug(20, 1) ("ERROR: Be sure to have set cache_replacement_policy\n"); - debug(20, 1) ("ERROR: and memory_replacement_policy in squid.conf!\n"); + debugs(20, 1, "ERROR: Unknown policy " << settings->type); + debugs(20, 1, "ERROR: Be sure to have set cache_replacement_policy"); + debugs(20, 1, "ERROR: and memory_replacement_policy in squid.conf!"); fatalf("ERROR: Unknown policy %s\n", settings->type); return NULL; /* NOTREACHED */ } @@ -1792,11 +1771,11 @@ storeSwapFileNumberSet(StoreEntry * e, sfileno filn) void StoreEntry::replaceHttpReply(HttpReply *rep) { - debug(20, 3) ("StoreEntry::replaceHttpReply: %s\n", url()); + debugs(20, 3, "StoreEntry::replaceHttpReply: " << url()); Packer p; if (!mem_obj) { - debug (20,0)("Attempt to replace object with no in-memory representation\n"); + debugs(20, 0, "Attempt to replace object with no in-memory representation"); return; } @@ -1835,9 +1814,8 @@ bool StoreEntry::swapoutPossible() { /* should we swap something out to disk? */ - debug(20, 7) ("storeSwapOut: %s\n", url()); - debug(20, 7) ("storeSwapOut: store_status = %s\n", - storeStatusStr[store_status]); + debugs(20, 7, "storeSwapOut: " << url()); + debugs(20, 7, "storeSwapOut: store_status = " << storeStatusStr[store_status]); if (EBIT_TEST(flags, ENTRY_ABORTED)) { assert(EBIT_TEST(flags, RELEASE_REQUEST)); @@ -1846,7 +1824,7 @@ StoreEntry::swapoutPossible() } if (EBIT_TEST(flags, ENTRY_SPECIAL)) { - debug(20, 3) ("storeSwapOut: %s SPECIAL\n", url()); + debugs(20, 3, "storeSwapOut: " << url() << " SPECIAL"); return false; } @@ -1884,9 +1862,9 @@ StoreEntry::modifiedSince(HttpRequest * request) const if (mod_time < 0) mod_time = timestamp; - debug(88, 3) ("modifiedSince: '%s'\n", url()); + debugs(88, 3, "modifiedSince: '" << url() << "'"); - debug(88, 3) ("modifiedSince: mod_time = %ld\n", (long int) mod_time); + debugs(88, 3, "modifiedSince: mod_time = " << (long int) mod_time); if (mod_time < 0) return true; @@ -1898,19 +1876,19 @@ StoreEntry::modifiedSince(HttpRequest * request) const object_length = contentLen(); if (mod_time > request->ims) { - debug(88, 3) ("--> YES: entry newer than client\n"); + debugs(88, 3, "--> YES: entry newer than client"); return true; } else if (mod_time < request->ims) { - debug(88, 3) ("--> NO: entry older than client\n"); + debugs(88, 3, "--> NO: entry older than client"); return false; } else if (request->imslen < 0) { - debug(88, 3) ("--> NO: same LMT, no client length\n"); + debugs(88, 3, "--> NO: same LMT, no client length"); return false; } else if (request->imslen == object_length) { - debug(88, 3) ("--> NO: same LMT, same length\n"); + debugs(88, 3, "--> NO: same LMT, same length"); return false; } else { - debug(88, 3) ("--> YES: same LMT, different length\n"); + debugs(88, 3, "--> YES: same LMT, different length"); return true; } } diff --git a/src/store_client.cc b/src/store_client.cc index fe40aaab1e..234f58d2f1 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.155 2007/04/21 07:10:06 wessels Exp $ + * $Id: store_client.cc,v 1.156 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -170,7 +170,7 @@ static void storeClientCopyEvent(void *data) { store_client *sc = (store_client *)data; - debug(90, 3)("storeClientCopyEvent: Running\n"); + debugs(90, 3, "storeClientCopyEvent: Running"); assert (sc->flags.copy_event_pending); sc->flags.copy_event_pending = 0; @@ -228,12 +228,11 @@ store_client::copy(StoreEntry * anEntry, assert (callback_fn); assert (data); assert(!EBIT_TEST(entry->flags, ENTRY_ABORTED)); - debug(90, 3)("store_client::copy: %s, from %lu, for length %d, cb %p, cbdata %p\n", - entry->getMD5Text(), - (unsigned long) copyRequest.offset, - (int) copyRequest.length, - callback_fn, - data); + debugs(90, 3, "store_client::copy: " << entry->getMD5Text() << ", from " << + (unsigned long) copyRequest.offset << ", for length " << + (int) copyRequest.length << ", cb " << callback_fn << ", cbdata " << + data); + #if STORE_CLIENT_LIST_DEBUG assert(this == storeClientListSearch(entry->mem_obj, data)); @@ -303,18 +302,18 @@ storeClientCopy2(StoreEntry * e, store_client * sc) } if (EBIT_TEST(e->flags, ENTRY_FWD_HDR_WAIT)) { - debug(90, 5)("storeClientCopy2: returning because ENTRY_FWD_HDR_WAIT set\n"); + debugs(90, 5, "storeClientCopy2: returning because ENTRY_FWD_HDR_WAIT set"); return; } if (sc->flags.store_copying) { sc->flags.copy_event_pending = 1; - debug(90, 3)("storeClientCopy2: Queueing storeClientCopyEvent()\n"); + debugs(90, 3, "storeClientCopy2: Queueing storeClientCopyEvent()"); eventAdd("storeClientCopyEvent", storeClientCopyEvent, sc, 0.0, 0); return; } - debug(90, 3)("storeClientCopy2: %s\n", e->getMD5Text()); + debugs(90, 3, "storeClientCopy2: " << e->getMD5Text()); assert(sc->_callback.pending()); /* * We used to check for ENTRY_ABORTED here. But there were some @@ -341,7 +340,9 @@ store_client::doCopy(StoreEntry *anEntry) flags.store_copying = 1; MemObject *mem = entry->mem_obj; - debug(33, 5)("store_client::doCopy: co: %lu, hi: %ld\n", (unsigned long) copyInto.offset, (long int) mem->endOffset()); + debugs(33, 5, "store_client::doCopy: co: " << + (unsigned long) copyInto.offset << ", hi: " << + (long int) mem->endOffset()); if (storeClientNoMoreToSend(entry, this)) { /* There is no more to send! */ @@ -352,7 +353,7 @@ store_client::doCopy(StoreEntry *anEntry) /* Check that we actually have data */ if (anEntry->store_status == STORE_PENDING && copyInto.offset >= mem->endOffset()) { - debug(90, 3)("store_client::doCopy: Waiting for more\n"); + debugs(90, 3, "store_client::doCopy: Waiting for more"); flags.store_copying = 0; return; } @@ -378,7 +379,7 @@ store_client::doCopy(StoreEntry *anEntry) void store_client::startSwapin() { - debug(90, 3)("store_client::doCopy: Need to open swap in file\n"); + debugs(90, 3, "store_client::doCopy: Need to open swap in file"); /* gotta open the swapin file */ if (storeTooManyDiskFilesOpen()) { @@ -404,7 +405,7 @@ store_client::startSwapin() return; } else { - debug (90, 1)("WARNING: Averted multiple fd operation (1)\n"); + debugs(90, 1, "WARNING: Averted multiple fd operation (1)"); flags.store_copying = 0; return; } @@ -429,7 +430,7 @@ store_client::scheduleDiskRead() assert(!flags.disk_io_pending); - debug(90, 3)("store_client::doCopy: reading from STORE\n"); + debugs(90, 3, "store_client::doCopy: reading from STORE"); fileRead(); @@ -441,7 +442,7 @@ store_client::scheduleMemRead() { /* What the client wants is in memory */ /* Old style */ - debug(90, 3)("store_client::doCopy: Copying normal from memory\n"); + debugs(90, 3, "store_client::doCopy: Copying normal from memory"); size_t sz = entry->mem_obj->data_hdr.copy(copyInto); callback(sz); flags.store_copying = 0; @@ -476,14 +477,14 @@ storeClientReadBody(void *data, const char *buf, ssize_t len, StoreIOState::Poin assert(sc->flags.disk_io_pending); sc->flags.disk_io_pending = 0; assert(sc->_callback.pending()); - debug(90, 3)("storeClientReadBody: len %d", (int) len); + debugs(90, 3, "storeClientReadBody: len " << (int) len << ""); if (sc->copyInto.offset == 0 && len > 0 && sc->entry->getReply()->sline.status == 0) { /* Our structure ! */ HttpReply *rep = (HttpReply *) sc->entry->getReply(); // bypass const if (!rep->parseCharBuf(sc->copyInto.data, headersEnd(sc->copyInto.data, len))) { - debug (90,0)("Could not parse headers from on disk object\n"); + debugs(90, 0, "Could not parse headers from on disk object"); } } @@ -515,10 +516,10 @@ storeClientReadHeader(void *data, const char *buf, ssize_t len, StoreIOState::Po void store_client::unpackHeader(char const *buf, ssize_t len) { - debug(90, 3)("store_client::unpackHeader: len %d", (int) len); + debugs(90, 3, "store_client::unpackHeader: len " << (int) len << ""); if (len < 0) { - debug(90, 3)("store_client::unpackHeader: %s", xstrerror()); + debugs(90, 3, "store_client::unpackHeader: " << xstrerror() << ""); fail(); return; } @@ -528,7 +529,7 @@ store_client::unpackHeader(char const *buf, ssize_t len) if (!aBuilder.isBufferSane()) { /* oops, bad disk file? */ - debug(90, 1) ("WARNING: swapfile header inconsistent with available data\n"); + debugs(90, 1, "WARNING: swapfile header inconsistent with available data"); fail(); return; } @@ -536,7 +537,7 @@ store_client::unpackHeader(char const *buf, ssize_t len) tlv *tlv_list = aBuilder.createStoreMeta (); if (tlv_list == NULL) { - debug(90, 1) ("WARNING: failed to unpack meta data\n"); + debugs(90, 1, "WARNING: failed to unpack meta data"); fail(); return; } @@ -585,8 +586,7 @@ store_client::readHeader(char const *buf, ssize_t len) */ size_t copy_sz = XMIN(copyInto.length, body_sz) ; - debug(90, 3) ("storeClientReadHeader: copying %d bytes of body\n", - (int) copy_sz); + debugs(90, 3, "storeClientReadHeader: copying " << (int) copy_sz << " bytes of body"); xmemmove(copyInto.data, copyInto.data + mem->swap_hdr_sz, copy_sz); if (copyInto.offset == 0 && len > 0 && entry->getReply()->sline.status == 0) { @@ -594,7 +594,7 @@ store_client::readHeader(char const *buf, ssize_t len) HttpReply *rep = (HttpReply *) entry->getReply(); // bypass const if (!rep->parseCharBuf(copyInto.data, headersEnd(copyInto.data, copy_sz))) { - debug (90,0)("could not parse headers from on disk structure!\n"); + debugs(90, 0, "could not parse headers from on disk structure!"); } } @@ -650,15 +650,15 @@ storeUnregister(store_client * sc, StoreEntry * e, void *data) if (mem == NULL) return 0; - debug(90, 3) ("storeUnregister: called for '%s'\n", e->getMD5Text()); + debugs(90, 3, "storeUnregister: called for '" << e->getMD5Text() << "'"); if (sc == NULL) { - debug(90, 3) ("storeUnregister: No matching client for '%s'\n", e->getMD5Text()); + debugs(90, 3, "storeUnregister: No matching client for '" << e->getMD5Text() << "'"); return 0; } if (mem->clientCount() == 0) { - debug(90, 3) ("storeUnregister: Consistency failure - store client being unregistered is not in the mem object's list for '%s'\n", e->getMD5Text()); + debugs(90, 3, "storeUnregister: Consistency failure - store client being unregistered is not in the mem object's list for '" << e->getMD5Text() << "'"); return 0; } @@ -676,8 +676,7 @@ storeUnregister(store_client * sc, StoreEntry * e, void *data) if (sc->_callback.pending()) { /* callback with ssize = -1 to indicate unexpected termination */ - debug(90, 3) ("storeUnregister: store_client for %s has a callback\n", - mem->url); + debugs(90, 3, "storeUnregister: store_client for " << mem->url << " has a callback"); sc->fail(); } @@ -711,13 +710,13 @@ StoreEntry::invokeHandlers() PROF_start(InvokeHandlers); - debug(90, 3) ("StoreEntry::invokeHandlers: %s\n", getMD5Text()); + debugs(90, 3, "InvokeHandlers: " << getMD5Text() ); /* walk the entire list looking for valid callbacks */ for (node = mem_obj->clients.head; node; node = nx) { sc = (store_client *)node->data; nx = node->next; - debug(90, 3) ("StoreEntry::invokeHandlers: checking client #%d\n", i++); + debugs(90, 3, "StoreEntry::InvokeHandlers: checking client #" << i++ ); if (!sc->_callback.pending()) continue; @@ -735,7 +734,7 @@ storePendingNClients(const StoreEntry * e) { MemObject *mem = e->mem_obj; int npend = NULL == mem ? 0 : mem->nclients; - debug(90, 3) ("storePendingNClients: returning %d\n", npend); + debugs(90, 3, "storePendingNClients: returning " << npend); return npend; } @@ -745,15 +744,15 @@ CheckQuickAbort2(StoreEntry * entry) { MemObject * const mem = entry->mem_obj; assert(mem); - debug(90, 3) ("CheckQuickAbort2: entry=%p, mem=%p\n", entry, mem); + debugs(90, 3, "CheckQuickAbort2: entry=" << entry << ", mem=" << mem); if (mem->request && !mem->request->flags.cachable) { - debug(90, 3) ("CheckQuickAbort2: YES !mem->request->flags.cachable\n"); + debugs(90, 3, "CheckQuickAbort2: YES !mem->request->flags.cachable"); return 1; } if (EBIT_TEST(entry->flags, KEY_PRIVATE)) { - debug(90, 3) ("CheckQuickAbort2: YES KEY_PRIVATE\n"); + debugs(90, 3, "CheckQuickAbort2: YES KEY_PRIVATE"); return 1; } @@ -768,36 +767,36 @@ CheckQuickAbort2(StoreEntry * entry) size_t minlen = (size_t) Config.quickAbort.min << 10; if (minlen < 0) { - debug(90, 3) ("CheckQuickAbort2: NO disabled\n"); + debugs(90, 3, "CheckQuickAbort2: NO disabled"); return 0; } if (curlen > expectlen) { - debug(90, 3) ("CheckQuickAbort2: YES bad content length\n"); + debugs(90, 3, "CheckQuickAbort2: YES bad content length"); return 1; } if ((expectlen - curlen) < minlen) { - debug(90, 3) ("CheckQuickAbort2: NO only little more left\n"); + debugs(90, 3, "CheckQuickAbort2: NO only little more left"); return 0; } if ((expectlen - curlen) > (Config.quickAbort.max << 10)) { - debug(90, 3) ("CheckQuickAbort2: YES too much left to go\n"); + debugs(90, 3, "CheckQuickAbort2: YES too much left to go"); return 1; } if (expectlen < 100) { - debug(90, 3) ("CheckQuickAbort2: NO avoid FPE\n"); + debugs(90, 3, "CheckQuickAbort2: NO avoid FPE"); return 0; } if ((curlen / (expectlen / 100)) > (size_t)Config.quickAbort.pct) { - debug(90, 3) ("CheckQuickAbort2: NO past point of no return\n"); + debugs(90, 3, "CheckQuickAbort2: NO past point of no return"); return 0; } - debug(90, 3) ("CheckQuickAbort2: YES default, returning 1\n"); + debugs(90, 3, "CheckQuickAbort2: YES default, returning 1"); return 1; } diff --git a/src/store_digest.cc b/src/store_digest.cc index d20d848258..6439d149aa 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: store_digest.cc,v 1.73 2007/04/21 07:14:15 wessels Exp $ + * $Id: store_digest.cc,v 1.74 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -115,18 +115,20 @@ storeDigestInit(void) if (!Config.onoff.digest_generation) { store_digest = NULL; - debug(71, 3) ("Local cache digest generation disabled\n"); + debugs(71, 3, "Local cache digest generation disabled"); return; } store_digest = cacheDigestCreate(cap, Config.digest.bits_per_entry); - debug(71, 1) ("Local cache digest enabled; rebuild/rewrite every %d/%d sec\n", - (int) Config.digest.rebuild_period, (int) Config.digest.rewrite_period); + debugs(71, 1, "Local cache digest enabled; rebuild/rewrite every " << + (int) Config.digest.rebuild_period << "/" << + (int) Config.digest.rewrite_period << " sec"); + memset(&sd_state, 0, sizeof(sd_state)); #else store_digest = NULL; - debug(71, 3) ("Local cache digest is 'off'\n"); + debugs(71, 3, "Local cache digest is 'off'"); #endif } @@ -161,19 +163,16 @@ storeDigestDel(const StoreEntry * entry) } assert(entry && store_digest); - debug(71, 6) ("storeDigestDel: checking entry, key: %s\n", - entry->getMD5Text()); + debugs(71, 6, "storeDigestDel: checking entry, key: " << entry->getMD5Text()); if (!EBIT_TEST(entry->flags, KEY_PRIVATE)) { if (!cacheDigestTest(store_digest, (const cache_key *)entry->key)) { sd_stats.del_lost_count++; - debug(71, 6) ("storeDigestDel: lost entry, key: %s url: %s\n", - entry->getMD5Text(), entry->url()); + debugs(71, 6, "storeDigestDel: lost entry, key: " << entry->getMD5Text() << " url: " << entry->url() ); } else { sd_stats.del_count++; cacheDigestDel(store_digest, (const cache_key *)entry->key); - debug(71, 6) ("storeDigestDel: deled entry, key: %s\n", - entry->getMD5Text()); + debugs(71, 6, "storeDigestDel: deled entry, key: " << entry->getMD5Text()); } } @@ -218,47 +217,45 @@ storeDigestAddable(const StoreEntry * e) { /* add some stats! XXX */ - debug(71, 6) ("storeDigestAddable: checking entry, key: %s\n", - e->getMD5Text()); + debugs(71, 6, "storeDigestAddable: checking entry, key: " << e->getMD5Text()); /* check various entry flags (mimics StoreEntry::checkCachable XXX) */ if (!EBIT_TEST(e->flags, ENTRY_CACHABLE)) { - debug(71, 6) ("storeDigestAddable: NO: not cachable\n"); + debugs(71, 6, "storeDigestAddable: NO: not cachable"); return 0; } if (EBIT_TEST(e->flags, KEY_PRIVATE)) { - debug(71, 6) ("storeDigestAddable: NO: private key\n"); + debugs(71, 6, "storeDigestAddable: NO: private key"); return 0; } if (EBIT_TEST(e->flags, ENTRY_NEGCACHED)) { - debug(71, 6) ("storeDigestAddable: NO: negative cached\n"); + debugs(71, 6, "storeDigestAddable: NO: negative cached"); return 0; } if (EBIT_TEST(e->flags, RELEASE_REQUEST)) { - debug(71, 6) ("storeDigestAddable: NO: release requested\n"); + debugs(71, 6, "storeDigestAddable: NO: release requested"); return 0; } if (e->store_status == STORE_OK && EBIT_TEST(e->flags, ENTRY_BAD_LENGTH)) { - debug(71, 6) ("storeDigestAddable: NO: wrong content-length\n"); + debugs(71, 6, "storeDigestAddable: NO: wrong content-length"); return 0; } /* do not digest huge objects */ if (e->swap_file_sz > Config.Store.maxObjectSize) { - debug(71, 6) ("storeDigestAddable: NO: too big\n"); + debugs(71, 6, "storeDigestAddable: NO: too big"); return 0; } /* still here? check staleness */ /* Note: We should use the time of the next rebuild, not (cur_time+period) */ if (refreshCheckDigest(e, Config.digest.rebuild_period)) { - debug(71, 6) ("storeDigestAdd: entry expires within %d secs, ignoring\n", - (int) Config.digest.rebuild_period); + debugs(71, 6, "storeDigestAdd: entry expires within " << (int) Config.digest.rebuild_period << " secs, ignoring"); return 0; } @@ -287,8 +284,7 @@ storeDigestAdd(const StoreEntry * entry) cacheDigestAdd(store_digest, (const cache_key *)entry->key); - debug(71, 6) ("storeDigestAdd: added entry, key: %s\n", - entry->getMD5Text()); + debugs(71, 6, "storeDigestAdd: added entry, key: " << entry->getMD5Text()); } else { sd_stats.rej_count++; @@ -305,15 +301,15 @@ storeDigestRebuildStart(void *datanotused) /* prevent overlapping if rebuild schedule is too tight */ if (sd_state.rebuild_lock) { - debug(71, 1) ("storeDigestRebuildStart: overlap detected, consider increasing rebuild period\n"); + debugs(71, 1, "storeDigestRebuildStart: overlap detected, consider increasing rebuild period"); return; } sd_state.rebuild_lock = 1; - debug(71, 2) ("storeDigestRebuildStart: rebuild #%d\n", sd_state.rebuild_count + 1); + debugs(71, 2, "storeDigestRebuildStart: rebuild #" << sd_state.rebuild_count + 1); if (sd_state.rewrite_lock) { - debug(71, 2) ("storeDigestRebuildStart: waiting for Rewrite to finish.\n"); + debugs(71, 2, "storeDigestRebuildStart: waiting for Rewrite to finish."); return; } @@ -344,7 +340,7 @@ storeDigestRebuildFinish(void) assert(sd_state.rebuild_lock); sd_state.rebuild_lock = 0; sd_state.rebuild_count++; - debug(71, 2) ("storeDigestRebuildFinish: done.\n"); + debugs(71, 2, "storeDigestRebuildFinish: done."); eventAdd("storeDigestRebuildStart", storeDigestRebuildStart, NULL, (double) Config.digest.rebuild_period, 1); /* resume pending Rewrite if any */ @@ -362,8 +358,7 @@ storeDigestRebuildStep(void *datanotused) (double) Config.digest.rebuild_chunk_percentage / 100.0); assert(sd_state.rebuild_lock); - debug(71, 3) ("storeDigestRebuildStep: buckets: %d entries to check: %d\n", - store_hash_buckets, count); + debugs(71, 3, "storeDigestRebuildStep: buckets: " << store_hash_buckets << " entries to check: " << count); while (count-- && !sd_state.theSearch->isDone() && sd_state.theSearch->next()) storeDigestAdd(sd_state.theSearch->currentItem()); @@ -388,24 +383,24 @@ storeDigestRewriteStart(void *datanotused) /* prevent overlapping if rewrite schedule is too tight */ if (sd_state.rewrite_lock) { - debug(71, 1) ("storeDigestRewrite: overlap detected, consider increasing rewrite period\n"); + debugs(71, 1, "storeDigestRewrite: overlap detected, consider increasing rewrite period"); return; } - debug(71, 2) ("storeDigestRewrite: start rewrite #%d\n", sd_state.rewrite_count + 1); + debugs(71, 2, "storeDigestRewrite: start rewrite #" << sd_state.rewrite_count + 1); /* make new store entry */ url = internalLocalUri("/squid-internal-periodic/", StoreDigestFileName); flags.cachable = 1; e = storeCreateEntry(url, url, flags, METHOD_GET); assert(e); sd_state.rewrite_lock = e; - debug(71, 3) ("storeDigestRewrite: url: %s key: %s\n", url, e->getMD5Text()); + debugs(71, 3, "storeDigestRewrite: url: " << url << " key: " << e->getMD5Text()); HttpRequest *req = HttpRequest::CreateFromUrl(url); e->mem_obj->request = HTTPMSGLOCK(req); /* wait for rebuild (if any) to finish */ if (sd_state.rebuild_lock) { - debug(71, 2) ("storeDigestRewriteStart: waiting for rebuild to finish.\n"); + debugs(71, 2, "storeDigestRewriteStart: waiting for rebuild to finish."); return; } @@ -430,8 +425,8 @@ storeDigestRewriteResume(void) rep->setHeaders(version, HTTP_OK, "Cache Digest OK", "application/cache-digest", store_digest->mask_size + sizeof(sd_state.cblock), squid_curtime, squid_curtime + Config.digest.rewrite_period); - debug(71, 3) ("storeDigestRewrite: entry expires on %ld (%+d)\n", - (long int) rep->expires, (int) (rep->expires - squid_curtime)); + debugs(71, 3, "storeDigestRewrite: entry expires on " << (long int) rep->expires << + " (" << std::showpos << (int) (rep->expires - squid_curtime) << ")"); e->buffer(); e->replaceHttpReply(rep); storeDigestCBlockSwapOut(e); @@ -446,8 +441,8 @@ storeDigestRewriteFinish(StoreEntry * e) assert(e == sd_state.rewrite_lock); e->complete(); e->timestampsSet(); - debug(71, 2) ("storeDigestRewriteFinish: digest expires at %ld (%+d)\n", - (long int) e->expires, (int) (e->expires - squid_curtime)); + debugs(71, 2, "storeDigestRewriteFinish: digest expires at " << (long int) e->expires << + " (" << std::showpos << (int) (e->expires - squid_curtime) << ")"); /* is this the write order? @?@ */ e->mem_obj->unlinkRequest(); e->unlock(); @@ -518,8 +513,8 @@ storeDigestCalcCap(void) const int lo_cap = 1 + store_swap_size / Config.Store.avgObjectSize; const int e_count = StoreEntry::inUseCount(); int cap = e_count ? e_count : hi_cap; - debug(71, 2) ("storeDigestCalcCap: have: %d, want %d entries; limits: [%d, %d]\n", - e_count, cap, lo_cap, hi_cap); + debugs(71, 2, "storeDigestCalcCap: have: " << e_count << ", want " << cap << + " entries; limits: [" << lo_cap << ", " << hi_cap << "]"); if (cap < lo_cap) cap = lo_cap; @@ -539,16 +534,16 @@ storeDigestResize(void) int diff; assert(store_digest); diff = abs(cap - store_digest->capacity); - debug(71, 2) ("storeDigestResize: %d -> %d; change: %d (%d%%)\n", - store_digest->capacity, cap, diff, - xpercentInt(diff, store_digest->capacity)); + debugs(71, 2, "storeDigestResize: " << + store_digest->capacity << " -> " << cap << "; change: " << + diff << " (" << xpercentInt(diff, store_digest->capacity) << "%)" ); /* avoid minor adjustments */ if (diff <= store_digest->capacity / 10) { - debug(71, 2) ("storeDigestResize: small change, will not resize.\n"); + debugs(71, 2, "storeDigestResize: small change, will not resize."); return 0; } else { - debug(71, 2) ("storeDigestResize: big change, resizing.\n"); + debugs(71, 2, "storeDigestResize: big change, resizing."); cacheDigestChangeCap(store_digest, cap); return 1; } diff --git a/src/store_dir.cc b/src/store_dir.cc index dee2601558..83359b3680 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir.cc,v 1.158 2007/04/17 05:40:18 wessels Exp $ + * $Id: store_dir.cc,v 1.159 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -89,10 +89,10 @@ StoreController::init() if (0 == strcasecmp(Config.store_dir_select_algorithm, "round-robin")) { storeDirSelectSwapDir = storeDirSelectSwapDirRoundRobin; - debug(47, 1) ("Using Round Robin store dir selection\n"); + debugs(47, 1, "Using Round Robin store dir selection"); } else { storeDirSelectSwapDir = storeDirSelectSwapDirLeastLoad; - debug(47, 1) ("Using Least Load store dir selection\n"); + debugs(47, 1, "Using Least Load store dir selection"); } } @@ -320,11 +320,11 @@ storeDirSwapLog(const StoreEntry * e, int op) assert(op > SWAP_LOG_NOP && op < SWAP_LOG_MAX); - debug(20, 3) ("storeDirSwapLog: %s %s %d %08X\n", - swap_log_op_str[op], - e->getMD5Text(), - e->swap_dirn, - e->swap_filen); + debugs(20, 3, "storeDirSwapLog: " << + swap_log_op_str[op] << " " << + e->getMD5Text() << " " << + e->swap_dirn << " " << + std::hex << std::uppercase << std::setfill('0') << std::setw(8) << e->swap_filen); dynamic_cast(INDEXSD(e->swap_dirn))->logEntry(*e, op); } @@ -430,12 +430,12 @@ storeDirWriteCleanLogs(int reopen) int notdone = 1; if (StoreController::store_dirs_rebuilding) { - debug(20, 1) ("Not currently OK to rewrite swap log.\n"); - debug(20, 1) ("storeDirWriteCleanLogs: Operation aborted.\n"); + debugs(20, 1, "Not currently OK to rewrite swap log."); + debugs(20, 1, "storeDirWriteCleanLogs: Operation aborted."); return 0; } - debug(20, 1) ("storeDirWriteCleanLogs: Starting...\n"); + debugs(20, 1, "storeDirWriteCleanLogs: Starting..."); getCurrentTime(); start = current_time; @@ -443,7 +443,7 @@ storeDirWriteCleanLogs(int reopen) sd = dynamic_cast(INDEXSD(dirn)); if (sd->writeCleanStart() < 0) { - debug(20, 1) ("log.clean.start() failed for dir #%d\n", sd->index); + debugs(20, 1, "log.clean.start() failed for dir #" << sd->index); continue; } } @@ -476,7 +476,8 @@ storeDirWriteCleanLogs(int reopen) if ((++n & 0xFFFF) == 0) { getCurrentTime(); - debug(20, 1) (" %7d entries written so far.\n", n); + debugs(20, 1, " " << std::setw(7) << n << + " entries written so far."); } } } @@ -492,10 +493,10 @@ storeDirWriteCleanLogs(int reopen) dt = tvSubDsec(start, current_time); - debug(20, 1) (" Finished. Wrote %d entries.\n", n); + debugs(20, 1, " Finished. Wrote " << n << " entries."); + debugs(20, 1, " Took "<< std::setw(3)<< std::setprecision(2) << dt << + " seconds ("<< std::setw(6) << ((double) n / (dt > 0.0 ? dt : 1.0)) << " entries/sec)."); - debug(20, 1) (" Took %3.1f seconds (%6.1f entries/sec).\n", - dt, (double) n / (dt > 0.0 ? dt : 1.0)); return n; } @@ -545,7 +546,7 @@ storeDirGetBlkSize(const char *path, int *blksize) struct statvfs sfs; if (statvfs(path, &sfs)) { - debug(50, 1) ("%s: %s\n", path, xstrerror()); + debugs(50, 1, "" << path << ": " << xstrerror()); *blksize = 2048; return 1; } @@ -556,7 +557,7 @@ storeDirGetBlkSize(const char *path, int *blksize) struct statfs sfs; if (statfs(path, &sfs)) { - debug(50, 1) ("%s: %s\n", path, xstrerror()); + debugs(50, 1, "" << path << ": " << xstrerror()); *blksize = 2048; return 1; } @@ -584,7 +585,7 @@ storeDirGetUFSStats(const char *path, int *totl_kb, int *free_kb, int *totl_in, struct statvfs sfs; if (statvfs(path, &sfs)) { - debug(50, 1) ("%s: %s\n", path, xstrerror()); + debugs(50, 1, "" << path << ": " << xstrerror()); return 1; } @@ -597,7 +598,7 @@ storeDirGetUFSStats(const char *path, int *totl_kb, int *free_kb, int *totl_in, struct statfs sfs; if (statfs(path, &sfs)) { - debug(50, 1) ("%s: %s\n", path, xstrerror()); + debugs(50, 1, "" << path << ": " << xstrerror()); return 1; } @@ -765,7 +766,7 @@ StoreHashIndex::get (const cache_key *key) { PROF_start(storeGet); - debug(20, 3) ("storeGet: looking up %s\n", storeKeyText(key)); + debugs(20, 3, "storeGet: looking up " << storeKeyText(key)); StoreEntry *p = static_cast(hash_lookup(store_table, key)); PROF_stop(storeGet); return p; diff --git a/src/store_io.cc b/src/store_io.cc index f7decc0b3d..21bbf8ff5e 100644 --- a/src/store_io.cc +++ b/src/store_io.cc @@ -49,12 +49,12 @@ storeCreate(StoreEntry * e, StoreIOState::STFNCB * file_callback, StoreIOState:: dirn = storeDirSelectSwapDir(e); if (dirn == -1) { - debug(20, 2) ("storeCreate: no valid swapdirs for this object\n"); + debugs(20, 2, "storeCreate: no valid swapdirs for this object"); store_io_stats.create.select_fail++; return NULL; } - debug(20, 2) ("storeCreate: Selected dir '%d' for obj size '%ld'\n", dirn, (long int) objsize); + debugs(20, 2, "storeCreate: Selected dir '" << dirn << "' for obj size '" << (long int) objsize << "'"); SD = dynamic_cast(INDEXSD(dirn)); /* Now that we have a fs to use, call its storeCreate function */ diff --git a/src/store_log.cc b/src/store_log.cc index d6f76b8ec7..6e57e95e9f 100644 --- a/src/store_log.cc +++ b/src/store_log.cc @@ -1,6 +1,6 @@ /* - * $Id: store_log.cc,v 1.31 2007/04/20 07:29:47 wessels Exp $ + * $Id: store_log.cc,v 1.32 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 20 Storage Manager Logging Functions * AUTHOR: Duane Wessels @@ -65,7 +65,7 @@ storeLog(int tag, const StoreEntry * e) storeLogTagsCounts[tag]++; if (mem != NULL) { if (mem->log_url == NULL) { - debug(20, 1) ("storeLog: NULL log_url for %s\n", mem->url); + debugs(20, 1, "storeLog: NULL log_url for " << mem->url); mem->dump(); mem->log_url = xstrdup(mem->url); } @@ -128,7 +128,7 @@ void storeLogOpen(void) { if (strcmp(Config.Log.store, "none") == 0) { - debug(20, 1) ("Store logging disabled\n"); + debugs(20, 1, "Store logging disabled"); return; } diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 85df970935..dd8f6df30c 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -1,6 +1,6 @@ /* - * $Id: store_rebuild.cc,v 1.88 2007/04/10 19:24:38 wessels Exp $ + * $Id: store_rebuild.cc,v 1.89 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 20 Store Rebuild Routines * AUTHOR: Duane Wessels @@ -154,28 +154,18 @@ storeRebuildComplete(struct _store_rebuild_data *dc) dt = tvSubDsec(rebuild_start, current_time); - debug(20, 1) ("Finished rebuilding storage from disk.\n"); - - debug(20, 1) (" %7d Entries scanned\n", counts.scancount); - - debug(20, 1) (" %7d Invalid entries.\n", counts.invalid); - - debug(20, 1) (" %7d With invalid flags.\n", counts.badflags); - - debug(20, 1) (" %7d Objects loaded.\n", counts.objcount); - - debug(20, 1) (" %7d Objects expired.\n", counts.expcount); - - debug(20, 1) (" %7d Objects cancelled.\n", counts.cancelcount); - - debug(20, 1) (" %7d Duplicate URLs purged.\n", counts.dupcount); - - debug(20, 1) (" %7d Swapfile clashes avoided.\n", counts.clashcount); - - debug(20, 1) (" Took %3.1f seconds (%6.1f objects/sec).\n", dt, - (double) counts.objcount / (dt > 0.0 ? dt : 1.0)); - - debug(20, 1) ("Beginning Validation Procedure\n"); + debugs(20, 1, "Finished rebuilding storage from disk."); + debugs(20, 1, " " << std::setw(7) << counts.scancount << " Entries scanned"); + debugs(20, 1, " " << std::setw(7) << counts.invalid << " Invalid entries."); + debugs(20, 1, " " << std::setw(7) << counts.badflags << " With invalid flags."); + debugs(20, 1, " " << std::setw(7) << counts.objcount << " Objects loaded."); + debugs(20, 1, " " << std::setw(7) << counts.expcount << " Objects expired."); + debugs(20, 1, " " << std::setw(7) << counts.cancelcount << " Objects cancelled."); + debugs(20, 1, " " << std::setw(7) << counts.dupcount << " Duplicate URLs purged."); + debugs(20, 1, " " << std::setw(7) << counts.clashcount << " Swapfile clashes avoided."); + debugs(20, 1, " Took "<< std::setw(3)<< std::setprecision(2) << dt << " seconds ("<< std::setw(6) << + ((double) counts.objcount / (dt > 0.0 ? dt : 1.0)) << " objects/sec)."); + debugs(20, 1, "Beginning Validation Procedure"); eventAdd("storeCleanup", storeCleanup, NULL, 0.0, 1); @@ -241,6 +231,6 @@ storeRebuildProgress(int sd_index, int total, int sofar) d += (double) RebuildProgress[sd_index].total; } - debug(20, 1) ("Store rebuilding is %4.1f%% complete\n", 100.0 * n / d); + debugs(20, 1, "Store rebuilding is "<< std::setw(4)<< std::setprecision(2) << 100.0 * n / d << "% complete"); last_report = squid_curtime; } diff --git a/src/store_swapin.cc b/src/store_swapin.cc index 870e31317f..ccd47a9cf4 100644 --- a/src/store_swapin.cc +++ b/src/store_swapin.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapin.cc,v 1.39 2006/05/23 00:30:21 wessels Exp $ + * $Id: store_swapin.cc,v 1.40 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 20 Storage Manager Swapin Functions * AUTHOR: Duane Wessels @@ -51,23 +51,22 @@ storeSwapInStart(store_client * sc) return; } - debug(20, 3) ("storeSwapInStart: called for %d %08X %s \n", - e->swap_dirn, e->swap_filen, e->getMD5Text()); + debugs(20, 3, "storeSwapInStart: called for : " << e->swap_dirn << " " << + std::hex << std::setw(8) << std::setfill('0') << std::uppercase << + e->swap_filen << " " << e->getMD5Text()); if (e->swap_status != SWAPOUT_WRITING && e->swap_status != SWAPOUT_DONE) { - debug(20, 1) ("storeSwapInStart: bad swap_status (%s)\n", - swapStatusStr[e->swap_status]); + debugs(20, 1, "storeSwapInStart: bad swap_status (" << swapStatusStr[e->swap_status] << ")"); return; } if (e->swap_filen < 0) { - debug(20, 1) ("storeSwapInStart: swap_filen < 0\n"); + debugs(20, 1, "storeSwapInStart: swap_filen < 0"); return; } assert(e->mem_obj != NULL); - debug(20, 3) ("storeSwapInStart: Opening fileno %08X\n", - e->swap_filen); + debugs(20, 3, "storeSwapInStart: Opening fileno " << std::hex << std::setw(8) << std::setfill('0') << std::uppercase << e->swap_filen); sc->swapin_sio = storeOpen(e, storeSwapInFileNotify, storeSwapInFileClosed, sc); } @@ -75,8 +74,7 @@ static void storeSwapInFileClosed(void *data, int errflag, StoreIOState::Pointer self) { store_client *sc = (store_client *)data; - debug(20, 3) ("storeSwapInFileClosed: sio=%p, errflag=%d\n", - sc->swapin_sio.getRaw(), errflag); + debugs(20, 3, "storeSwapInFileClosed: sio=" << sc->swapin_sio.getRaw() << ", errflag=" << errflag); sc->swapin_sio = NULL; if (sc->_callback.pending()) { @@ -93,7 +91,9 @@ storeSwapInFileNotify(void *data, int errflag, StoreIOState::Pointer self) store_client *sc = (store_client *)data; StoreEntry *e = sc->entry; - debug(1, 3) ("storeSwapInFileNotify: changing %d/%d to %d/%d\n", e->swap_filen, e->swap_dirn, sc->swapin_sio->swap_filen, sc->swapin_sio->swap_dirn); + debugs(1, 3, "storeSwapInFileNotify: changing " << e->swap_filen << "/" << + e->swap_dirn << " to " << sc->swapin_sio->swap_filen << "/" << + sc->swapin_sio->swap_dirn); e->swap_filen = sc->swapin_sio->swap_filen; e->swap_dirn = sc->swapin_sio->swap_dirn; diff --git a/src/store_swapmeta.cc b/src/store_swapmeta.cc index 05dd515a78..2b3472a8e5 100644 --- a/src/store_swapmeta.cc +++ b/src/store_swapmeta.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapmeta.cc,v 1.24 2007/04/21 07:14:15 wessels Exp $ + * $Id: store_swapmeta.cc,v 1.25 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -64,7 +64,7 @@ storeSwapMetaBuild(StoreEntry * e) assert(e->mem_obj != NULL); assert(e->swap_status == SWAPOUT_WRITING); url = e->url(); - debug(20, 3) ("storeSwapMetaBuild: %s\n", url); + debugs(20, 3, "storeSwapMetaBuild: " << url ); tlv *t = StoreMeta::Factory (STORE_META_KEY,MD5_DIGEST_CHARS, e->key); if (!t) { diff --git a/src/store_swapout.cc b/src/store_swapout.cc index 42aa6da155..508b9e79a6 100644 --- a/src/store_swapout.cc +++ b/src/store_swapout.cc @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.cc,v 1.115 2007/04/21 07:14:15 wessels Exp $ + * $Id: store_swapout.cc,v 1.116 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -56,8 +56,9 @@ storeSwapOutStart(StoreEntry * e) /* Build the swap metadata, so the filesystem will know how much * metadata there is to store */ - debug(20, 5) ("storeSwapOutStart: Begin SwapOut '%s' to dirno %d, fileno %08X\n", - e->url(), e->swap_dirn, e->swap_filen); + debugs(20, 5, "storeSwapOutStart: Begin SwapOut '" << e->url() << "' to dirno " << + e->swap_dirn << ", fileno " << std::hex << std::setw(8) << std::setfill('0') << + std::uppercase << e->swap_filen); e->swap_status = SWAPOUT_WRITING; /* If we start swapping out objects with OutOfBand Metadata, * then this code needs changing @@ -146,12 +147,11 @@ doPages(StoreEntry *anEntry) */ ssize_t swap_buf_len = mem->swapout.memnode->nodeBuffer.length; - debug(20, 3) ("storeSwapOut: swap_buf_len = %d\n", (int) swap_buf_len); + debugs(20, 3, "storeSwapOut: swap_buf_len = " << (int) swap_buf_len); assert(swap_buf_len > 0); - debug(20, 3) ("storeSwapOut: swapping out %ld bytes from %ld\n", - (long int) swap_buf_len, (long int) mem->swapout.queue_offset); + debugs(20, 3, "storeSwapOut: swapping out " << (long int) swap_buf_len << " bytes from " << (long int) mem->swapout.queue_offset); mem->swapout.queue_offset += swap_buf_len; @@ -189,18 +189,12 @@ StoreEntry::swapOut() if (!swapoutPossible()) return; - debug(20, 7) ("storeSwapOut: mem_obj->inmem_lo = %d\n", - (int) mem_obj->inmem_lo); - - debug(20, 7) ("storeSwapOut: mem_obj->endOffset() = %d\n", - (int) mem_obj->endOffset()); - - debug(20, 7) ("storeSwapOut: swapout.queue_offset = %d\n", - (int) mem_obj->swapout.queue_offset); + debugs(20, 7, "storeSwapOut: mem_obj->inmem_lo = " << (int) mem_obj->inmem_lo); + debugs(20, 7, "storeSwapOut: mem_obj->endOffset() = " << (int) mem_obj->endOffset()); + debugs(20, 7, "storeSwapOut: swapout.queue_offset = " << (int) mem_obj->swapout.queue_offset); if (mem_obj->swapout.sio != NULL) - debug(20, 7) ("storeSwapOut: storeOffset() = %d\n", - (int) mem_obj->swapout.sio->offset()); + debugs(20, 7, "storeSwapOut: storeOffset() = " << (int) mem_obj->swapout.sio->offset() ); ssize_t swapout_maxsize = (ssize_t) (mem_obj->endOffset() - mem_obj->swapout.queue_offset); @@ -208,8 +202,7 @@ StoreEntry::swapOut() off_t const lowest_offset = mem_obj->lowestMemReaderOffset(); - debug(20, 7) ("storeSwapOut: lowest_offset = %d\n", - (int) lowest_offset); + debugs(20, 7, "storeSwapOut: lowest_offset = " << (int) lowest_offset); /* * Grab the swapout_size and check to see whether we're going to defer @@ -226,7 +219,7 @@ StoreEntry::swapOut() * content-length, rather than wait to accumulate huge * amounts of object data in memory. */ - debug(20, 5) ("storeSwapOut: Deferring starting swapping out\n"); + debugs(20, 5, "storeSwapOut: Deferring starting swapping out"); return; } @@ -234,7 +227,7 @@ StoreEntry::swapOut() #if SIZEOF_OFF_T == 4 if (mem_obj->endOffset() > 0x7FFF0000) { - debug(20, 0) ("WARNING: preventing off_t overflow for %s\n", url()); + debugs(20, 0, "WARNING: preventing off_t overflow for " << url() ); abort(); return; } @@ -246,8 +239,7 @@ StoreEntry::swapOut() if (!swapOutAble()) return; - debug(20, 7) ("storeSwapOut: swapout_size = %d\n", - (int) swapout_maxsize); + debugs(20, 7, "storeSwapOut: swapout_size = " << (int) swapout_maxsize); if (swapout_maxsize == 0) { if (store_status == STORE_OK) @@ -307,8 +299,8 @@ void StoreEntry::swapOutFileClose() { assert(mem_obj != NULL); - debug(20, 3) ("storeSwapOutFileClose: %s\n", getMD5Text()); - debug(20, 3) ("storeSwapOutFileClose: sio = %p\n", mem_obj->swapout.sio.getRaw()); + debugs(20, 3, "storeSwapOutFileClose: " << getMD5Text()); + debugs(20, 3, "storeSwapOutFileClose: sio = " << mem_obj->swapout.sio.getRaw()); if (mem_obj->swapout.sio == NULL) return; @@ -327,8 +319,10 @@ storeSwapOutFileClosed(void *data, int errflag, StoreIOState::Pointer self) cbdataFree(c); if (errflag) { - debug(20, 1) ("storeSwapOutFileClosed: dirno %d, swapfile %08X, errflag=%d\n\t%s\n", - e->swap_dirn, e->swap_filen, errflag, xstrerror()); + debugs(20, 1, "storeSwapOutFileClosed: dirno " << e->swap_dirn << ", swapfile " << + std::hex << std::setw(8) << std::setfill('0') << std::uppercase << + e->swap_filen << ", errflag=" << errflag); + debugs(20, 1, "\t" << xstrerror()); if (errflag == DISK_NO_SPACE_LEFT) { /* FIXME: this should be handle by the link from store IO to @@ -350,8 +344,9 @@ storeSwapOutFileClosed(void *data, int errflag, StoreIOState::Pointer self) e->releaseRequest(); } else { /* swapping complete */ - debug(20, 3) ("storeSwapOutFileClosed: SwapOut complete: '%s' to %d, %08X\n", - e->url(), e->swap_dirn, e->swap_filen); + debugs(20, 3, "storeSwapOutFileClosed: SwapOut complete: '" << e->url() << "' to " << + e->swap_dirn << ", " << std::hex << std::setw(8) << std::setfill('0') << + std::uppercase << e->swap_filen); e->swap_file_sz = e->objectLen() + mem->swap_hdr_sz; e->swap_status = SWAPOUT_DONE; e->store()->updateSize(e->swap_file_sz, 1); @@ -364,7 +359,7 @@ storeSwapOutFileClosed(void *data, int errflag, StoreIOState::Pointer self) statCounter.swap.outs++; } - debug(20, 3) ("storeSwapOutFileClosed: %s:%d\n", __FILE__, __LINE__); + debugs(20, 3, "storeSwapOutFileClosed: " << __FILE__ << ":" << __LINE__); mem->swapout.sio = NULL; e->unlock(); } diff --git a/src/tests/stub_MemObject.cc b/src/tests/stub_MemObject.cc index c65fd183a2..6a7cd54781 100644 --- a/src/tests/stub_MemObject.cc +++ b/src/tests/stub_MemObject.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_MemObject.cc,v 1.5 2006/08/21 00:50:47 robertc Exp $ + * $Id: stub_MemObject.cc,v 1.6 2007/04/28 22:26:52 hno Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Robert Collins @@ -133,7 +133,7 @@ void MemObject::write(StoreIOBuffer writeBuffer, STMCB *callback, void *callbackData) { PROF_start(MemObject_write); - debug(19, 6) ("memWrite: offset %lu len %ld\n", (unsigned long)writeBuffer.offset, (long)writeBuffer.length); + debugs(19, 6, "memWrite: offset " << (unsigned long)writeBuffer.offset << " len " << (long)writeBuffer.length); /* the offset is into the content, not the headers */ writeBuffer.offset += (_reply ? _reply->hdr_sz : 0); diff --git a/src/tools.cc b/src/tools.cc index f6326de50d..be0b445a74 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.273 2007/04/15 14:46:17 serassio Exp $ + * $Id: tools.cc,v 1.274 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -425,7 +425,8 @@ sigusr2_handle(int sig) #if !HAVE_SIGACTION if (signal(sig, sigusr2_handle) == SIG_ERR) /* reinstall */ - debug(50, 0) ("signal: sig=%d func=%p: %s\n", sig, sigusr2_handle, xstrerror()); + debugs(50, 0, "signal: sig=" << sig << " func=" << sigusr2_handle << + ": " << xstrerror()); #endif } @@ -609,9 +610,8 @@ getMyHostname(void) /* DNS lookup successful */ /* use the official name from DNS lookup */ xstrncpy(host, h->h_name, SQUIDHOSTNAMELEN); - debug(50, 4) ("getMyHostname: resolved %s to '%s'\n", - inet_ntoa(sa), - host); + debugs(50, 4, "getMyHostname: resolved " << inet_ntoa(sa) << " to '" << host << "'"); + present = 1; if (strchr(host, '.')) @@ -619,20 +619,18 @@ getMyHostname(void) } - debug(50, 1) ("WARNING: failed to resolve %s to a fully qualified hostname\n", - inet_ntoa(sa)); + debugs(50, 1, "WARNING: failed to resolve " << inet_ntoa(sa) << " to a fully qualified hostname"); } /* * Get the host name and store it in host to return */ if (gethostname(host, SQUIDHOSTNAMELEN) < 0) { - debug(50, 1) ("WARNING: gethostname failed: %s\n", xstrerror()); + debugs(50, 1, "WARNING: gethostname failed: " << xstrerror()); } else if ((h = gethostbyname(host)) == NULL) { - debug(50, 1) ("WARNING: gethostbyname failed for %s\n", host); + debugs(50, 1, "WARNING: gethostbyname failed for " << host); } else { - debug(50, 6) ("getMyHostname: '%s' resolved into '%s'\n", - host, h->h_name); + debugs(50, 6, "getMyHostname: '" << host << "' resolved into '" << h->h_name << "'"); /* DNS lookup successful */ /* use the official name from DNS lookup */ xstrncpy(host, h->h_name, SQUIDHOSTNAMELEN); @@ -675,7 +673,7 @@ leave_suid(void) #endif if (setgid(Config2.effectiveGroupID) < 0) - debug(50, 0) ("ALERT: setgid: %s\n", xstrerror()); + debugs(50, 0, "ALERT: setgid: " << xstrerror()); } @@ -691,29 +689,29 @@ leave_suid(void) if (!Config.effectiveGroup) { if (setgid(Config2.effectiveGroupID) < 0) - debug(50, 0) ("ALERT: setgid: %s\n", xstrerror()); + debugs(50, 0, "ALERT: setgid: " << xstrerror()); if (initgroups(Config.effectiveUser, Config2.effectiveGroupID) < 0) { - debug(50, 0) ("ALERT: initgroups: unable to set groups for User %s " - "and Group %u", Config.effectiveUser, - (unsigned) Config2.effectiveGroupID); + debugs(50, 0, "ALERT: initgroups: unable to set groups for User " << + Config.effectiveUser << " and Group " << + (unsigned) Config2.effectiveGroupID << ""); } } #if HAVE_SETRESUID if (setresuid(Config2.effectiveUserID, Config2.effectiveUserID, 0) < 0) - debug(50, 0) ("ALERT: setresuid: %s\n", xstrerror()); + debugs(50, 0, "ALERT: setresuid: " << xstrerror()); #elif HAVE_SETEUID if (seteuid(Config2.effectiveUserID) < 0) - debug(50, 0) ("ALERT: seteuid: %s\n", xstrerror()); + debugs(50, 0, "ALERT: seteuid: " << xstrerror()); #else if (setuid(Config2.effectiveUserID) < 0) - debug(50, 0) ("ALERT: setuid: %s\n", xstrerror()); + debugs(50, 0, "ALERT: setuid: " << xstrerror()); #endif #if LINUX_TPROXY @@ -740,7 +738,7 @@ leave_suid(void) #if HAVE_PRCTL && defined(PR_SET_DUMPABLE) /* Set Linux DUMPABLE flag */ if (Config.coredump_dir && prctl(PR_SET_DUMPABLE, 1) != 0) - debug(50, 2) ("ALERT: prctl: %s\n", xstrerror()); + debugs(50, 2, "ALERT: prctl: " << xstrerror()); #endif } @@ -761,7 +759,7 @@ enter_suid(void) /* Set Linux DUMPABLE flag */ if (Config.coredump_dir && prctl(PR_SET_DUMPABLE, 1) != 0) - debug(50, 2) ("ALERT: prctl: %s\n", xstrerror()); + debugs(50, 2, "ALERT: prctl: " << xstrerror()); #endif } @@ -779,20 +777,20 @@ no_suid(void) #if HAVE_SETRESUID if (setresuid(uid, uid, uid) < 0) - debug(50, 1) ("no_suid: setresuid: %s\n", xstrerror()); + debugs(50, 1, "no_suid: setresuid: " << xstrerror()); #else setuid(0); if (setuid(uid) < 0) - debug(50, 1) ("no_suid: setuid: %s\n", xstrerror()); + debugs(50, 1, "no_suid: setuid: " << xstrerror()); #endif #if HAVE_PRCTL && defined(PR_SET_DUMPABLE) /* Set Linux DUMPABLE flag */ if (Config.coredump_dir && prctl(PR_SET_DUMPABLE, 1) != 0) - debug(50, 2) ("ALERT: prctl: %s\n", xstrerror()); + debugs(50, 2, "ALERT: prctl: " << xstrerror()); #endif } @@ -822,7 +820,7 @@ writePidFile(void) leave_suid(); if (fd < 0) { - debug(50, 0) ("%s: %s\n", f, xstrerror()); + debugs(50, 0, "" << f << ": " << xstrerror()); debug_trap("Could not write pid file"); return; } @@ -887,7 +885,7 @@ setMaxFD(void) #if defined(RLIMIT_NOFILE) if (getrlimit(RLIMIT_NOFILE, &rl) < 0) { - debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror()); + debugs(50, 0, "setrlimit: RLIMIT_NOFILE: " << xstrerror()); } else { rl.rlim_cur = Squid_MaxFD; @@ -903,7 +901,7 @@ setMaxFD(void) #elif defined(RLIMIT_OFILE) if (getrlimit(RLIMIT_OFILE, &rl) < 0) { - debug(50, 0) ("setrlimit: RLIMIT_NOFILE: %s\n", xstrerror()); + debugs(50, 0, "setrlimit: RLIMIT_NOFILE: " << xstrerror()); } else { rl.rlim_cur = Squid_MaxFD; @@ -919,14 +917,14 @@ setMaxFD(void) #endif #else /* HAVE_SETRLIMIT */ - debug(21, 1) ("setMaxFD: Cannot increase: setrlimit() not supported on this system\n"); + debugs(21, 1, "setMaxFD: Cannot increase: setrlimit() not supported on this system"); #endif /* HAVE_SETRLIMIT */ #if HAVE_SETRLIMIT && defined(RLIMIT_DATA) if (getrlimit(RLIMIT_DATA, &rl) < 0) { - debug(50, 0) ("getrlimit: RLIMIT_DATA: %s\n", xstrerror()); + debugs(50, 0, "getrlimit: RLIMIT_DATA: " << xstrerror()); } else if (rl.rlim_max > rl.rlim_cur) { rl.rlim_cur = rl.rlim_max; /* set it to the max */ @@ -940,7 +938,7 @@ setMaxFD(void) #endif /* RLIMIT_DATA */ #if HAVE_SETRLIMIT && defined(RLIMIT_VMEM) if (getrlimit(RLIMIT_VMEM, &rl) < 0) { - debug(50, 0) ("getrlimit: RLIMIT_VMEM: %s\n", xstrerror()); + debugs(50, 0, "getrlimit: RLIMIT_VMEM: " << xstrerror()); } else if (rl.rlim_max > rl.rlim_cur) { rl.rlim_cur = rl.rlim_max; /* set it to the max */ @@ -977,7 +975,7 @@ squid_signal(int sig, SIGHDLR * func, int flags) sigemptyset(&sa.sa_mask); if (sigaction(sig, &sa, NULL) < 0) - debug(50, 0) ("sigaction: sig=%d func=%p: %s\n", sig, func, xstrerror()); + debugs(50, 0, "sigaction: sig=" << sig << " func=" << func << ": " << xstrerror()); #else #ifdef _SQUID_MSWIN_ @@ -1162,7 +1160,7 @@ debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm) mb.init(); packerToMemInit(&p, &mb); (*pm) (obj, &p); - debug(section, level) ("%s%s", label, mb.buf); + debugs(section, level, "" << label << "" << mb.buf << ""); packerClean(&p); mb.clean(); } @@ -1185,8 +1183,7 @@ parseEtcHosts(void) fp = fopen(Config.etcHostsPath, "r"); if (fp == NULL) { - debug(1, 1) ("parseEtcHosts: %s: %s\n", - Config.etcHostsPath, xstrerror()); + debugs(1, 1, "parseEtcHosts: " << Config.etcHostsPath << ": " << xstrerror()); return; } @@ -1208,7 +1205,7 @@ parseEtcHosts(void) addr = buf; - debug(1, 5) ("etc_hosts: line is '%s'\n", buf); + debugs(1, 5, "etc_hosts: line is '" << buf << "'"); nt = strpbrk(lt, w_space); @@ -1217,7 +1214,7 @@ parseEtcHosts(void) *nt = '\0'; /* null-terminate the address */ - debug(1, 5) ("etc_hosts: address is '%s'\n", addr); + debugs(1, 5, "etc_hosts: address is '" << addr << "'"); lt = nt + 1; @@ -1225,13 +1222,13 @@ parseEtcHosts(void) char *host = NULL; if (nt == lt) { /* multiple spaces */ - debug(1, 5) ("etc_hosts: multiple spaces, skipping\n"); + debugs(1, 5, "etc_hosts: multiple spaces, skipping"); lt = nt + 1; continue; } *nt = '\0'; - debug(1, 5) ("etc_hosts: got hostname '%s'\n", lt); + debugs(1, 5, "etc_hosts: got hostname '" << lt << "'"); if (Config.appendDomain && !strchr(lt, '.')) { /* I know it's ugly, but it's only at reconfig */ @@ -1330,7 +1327,7 @@ keepCapabilities(void) if (need_linux_tproxy) { if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) { - debug(1, 1) ("Error - tproxy support requires capability setting which has failed. Continuing without tproxy support\n"); + debugs(1, 1, "Error - tproxy support requires capability setting which has failed. Continuing without tproxy support"); } } diff --git a/src/tunnel.cc b/src/tunnel.cc index 5974ffdffe..95663f55fb 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.166 2007/04/12 14:21:50 rousskov Exp $ + * $Id: tunnel.cc,v 1.167 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -130,7 +130,7 @@ static void sslServerClosed(int fd, void *data) { SslStateData *sslState = (SslStateData *)data; - debug(26, 3) ("sslServerClosed: FD %d\n", fd); + debugs(26, 3, "sslServerClosed: FD " << fd); assert(fd == sslState->server.fd()); sslState->server.fd(-1); @@ -142,7 +142,7 @@ static void sslClientClosed(int fd, void *data) { SslStateData *sslState = (SslStateData *)data; - debug(26, 3) ("sslClientClosed: FD %d\n", fd); + debugs(26, 3, "sslClientClosed: FD " << fd); assert(fd == sslState->client.fd()); sslState->client.fd(-1); @@ -153,7 +153,7 @@ sslClientClosed(int fd, void *data) static void sslStateFree(SslStateData * sslState) { - debug(26, 3) ("sslStateFree: sslState=%p\n", sslState); + debugs(26, 3, "sslStateFree: sslState=" << sslState); assert(sslState != NULL); assert(sslState->noConnections()); safe_free(sslState->url); @@ -227,7 +227,7 @@ SslStateData::readServer(char *buf, size_t len, comm_err_t errcode, int xerrno) if (errcode == COMM_ERR_CLOSING) return; - debug(26, 3) ("sslReadServer: FD %d, read %d bytes\n", server.fd(), (int)len); + debugs(26, 3, "sslReadServer: FD " << server.fd() << ", read " << (int)len << " bytes"); if (len > 0) { server.bytesIn(len); @@ -247,8 +247,8 @@ SslStateData::Connection::error(int const xerrno) if (xerrno == COMM_ERR_CLOSING) return; - debug(50, debugLevelForError(xerrno)) - ("sslReadServer: FD %d: read failure: %s\n", fd(), xstrerror()); + debugs(50, debugLevelForError(xerrno), "sslReadServer: FD " << fd() << + ": read failure: " << xstrerror()); if (!ignoreErrno(xerrno)) comm_close(fd()); @@ -276,7 +276,7 @@ SslStateData::readClient(char *buf, size_t len, comm_err_t errcode, int xerrno) if (errcode == COMM_ERR_CLOSING) return; - debug(26, 3) ("sslReadClient: FD %d, read %d bytes\n", client.fd(), (int) len); + debugs(26, 3, "sslReadClient: FD " << client.fd() << ", read " << (int) len << " bytes"); if (len > 0) { client.bytesIn(len); @@ -323,7 +323,7 @@ SslStateData::WriteServerDone(int fd, char *buf, size_t len, comm_err_t flag, in void SslStateData::writeServerDone(char *buf, size_t len, comm_err_t flag, int xerrno) { - debug(26, 3) ("sslWriteServer: FD %d, %d bytes written\n", server.fd(), (int)len); + debugs(26, 3, "sslWriteServer: FD " << server.fd() << ", " << (int)len << " bytes written"); /* Error? */ if (len < 0 || flag != COMM_OK) { @@ -381,7 +381,7 @@ SslStateData::Connection::dataSent (size_t amount) void SslStateData::writeClientDone(char *buf, size_t len, comm_err_t flag, int xerrno) { - debug(26, 3) ("sslWriteClient: FD %d, %d bytes written\n", client.fd(), (int)len); + debugs(26, 3, "sslWriteClient: FD " << client.fd() << ", " << (int)len << " bytes written"); /* Error? */ if (len < 0 || flag != COMM_OK) { @@ -417,7 +417,7 @@ static void sslTimeout(int fd, void *data) { SslStateData *sslState = (SslStateData *)data; - debug(26, 3) ("sslTimeout: FD %d\n", fd); + debugs(26, 3, "sslTimeout: FD " << fd); /* Temporary lock to protect our own feets (comm_close -> sslClientClosed -> Free) */ cbdataInternalLock(sslState); @@ -503,7 +503,7 @@ static void sslConnected(int fd, void *data) { SslStateData *sslState = (SslStateData *)data; - debug(26, 3) ("sslConnected: FD %d sslState=%p\n", fd, sslState); + debugs(26, 3, "sslConnected: FD " << fd << " sslState=" << sslState); *sslState->status_ptr = HTTP_OK; comm_write(sslState->client.fd(), conn_established, strlen(conn_established), sslConnectedWriteDone, sslState, NULL); @@ -545,7 +545,7 @@ sslConnectDone(int fdnotused, comm_err_t status, int xerrno, void *data) sslState->host); if (status == COMM_ERR_DNS) { - debug(26, 4) ("sslConnect: Unknown host: %s\n", sslState->host); + debugs(26, 4, "sslConnect: Unknown host: " << sslState->host); err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND, request); *sslState->status_ptr = HTTP_NOT_FOUND; err->dnsserver_msg = xstrdup(dns_error_message); @@ -612,8 +612,7 @@ sslStart(ClientHttpRequest * http, size_t * size_ptr, int *status_ptr) } } - debug(26, 3) ("sslStart: '%s %s'\n", - RequestMethodStr[request->method], url); + debugs(26, 3, "sslStart: '" << RequestMethodStr[request->method] << " " << url << "'"); statCounter.server.all.requests++; statCounter.server.other.requests++; /* Create socket. */ @@ -626,7 +625,7 @@ sslStart(ClientHttpRequest * http, size_t * size_ptr, int *status_ptr) url); if (sock == COMM_ERROR) { - debug(26, 4) ("sslStart: Failed because we're out of sockets.\n"); + debugs(26, 4, "sslStart: Failed because we're out of sockets."); err = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request); *status_ptr = HTTP_INTERNAL_SERVER_ERROR; err->xerrno = errno; @@ -678,7 +677,7 @@ sslProxyConnected(int fd, void *data) HttpHeader hdr_out(hoRequest); Packer p; http_state_flags flags; - debug(26, 3) ("sslProxyConnected: FD %d sslState=%p\n", fd, sslState); + debugs(26, 3, "sslProxyConnected: FD " << fd << " sslState=" << sslState); memset(&flags, '\0', sizeof(flags)); flags.proxying = sslState->request->flags.proxying; MemBuf mb; diff --git a/src/unlinkd.cc b/src/unlinkd.cc index 87c418779f..9b3ec19a05 100644 --- a/src/unlinkd.cc +++ b/src/unlinkd.cc @@ -1,6 +1,6 @@ /* - * $Id: unlinkd.cc,v 1.61 2007/04/24 15:04:22 hno Exp $ + * $Id: unlinkd.cc,v 1.62 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 2 Unlink Daemon * AUTHOR: Duane Wessels @@ -121,13 +121,11 @@ unlinkdUnlink(const char *path) x = write(unlinkd_wfd, buf, l); if (x < 0) { - debug(2, 1) ("unlinkdUnlink: write FD %d failed: %s\n", - unlinkd_wfd, xstrerror()); + debugs(2, 1, "unlinkdUnlink: write FD " << unlinkd_wfd << " failed: " << xstrerror()); safeunlink(path, 0); return; } else if (x != l) { - debug(2, 1) ("unlinkdUnlink: FD %d only wrote %d of %d bytes\n", - unlinkd_wfd, x, l); + debugs(2, 1, "unlinkdUnlink: FD " << unlinkd_wfd << " only wrote " << x << " of " << l << " bytes"); safeunlink(path, 0); return; } @@ -242,11 +240,11 @@ IPC_FIFO, if (FD_PIPE == fd_table[unlinkd_wfd].type) commUnsetNonBlocking(unlinkd_wfd); - debug(2, 1) ("Unlinkd pipe opened on FD %d\n", unlinkd_wfd); + debugs(2, 1, "Unlinkd pipe opened on FD " << unlinkd_wfd); #ifdef _SQUID_MSWIN_ - debug(2, 4) ("Unlinkd handle: 0x%x, PID: %d\n", (unsigned)hIpc, pid); + debugs(2, 4, "Unlinkd handle: 0x" << hex << (unsigned)hIpc << dec << ", PID: " << pid); #endif diff --git a/src/url.cc b/src/url.cc index 4b89bd6004..e4788fce9d 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.156 2007/04/07 09:35:38 serassio Exp $ + * $Id: url.cc,v 1.157 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -84,7 +84,7 @@ url_convert_hex(char *org_url, int allocate) void urlInitialize(void) { - debug(23, 5) ("urlInitialize: Initializing...\n"); + debugs(23, 5, "urlInitialize: Initializing..."); /* this ensures that the number of protocol strings is the same as * the enum slots allocated because the last enum is always 'TOTAL'. */ @@ -230,7 +230,7 @@ urlParse(method_t method, char *url, HttpRequest *request) if ((l = strlen(url)) + Config.appendDomainLen > (MAX_URL - 1)) { /* terminate so it doesn't overflow other buffers */ *(url + (MAX_URL >> 1)) = '\0'; - debug(23, 1) ("urlParse: URL too large (%d bytes)\n", l); + debugs(23, 1, "urlParse: URL too large (" << l << " bytes)"); return NULL; } @@ -284,7 +284,7 @@ urlParse(method_t method, char *url, HttpRequest *request) } if (Config.onoff.check_hostnames && strspn(host, Config.onoff.allow_underscore ? valid_hostname_chars_u : valid_hostname_chars) != strlen(host)) { - debug(23, 1) ("urlParse: Illegal character in hostname '%s'\n", host); + debugs(23, 1, "urlParse: Illegal character in hostname '" << host << "'"); return NULL; } @@ -303,7 +303,7 @@ urlParse(method_t method, char *url, HttpRequest *request) strncat(host, Config.appendDomain, SQUIDHOSTNAMELEN - strlen(host) - 1); if (port < 1 || port > 65535) { - debug(23, 3) ("urlParse: Invalid port '%d'\n", port); + debugs(23, 3, "urlParse: Invalid port '" << port << "'"); return NULL; } @@ -311,13 +311,13 @@ urlParse(method_t method, char *url, HttpRequest *request) /* These ports are filtered in the default squid.conf, but * maybe someone wants them hardcoded... */ if (port == 7 || port == 9 || port == 19) { - debug(23, 0) ("urlParse: Deny access to port %d\n", port); + debugs(23, 0, "urlParse: Deny access to port " << port); return NULL; } #endif if (stringHasWhitespace(urlpath)) { - debug(23, 2) ("urlParse: URI has whitespace: {%s}\n", url); + debugs(23, 2, "urlParse: URI has whitespace: {" << url << "}"); switch (Config.uri_whitespace) { @@ -367,7 +367,7 @@ urlParse(method_t method, char *url, HttpRequest *request) static HttpRequest * urnParse(method_t method, char *urn) { - debug(50, 5) ("urnParse: %s\n", urn); + debugs(50, 5, "urnParse: " << urn); return new HttpRequest(method, PROTO_URN, urn + 4); } diff --git a/src/urn.cc b/src/urn.cc index d158927a42..94e7755a5a 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,6 +1,6 @@ /* - * $Id: urn.cc,v 1.104 2007/04/21 07:14:15 wessels Exp $ + * $Id: urn.cc,v 1.105 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -135,22 +135,22 @@ urnFindMinRtt(url_entry * urls, method_t m, int *rtt_ret) url_entry *min_u = NULL; int i; int urlcnt = 0; - debug(52, 3) ("urnFindMinRtt\n"); + debugs(52, 3, "urnFindMinRtt"); assert(urls != NULL); for (i = 0; NULL != urls[i].url; i++) urlcnt++; - debug(53, 3) ("urnFindMinRtt: Counted %d URLs\n", i); + debugs(53, 3, "urnFindMinRtt: Counted " << i << " URLs"); if (1 == urlcnt) { - debug(52, 3) ("urnFindMinRtt: Only one URL - return it!\n"); + debugs(52, 3, "urnFindMinRtt: Only one URL - return it!"); return urls; } for (i = 0; i < urlcnt; i++) { u = &urls[i]; - debug(52, 3) ("urnFindMinRtt: %s rtt=%d\n", u->host, u->rtt); + debugs(52, 3, "urnFindMinRtt: " << u->host << " rtt=" << u->rtt); if (u->rtt == 0) continue; @@ -166,9 +166,9 @@ urnFindMinRtt(url_entry * urls, method_t m, int *rtt_ret) if (rtt_ret) *rtt_ret = min_rtt; - debug(52, 1) ("urnFindMinRtt: Returning '%s' RTT %d\n", - min_u ? min_u->url : "NONE", - min_rtt); + debugs(52, 1, "urnFindMinRtt: Returning '" << + (min_u ? min_u->url : "NONE") << "' RTT " << + min_rtt ); return min_u; } @@ -227,7 +227,7 @@ UrnState::setUriResFromRequest(HttpRequest *r) createUriResRequest (r->urlpath); if (urlres_r == NULL) { - debug(52, 3) ("urnStart: Bad uri-res URL %s\n", urlres); + debugs(52, 3, "urnStart: Bad uri-res URL " << urlres); ErrorState *err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, r); err->url = urlres; urlres = NULL; @@ -242,7 +242,7 @@ UrnState::setUriResFromRequest(HttpRequest *r) void UrnState::start(HttpRequest * r, StoreEntry * e) { - debug(52, 3) ("urnStart: '%s'\n", e->url()); + debugs(52, 3, "urnStart: '" << e->url() << "'" ); entry = e; request = HTTPMSGLOCK(r); @@ -328,7 +328,7 @@ urnHandleReply(void *data, StoreIOBuffer result) char *buf = urnState->reqbuf; StoreIOBuffer tempBuffer; - debug(52, 3) ("urnHandleReply: Called with size=%u.\n", (unsigned int)result.length); + debugs(52, 3, "urnHandleReply: Called with size=" << (unsigned int)result.length << "."); /* Can't be lower because of the goto's */ HttpVersion version(1, 0); @@ -368,8 +368,7 @@ urnHandleReply(void *data, StoreIOBuffer result) k = headersEnd(buf, urnState->reqofs); if (0 == k) { - debug(52, 1) ("urnHandleReply: didn't find end-of-headers for %s\n", - e->url()); + debugs(52, 1, "urnHandleReply: didn't find end-of-headers for " << e->url() ); goto error; } @@ -377,10 +376,10 @@ urnHandleReply(void *data, StoreIOBuffer result) assert(urlres_e->getReply()); rep = new HttpReply; rep->parseCharBuf(buf, k); - debug(52, 3) ("reply exists, code=%d.\n", rep->sline.status); + debugs(52, 3, "reply exists, code=" << rep->sline.status << "."); if (rep->sline.status != HTTP_OK) { - debug(52, 3) ("urnHandleReply: failed.\n"); + debugs(52, 3, "urnHandleReply: failed."); err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request); err->url = xstrdup(e->url()); errorAppendEntry(e, err); @@ -398,10 +397,10 @@ urnHandleReply(void *data, StoreIOBuffer result) for (i = 0; NULL != urls[i].url; i++) urlcnt++; - debug(53, 3) ("urnFindMinRtt: Counted %d URLs\n", i); + debugs(53, 3, "urnFindMinRtt: Counted " << i << " URLs"); if (urls == NULL) { /* unkown URN error */ - debug(52, 3) ("urnTranslateDone: unknown URN %s\n", e->url()); + debugs(52, 3, "urnTranslateDone: unknown URN " << e->url() ); err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request); err->url = xstrdup(e->url()); errorAppendEntry(e, err); @@ -420,7 +419,7 @@ urnHandleReply(void *data, StoreIOBuffer result) for (i = 0; i < urlcnt; i++) { u = &urls[i]; - debug(52, 3) ("URL {%s}\n", u->url); + debugs(52, 3, "URL {" << u->url << "}"); mb->Printf( "%s", u->url, u->url); @@ -446,7 +445,7 @@ urnHandleReply(void *data, StoreIOBuffer result) "text/html", mb->contentSize(), 0, squid_curtime); if (urnState->flags.force_menu) { - debug(51, 3) ("urnHandleReply: forcing menu\n"); + debugs(51, 3, "urnHandleReply: forcing menu"); } else if (min_u) { rep->header.putStr(HDR_LOCATION, min_u->url); } @@ -485,11 +484,11 @@ urnParseReply(const char *inbuf, method_t m) url_entry *old; int n = 32; int i = 0; - debug(52, 3) ("urnParseReply\n"); + debugs(52, 3, "urnParseReply"); list = (url_entry *)xcalloc(n + 1, sizeof(*list)); for (token = strtok(buf, crlf); token; token = strtok(NULL, crlf)) { - debug(52, 3) ("urnParseReply: got '%s'\n", token); + debugs(52, 3, "urnParseReply: got '" << token << "'"); if (i == n) { old = list; @@ -508,7 +507,7 @@ urnParseReply(const char *inbuf, method_t m) rtt = netdbHostRtt(host); if (0 == rtt) { - debug(52, 3) ("urnParseReply: Pinging %s\n", host); + debugs(52, 3, "urnParseReply: Pinging " << host); netdbPingSite(host); } @@ -519,6 +518,6 @@ urnParseReply(const char *inbuf, method_t m) i++; } - debug(52, 3) ("urnParseReply: Found %d URLs\n", i); + debugs(52, 3, "urnParseReply: Found " << i << " URLs"); return list; } diff --git a/src/useragent.cc b/src/useragent.cc index 66cf7f0e90..17affe7aab 100644 --- a/src/useragent.cc +++ b/src/useragent.cc @@ -1,6 +1,6 @@ /* - * $Id: useragent.cc,v 1.30 2007/04/25 11:30:18 adrian Exp $ + * $Id: useragent.cc,v 1.31 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 40 User-Agent Logging * AUTHOR: Joe Ramey @@ -47,7 +47,7 @@ useragentOpenLog(void) assert(NULL == useragentlog); if (!Config.Log.useragent || (0 == strcmp(Config.Log.useragent, "none"))) { - debug(40, 1) ("User-Agent logging is disabled.\n"); + debugs(40, 1, "User-Agent logging is disabled."); return; } diff --git a/src/wccp.cc b/src/wccp.cc index 6ae16ae26a..ab8eee3b16 100644 --- a/src/wccp.cc +++ b/src/wccp.cc @@ -1,6 +1,6 @@ /* - * $Id: wccp.cc,v 1.41 2006/08/07 02:28:22 robertc Exp $ + * $Id: wccp.cc,v 1.42 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Glenn Chisholm @@ -114,7 +114,7 @@ static void wccpAssignBuckets(void); void wccpInit(void) { - debug(80, 5) ("wccpInit: Called\n"); + debugs(80, 5, "wccpInit: Called"); memset(&wccp_here_i_am, '\0', sizeof(wccp_here_i_am)); wccp_here_i_am.type = htonl(WCCP_HERE_I_AM); wccp_here_i_am.version = htonl(Config.Wccp.version); @@ -136,10 +136,10 @@ wccpConnectionOpen(void) struct sockaddr_in router, local; socklen_t local_len, router_len; - debug(80, 5) ("wccpConnectionOpen: Called\n"); + debugs(80, 5, "wccpConnectionOpen: Called"); if (Config.Wccp.router.s_addr == any_addr.s_addr) { - debug(1, 1) ("WCCP Disabled.\n"); + debugs(1, 1, "WCCP Disabled."); return; } @@ -159,8 +159,7 @@ wccpConnectionOpen(void) NULL, 0); - debug(1, 1) ("Accepting WCCP messages on port %d, FD %d.\n", - (int) port, theWccpConnection); + debugs(1, 1, "Accepting WCCP messages on port " << (int) port << ", FD " << theWccpConnection << "."); router_len = sizeof(router); @@ -191,7 +190,7 @@ void wccpConnectionClose(void) { if (theWccpConnection > -1) { - debug(80, 1) ("FD %d Closing WCCP socket\n", theWccpConnection); + debugs(80, 1, "FD " << theWccpConnection << " Closing WCCP socket"); comm_close(theWccpConnection); theWccpConnection = -1; } @@ -212,7 +211,7 @@ wccpHandleUdp(int sock, void *not_used) socklen_t from_len; int len; - debug(80, 6) ("wccpHandleUdp: Called.\n"); + debugs(80, 6, "wccpHandleUdp: Called."); commSetSelect(sock, COMM_SELECT_READ, wccpHandleUdp, NULL, 0); @@ -227,14 +226,13 @@ wccpHandleUdp(int sock, void *not_used) (struct sockaddr *) &from, &from_len); - debug(80, 3) ("wccpHandleUdp: %d bytes WCCP pkt from %s: type=%u, version=%u, change=%u, id=%u, number=%u\n", - len, - inet_ntoa(from.sin_addr), - (unsigned) ntohl(wccp_i_see_you.type), - (unsigned) ntohl(wccp_i_see_you.version), - (unsigned) ntohl(wccp_i_see_you.change), - (unsigned) ntohl(wccp_i_see_you.id), - (unsigned) ntohl(wccp_i_see_you.number)); + debugs(80, 3, "wccpHandleUdp: " << len << " bytes WCCP pkt from " << + inet_ntoa(from.sin_addr) << ": type=" << + (unsigned) ntohl(wccp_i_see_you.type) << ", version=" << + (unsigned) ntohl(wccp_i_see_you.version) << ", change=" << + (unsigned) ntohl(wccp_i_see_you.change) << ", id=" << + (unsigned) ntohl(wccp_i_see_you.id) << ", number=" << + (unsigned) ntohl(wccp_i_see_you.number)); if (len < 0) return; @@ -249,8 +247,10 @@ wccpHandleUdp(int sock, void *not_used) return; if (ntohl(wccp_i_see_you.number) > WCCP_ACTIVE_CACHES) { - debug(80, 1) ("Ignoring WCCP_I_SEE_YOU from %s with number of caches set to %d\n", - inet_ntoa(from.sin_addr), (int) ntohl(wccp_i_see_you.number)); + debugs(80, 1, "Ignoring WCCP_I_SEE_YOU from " << + inet_ntoa(from.sin_addr) << " with number of caches set to " << + (int) ntohl(wccp_i_see_you.number)); + return; } @@ -309,7 +309,7 @@ wccpLowestIP(void) static void wccpHereIam(void *voidnotused) { - debug(80, 6) ("wccpHereIam: Called\n"); + debugs(80, 6, "wccpHereIam: Called"); wccp_here_i_am.id = last_id; comm_udp_send(theWccpConnection, @@ -335,7 +335,7 @@ wccpAssignBuckets(void) int cache_len; char *buf; - debug(80, 6) ("wccpAssignBuckets: Called\n"); + debugs(80, 6, "wccpAssignBuckets: Called"); number_caches = ntohl(wccp_i_see_you.number); assert(number_caches > 0); diff --git a/src/wccp2.cc b/src/wccp2.cc index 82050ed63a..639760a0c6 100644 --- a/src/wccp2.cc +++ b/src/wccp2.cc @@ -1,6 +1,6 @@ /* - * $Id: wccp2.cc,v 1.14 2007/04/07 10:01:50 serassio Exp $ + * $Id: wccp2.cc,v 1.15 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 80 WCCP Support * AUTHOR: Steven Wilton @@ -32,6 +32,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ + #include "squid.h" #include "comm.h" #include "event.h" @@ -453,7 +454,7 @@ void wccp2_add_service_list(int service, int service_id, int service_priority, static void wccp2InitServices(void) { - debug(80, 5) ("wccp2InitServices: called\n"); + debugs(80, 5, "wccp2InitServices: called"); } static void @@ -488,7 +489,7 @@ wccp2_add_service_list(int service, int service_id, int service_priority, wccp2_service_list_ptr = (wccp2_service_list_t *) xcalloc(1, sizeof(struct wccp2_service_list_t)); - debug(80, 5) ("wccp2_add_service_list: added service id %d\n", service_id); + debugs(80, 5, "wccp2_add_service_list: added service id " << service_id); /* XXX check what needs to be wrapped in htons()! */ wccp2_service_list_ptr->info.service_type = htons(WCCP2_SERVICE_INFO); @@ -539,7 +540,7 @@ wccp2_update_md5_security(char *password, char *ptr, char *packet, int len) struct wccp2_security_md5_t *ws; - debug(80, 5) ("wccp2_update_md5_security: called\n"); + debugs(80, 5, "wccp2_update_md5_security: called"); /* The password field, for the MD5 hash, needs to be 8 bytes and NUL padded. */ memset(pwd, 0, sizeof(pwd)); @@ -550,7 +551,7 @@ wccp2_update_md5_security(char *password, char *ptr, char *packet, int len) /* Its the security part */ if (ntohl(ws->security_option) != WCCP2_MD5_SECURITY) { - debug(80, 5) ("wccp2_update_md5_security: this service ain't md5'ing, abort\n"); + debugs(80, 5, "wccp2_update_md5_security: this service ain't md5'ing, abort"); return 0; } @@ -595,7 +596,7 @@ wccp2_check_security(struct wccp2_service_list_t *srv, char *security, char *pac if (ntohl(ws->security_option) != srv->wccp2_security_type) { - debug(80, 1) ("wccp2_check_security: received packet has the wrong security option\n"); + debugs(80, 1, "wccp2_check_security: received packet has the wrong security option"); return 0; } @@ -606,7 +607,7 @@ wccp2_check_security(struct wccp2_service_list_t *srv, char *security, char *pac if (srv->wccp2_security_type != WCCP2_MD5_SECURITY) { - debug(80, 1) ("wccp2_check_security: invalid security option\n"); + debugs(80, 1, "wccp2_check_security: invalid security option"); return 0; } @@ -647,7 +648,7 @@ wccp2Init(void) struct wccp2_security_md5_t wccp2_security_md5; - debug(80, 5) ("wccp2Init: Called\n"); + debugs(80, 5, "wccp2Init: Called"); if (wccp2_connected == 1) return; @@ -951,10 +952,10 @@ wccp2ConnectionOpen(void) struct wccp2_router_list_t *router_list_ptr; - debug(80, 5) ("wccp2ConnectionOpen: Called\n"); + debugs(80, 5, "wccp2ConnectionOpen: Called"); if (wccp2_numrouters == 0 || !wccp2_service_list_head) { - debug(80, 2) ("WCCPv2 Disabled.\n"); + debugs(80, 2, "WCCPv2 Disabled."); return; } @@ -981,10 +982,8 @@ wccp2ConnectionOpen(void) NULL, 0); - debug(80, 1) ("Accepting WCCPv2 messages on port %d, FD %d.\n", - (int) port, theWccp2Connection); - - debug(80, 1) ("Initialising all WCCPv2 lists\n"); + debugs(80, 1, "Accepting WCCPv2 messages on port " << (int) port << ", FD " << theWccp2Connection << "."); + debugs(80, 1, "Initialising all WCCPv2 lists"); /* Initialise all routers on all services */ memset(&null, 0, sizeof(null)); @@ -1048,7 +1047,7 @@ wccp2ConnectionClose(void) } if (theWccp2Connection > -1) { - debug(80, 1) ("FD %d Closing WCCP socket\n", theWccp2Connection); + debugs(80, 1, "FD " << theWccp2Connection << " Closing WCCP socket"); comm_close(theWccp2Connection); theWccp2Connection = -1; } @@ -1142,7 +1141,7 @@ wccp2HandleUdp(int sock, void *not_used) char *ptr; int num_caches; - debug(80, 6) ("wccp2HandleUdp: Called.\n"); + debugs(80, 6, "wccp2HandleUdp: Called."); commSetSelect(sock, COMM_SELECT_READ, wccp2HandleUdp, NULL, 0); @@ -1166,7 +1165,7 @@ wccp2HandleUdp(int sock, void *not_used) if (ntohl(wccp2_i_see_you.type) != WCCP2_I_SEE_YOU) return; - debug(80, 3) ("Incoming WCCPv2 I_SEE_YOU length %d.\n", ntohs(wccp2_i_see_you.length)); + debugs(80, 3, "Incoming WCCPv2 I_SEE_YOU length " << ntohs(wccp2_i_see_you.length) << "."); /* Record the total data length */ data_length = ntohs(wccp2_i_see_you.length); @@ -1174,7 +1173,7 @@ wccp2HandleUdp(int sock, void *not_used) offset = 0; if (data_length > len) { - debug(80, 1) ("ERROR: Malformed WCCPv2 packet claiming it's bigger than received data\n"); + debugs(80, 1, "ERROR: Malformed WCCPv2 packet claiming it's bigger than received data"); return; } @@ -1188,7 +1187,7 @@ wccp2HandleUdp(int sock, void *not_used) case WCCP2_SECURITY_INFO: if (security_info != NULL) { - debug(80, 1) ("Duplicate security definition\n"); + debugs(80, 1, "Duplicate security definition"); return; } @@ -1198,7 +1197,7 @@ wccp2HandleUdp(int sock, void *not_used) case WCCP2_SERVICE_INFO: if (service_info != NULL) { - debug(80, 1) ("Duplicate service_info definition\n"); + debugs(80, 1, "Duplicate service_info definition"); return; } @@ -1208,7 +1207,7 @@ wccp2HandleUdp(int sock, void *not_used) case WCCP2_ROUTER_ID_INFO: if (router_identity_info != NULL) { - debug(80, 1) ("Duplicate router_identity_info definition\n"); + debugs(80, 1, "Duplicate router_identity_info definition"); return; } @@ -1218,7 +1217,7 @@ wccp2HandleUdp(int sock, void *not_used) case WCCP2_RTR_VIEW_INFO: if (router_view_header != NULL) { - debug(80, 1) ("Duplicate router_view definition\n"); + debugs(80, 1, "Duplicate router_view definition"); return; } @@ -1228,7 +1227,7 @@ wccp2HandleUdp(int sock, void *not_used) case WCCP2_CAPABILITY_INFO: if (router_capability_header != NULL) { - debug(80, 1) ("Duplicate router_capability definition\n"); + debugs(80, 1, "Duplicate router_capability definition"); return; } @@ -1241,25 +1240,24 @@ wccp2HandleUdp(int sock, void *not_used) break; default: - debug(80, 1) ("Unknown record type in WCCPv2 Packet (%d).\n", - ntohs(header->type)); + debugs(80, 1, "Unknown record type in WCCPv2 Packet (" << ntohs(header->type) << ")."); } offset += sizeof(struct wccp2_item_header_t); offset += ntohs(header->length); if (offset > data_length) { - debug(80, 1) ("Error: WCCPv2 packet tried to tell us there is data beyond the end of the packet\n"); + debugs(80, 1, "Error: WCCPv2 packet tried to tell us there is data beyond the end of the packet"); return; } } if ((security_info == NULL) || (service_info == NULL) || (router_identity_info == NULL) || (router_view_header == NULL)) { - debug(80, 1) ("Incomplete WCCPv2 Packet\n"); + debugs(80, 1, "Incomplete WCCPv2 Packet"); return; } - debug(80, 5) ("Complete packet received\n"); + debugs(80, 5, "Complete packet received"); /* Check that the service in the packet is configured on this router */ service_list_ptr = wccp2_service_list_head; @@ -1273,7 +1271,7 @@ wccp2HandleUdp(int sock, void *not_used) } if (service_list_ptr == NULL) { - debug(80, 1) ("WCCPv2 Unknown service received from router (%d)\n", service_info->service_id); + debugs(80, 1, "WCCPv2 Unknown service received from router (" << service_info->service_id << ")"); return; } @@ -1283,7 +1281,7 @@ wccp2HandleUdp(int sock, void *not_used) } if (!wccp2_check_security(service_list_ptr, (char *) security_info, (char *) &wccp2_i_see_you, len)) { - debug(80, 1) ("Received WCCPv2 Packet failed authentication\n"); + debugs(80, 1, "Received WCCPv2 Packet failed authentication"); return; } @@ -1294,7 +1292,7 @@ wccp2HandleUdp(int sock, void *not_used) } if (router_list_ptr->next == NULL) { - debug(80, 1) ("WCCPv2 Packet received from unknown router\n"); + debugs(80, 1, "WCCPv2 Packet received from unknown router"); return; } @@ -1310,7 +1308,7 @@ wccp2HandleUdp(int sock, void *not_used) /* TODO: check return/forwarding methods */ if (router_capability_header == NULL) { if ((Config.Wccp2.return_method != WCCP2_PACKET_RETURN_METHOD_GRE) || (Config.Wccp2.forwarding_method != WCCP2_FORWARDING_METHOD_GRE)) { - debug(80, 1) ("wccp2HandleUdp: fatal error - A WCCP router does not support the forwarding method specified, only GRE supported\n"); + debugs(80, 1, "wccp2HandleUdp: fatal error - A WCCP router does not support the forwarding method specified, only GRE supported"); wccp2ConnectionClose(); return; } @@ -1355,15 +1353,14 @@ wccp2HandleUdp(int sock, void *not_used) break; default: - debug(80, 1) ("Unknown capability type in WCCPv2 Packet (%d).\n", - ntohs(router_capability_element->capability_type)); + debugs(80, 1, "Unknown capability type in WCCPv2 Packet (" << ntohs(router_capability_element->capability_type) << ")."); } router_capability_element = (struct wccp2_capability_element_t *) (((char *) router_capability_element) + sizeof(struct wccp2_capability_element_header_t) + ntohs(router_capability_element->capability_length)); } } - debug(80, 5) ("Cleaning out cache list\n"); + debugs(80, 5, "Cleaning out cache list"); /* clean out the old cache list */ for (cache_list_ptr = &router_list_ptr->cache_list_head; cache_list_ptr; cache_list_ptr = cache_list_ptr_next) { @@ -1452,7 +1449,7 @@ wccp2HandleUdp(int sock, void *not_used) cache_list_ptr->next = NULL; - debug(80, 5) ("checking cache list: (%x:%x)\n", cache_address.s_addr, router_list_ptr->local_ip.s_addr); + debugs (80, 5, "checking cache list: (" << std::hex << cache_address.s_addr << ":" << router_list_ptr->local_ip.s_addr << ")"); /* Check to see if it's the master, or us */ @@ -1465,7 +1462,7 @@ wccp2HandleUdp(int sock, void *not_used) } } } else { - debug(80, 5) ("Adding ourselves as the only cache\n"); + debugs(80, 5, "Adding ourselves as the only cache"); /* Update the cache list */ cache_list_ptr->cache_ip = router_list_ptr->local_ip; @@ -1483,16 +1480,16 @@ wccp2HandleUdp(int sock, void *not_used) if ((found == 1) && (service_list_ptr->lowest_ip == 1)) { if (ntohl(router_view_header->change_number) != router_list_ptr->member_change) { - debug(80, 4) ("Change detected - queueing up new assignment\n"); + debugs(80, 4, "Change detected - queueing up new assignment"); router_list_ptr->member_change = ntohl(router_view_header->change_number); eventDelete(wccp2AssignBuckets, NULL); eventAdd("wccp2AssignBuckets", wccp2AssignBuckets, NULL, 15.0, 1); } else { - debug(80, 5) ("Change not detected (%d = %d)\n", (int) ntohl(router_view_header->change_number), router_list_ptr->member_change); + debugs(80, 5, "Change not detected (" << (int) ntohl(router_view_header->change_number) << " = " << router_list_ptr->member_change << ")"); } } else { eventDelete(wccp2AssignBuckets, NULL); - debug(80, 5) ("I am not the lowest ip cache - not assigning buckets\n"); + debugs(80, 5, "I am not the lowest ip cache - not assigning buckets"); } } @@ -1512,10 +1509,10 @@ wccp2HereIam(void *voidnotused) int router_len; u_short port = WCCP_PORT; - debug(80, 6) ("wccp2HereIam: Called\n"); + debugs(80, 6, "wccp2HereIam: Called"); if (wccp2_connected == 0) { - debug(80, 1) ("wccp2HereIam: wccp2 socket closed. Shutting down WCCP2\n"); + debugs(80, 1, "wccp2HereIam: wccp2 socket closed. Shutting down WCCP2"); return; } @@ -1534,7 +1531,7 @@ wccp2HereIam(void *voidnotused) service_list_ptr = wccp2_service_list_head; while (service_list_ptr != NULL) { - debug(80, 5) ("wccp2HereIam: sending to service id %d\n", service_list_ptr->info.service_id); + debugs(80, 5, "wccp2HereIam: sending to service id " << service_list_ptr->info.service_id); for (router_list_ptr = &service_list_ptr->router_list_head; router_list_ptr->next != NULL; router_list_ptr = router_list_ptr->next) { router.sin_addr = router_list_ptr->router_sendto_address; @@ -1565,7 +1562,7 @@ wccp2HereIam(void *voidnotused) wccp2_update_md5_security(service_list_ptr->wccp_password, (char *) service_list_ptr->security_info, service_list_ptr->wccp_packet, service_list_ptr->wccp_packet_size); } - debug(80, 3) ("Sending HereIam packet size %d\n", (int) service_list_ptr->wccp_packet_size); + debugs(80, 3, "Sending HereIam packet size " << (int) service_list_ptr->wccp_packet_size); /* Send the packet */ if (wccp2_numrouters > 1) { @@ -1647,7 +1644,7 @@ wccp2AssignBuckets(void *voidnotused) main_header->type = htonl(WCCP2_REDIRECT_ASSIGN); main_header->version = htons(WCCP2_VERSION); - debug(80, 2) ("Running wccp2AssignBuckets\n"); + debugs(80, 2, "Running wccp2AssignBuckets"); service_list_ptr = wccp2_service_list_head; while (service_list_ptr != NULL) { @@ -1991,14 +1988,13 @@ parse_wccp2_service(void *v) char wccp_password[WCCP2_PASSWORD_LEN + 1]; if (wccp2_connected == 1) { - debug(80, 1) ("WCCPv2: Somehow reparsing the configuration " - "without having shut down WCCP! Try reloading squid again.\n"); + debugs(80, 1, "WCCPv2: Somehow reparsing the configuration without having shut down WCCP! Try reloading squid again."); return; } /* Snarf the type */ if ((t = strtok(NULL, w_space)) == NULL) { - debug(80, 0) ("wccp2ParseServiceInfo: missing service info type (standard|dynamic)\n"); + debugs(80, 0, "wccp2ParseServiceInfo: missing service info type (standard|dynamic)"); self_destruct(); } @@ -2007,7 +2003,7 @@ parse_wccp2_service(void *v) } else if (strcmp(t, "dynamic") == 0) { service = WCCP2_SERVICE_DYNAMIC; } else { - debug(80, 0) ("wccp2ParseServiceInfo: bad service info type (expected standard|dynamic, got %s)\n", t); + debugs(80, 0, "wccp2ParseServiceInfo: bad service info type (expected standard|dynamic, got " << t << ")"); self_destruct(); } @@ -2015,7 +2011,7 @@ parse_wccp2_service(void *v) service_id = GetInteger(); if (service_id < 0 || service_id > 255) { - debug(80, 0) ("wccp2ParseServiceInfo: service info id %d is out of range (0..255)\n", service_id); + debugs(80, 0, "wccp2ParseServiceInfo: service info id " << service_id << " is out of range (0..255)"); self_destruct(); } @@ -2041,7 +2037,7 @@ dump_wccp2_service(StoreEntry * e, const char *label, void *v) srv = wccp2_service_list_head; while (srv != NULL) { - debug(80, 3) ("dump_wccp2_service: id %d, type %d\n", srv->info.service_id, srv->info.service); + debugs(80, 3, "dump_wccp2_service: id " << srv->info.service_id << ", type " << srv->info.service); storeAppendPrintf(e, "%s %s %d", label, (srv->info.service == WCCP2_SERVICE_DYNAMIC) ? "dynamic" : "standard", srv->info.service_id); @@ -2176,18 +2172,17 @@ parse_wccp2_service_info(void *v) int priority = -1; if (wccp2_connected == 1) { - debug(80, 1) ("WCCPv2: Somehow reparsing the configuration " - "without having shut down WCCP! Try reloading squid again.\n"); + debugs(80, 1, "WCCPv2: Somehow reparsing the configuration without having shut down WCCP! Try reloading squid again."); return; } - debug(80, 5) ("parse_wccp2_service_info: called\n"); + debugs(80, 5, "parse_wccp2_service_info: called"); memset(portlist, 0, sizeof(portlist)); /* First argument: id */ service_id = GetInteger(); if (service_id < 0 || service_id > 255) { - debug(80, 1) ("parse_wccp2_service_info: invalid service id %d (must be between 0 .. 255)\n", service_id); + debugs(80, 1, "parse_wccp2_service_info: invalid service id " << service_id << " (must be between 0 .. 255)"); self_destruct(); } @@ -2253,12 +2248,13 @@ dump_wccp2_service_info(StoreEntry * e, const char *label, void *v) srv = wccp2_service_list_head; while (srv != NULL) { - debug(80, 3) ("dump_wccp2_service_info: id %d (type %d)\n", srv->info.service_id, srv->info.service); + debugs(80, 3, "dump_wccp2_service_info: id " << srv->info.service_id << " (type " << srv->info.service << ")"); /* We don't need to spit out information for standard services */ if (srv->info.service == WCCP2_SERVICE_STANDARD) { - debug(80, 3) ("dump_wccp2_service_info: id %d: standard service, not dumping info\n", srv->info.service_id); + debugs(80, 3, "dump_wccp2_service_info: id " << srv->info.service_id << ": standard service, not dumping info"); + /* XXX eww */ srv = srv->next; continue; diff --git a/src/whois.cc b/src/whois.cc index d797dbd145..ba0d35f364 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -1,6 +1,6 @@ /* - * $Id: whois.cc,v 1.40 2007/04/21 07:14:15 wessels Exp $ + * $Id: whois.cc,v 1.41 2007/04/28 22:26:38 hno Exp $ * * DEBUG: section 75 WHOIS protocol * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -113,7 +113,7 @@ static void whoisTimeout(int fd, void *data) { WhoisState *p = (WhoisState *)data; - debug(75, 1) ("whoisTimeout: %s\n", p->entry->url()); + debugs(75, 1, "whoisTimeout: " << p->entry->url() ); whoisClose(fd, p); } @@ -146,8 +146,8 @@ WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrn } buf[len] = '\0'; - debug(75, 3) ("whoisReadReply: FD %d read %d bytes\n", fd, (int)len); - debug(75, 5) ("{%s}\n", buf); + debugs(75, 3, "whoisReadReply: FD " << fd << " read " << (int)len << " bytes"); + debugs(75, 5, "{" << buf << "}"); if (flag == COMM_OK && len > 0) { if (!dataWritten) @@ -166,8 +166,7 @@ WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrn do_next_read = 1; } else if (flag != COMM_OK || len < 0) { - debug(50, 2) ("whoisReadReply: FD %d: read failure: %s.\n", - fd, xstrerror()); + debugs(50, 2, "whoisReadReply: FD " << fd << ": read failure: " << xstrerror() << "."); if (ignoreErrno(errno)) { do_next_read = 1; @@ -188,7 +187,7 @@ WhoisState::readReply (int fd, char *buf, size_t len, comm_err_t flag, int xerrn fwd->complete(); - debug(75, 3) ("whoisReadReply: Done: %s\n", entry->url()); + debugs(75, 3, "whoisReadReply: Done: " << entry->url() ); comm_close(fd); @@ -203,7 +202,7 @@ static void whoisClose(int fd, void *data) { WhoisState *p = (WhoisState *)data; - debug(75, 3) ("whoisClose: FD %d\n", fd); + debugs(75, 3, "whoisClose: FD " << fd); p->entry->unlock(); cbdataFree(p); }