]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3605: memory leak in peer selection
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 12 Aug 2012 08:57:49 +0000 (02:57 -0600)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 12 Aug 2012 08:57:49 +0000 (02:57 -0600)
src/peer_select.cc

index 763085c21b9c42545ebf967bfc92466395bedc0b..373a14a4c3caffe392c4275dca8cd04b9a9747a1 100644 (file)
@@ -259,6 +259,18 @@ peerSelectDnsPaths(ps_state *psstate)
         return;
     }
 
+    // Bug 3605: clear any extra listed FwdServer destinations, when the options exceeds max_foward_tries.
+    // due to the allocation method of fs, we must deallocate each manually.
+    // TODO: use a std::list so we can get the size and abort adding whenever the selection loops reach Config.forward_max_tries
+    if (fs && psstate->paths->size() >= (unsigned int)Config.forward_max_tries) {
+        while(fs) {
+            FwdServer *next = fs->next;
+            cbdataReferenceDone(fs->_peer);
+            memFree(fs, MEM_FWD_SERVER);
+            fs = next;
+        }
+    }
+
     // done with DNS lookups. pass back to caller
     PSC *callback = psstate->callback;
     psstate->callback = NULL;