]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3673: Silence 'Failed to select source' messages
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 8 Mar 2013 02:15:39 +0000 (19:15 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 8 Mar 2013 02:15:39 +0000 (19:15 -0700)
src/PeerSelectState.h
src/peer_select.cc

index 639f041a4f2435873f12c65f1483cc15336be308..b343d10d081a7c6d9452b9ce7913ccdcd3f5ebd0 100644 (file)
@@ -73,6 +73,11 @@ class ps_state
 public:
     void *operator new(size_t);
     ps_state();
+
+    // Produce a URL for display identifying the transaction we are
+    // trying to locate a peer for.
+    const char * url() const;
+
     HttpRequest *request;
     StoreEntry *entry;
     allow_t always_direct;
index fb3f20d775fe5910562e6e93eab38801c03e3de5..6199c97bff69d70c93f39511772db8f70da7a94e 100644 (file)
@@ -48,6 +48,7 @@
 #include "icmp/net_db.h"
 #include "ipcache.h"
 #include "ip/tools.h"
+#include "URL.h"
 
 static struct {
     int timeouts;
@@ -289,15 +290,10 @@ peerSelectDnsPaths(ps_state *psstate)
     PSC *callback = psstate->callback;
     psstate->callback = NULL;
 
-    if (psstate->paths->size() < 1) {
-        debugs(44, DBG_IMPORTANT, "Failed to select source for '" << psstate->entry->url() << "'");
-        debugs(44, DBG_IMPORTANT, "  always_direct = " << psstate->always_direct);
-        debugs(44, DBG_IMPORTANT, "   never_direct = " << psstate->never_direct);
-        debugs(44, DBG_IMPORTANT, "       timedout = " << psstate->ping.timedout);
-    } else {
-        debugs(44, 2, "Found sources for '" << psstate->entry->url() << "'");
-        debugs(44, 2, "  always_direct = " << psstate->always_direct);
-        debugs(44, 2, "   never_direct = " << psstate->never_direct);
+    debugs(44, 2, (psstate->paths->size()<1?"Failed to select source":"Found sources") << " for '" << psstate->url() << "'");
+    debugs(44, 2, "  always_direct = " << psstate->always_direct);
+    debugs(44, 2, "   never_direct = " << psstate->never_direct);
+    if (psstate->paths) {
         for (size_t i = 0; i < psstate->paths->size(); ++i) {
             if ((*psstate->paths)[i]->peerType == HIER_DIRECT)
                 debugs(44, 2, "         DIRECT = " << (*psstate->paths)[i]);
@@ -308,8 +304,8 @@ peerSelectDnsPaths(ps_state *psstate)
             else
                 debugs(44, 2, "     cache_peer = " << (*psstate->paths)[i]);
         }
-        debugs(44, 2, "       timedout = " << psstate->ping.timedout);
     }
+    debugs(44, 2, "       timedout = " << psstate->ping.timedout);
 
     psstate->ping.stop = current_time;
     psstate->request->hier.ping = psstate->ping;
@@ -977,6 +973,18 @@ ps_state::ps_state() : request (NULL),
     ; // no local defaults.
 }
 
+const char *
+ps_state::url() const
+{
+    if (entry)
+        return entry->url();
+
+    if (request)
+        return urlCanonical(request);
+
+    return "[no URL]";
+}
+
 ping_data::ping_data() :
         n_sent(0),
         n_recv(0),