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

index 6823bb75334d83ef83cc3b77c1636d94888f5e48..1e694c8e28073f440dbda80d9b73142f4086b347 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 bfd3a1f54185dd8b5bb554be664ba65728e176b5..e6897f0c7f87cc6d848e09d63490c0b80528b9d4 100644 (file)
@@ -55,6 +55,7 @@
 #include "SquidConfig.h"
 #include "SquidTime.h"
 #include "Store.h"
+#include "URL.h"
 
 static struct {
     int timeouts;
@@ -286,15 +287,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]);
@@ -305,8 +301,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;
@@ -972,6 +968,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),