]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added Comm close handler for peer probe to handle closing of a probe
authorAlex Rousskov <rousskov@measurement-factory.com>
Sun, 21 Sep 2008 05:08:44 +0000 (23:08 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Sun, 21 Sep 2008 05:08:44 +0000 (23:08 -0600)
descriptor while connect is pending. This was done in preparation for
officially dropping connect callbacks for closing descriptors.

I suspect that the old-code probe would get stuck if the descriptor were
closed during connect. One the other hand, nothing but a shutdown could
close that probe descriptor, I guess.

src/neighbors.cc

index ab1dbf4d02d667f3f669b25e030b3eb8d7006a32..6a52cb7e114e4cad6890746f42ddc41f0bb25bd2 100644 (file)
@@ -1362,10 +1362,21 @@ peerConnectSucceded(peer * p)
         p->tcp_up = PEER_TCP_MAGIC_COUNT;
 }
 
+/// called by Comm when test_fd is closed while connect is in progress
+static void
+peerProbeClosed(int fd, void *data)
+{
+    peer *p = (peer*)data;
+    p->test_fd = -1;
+    // it is a failure because we failed to connect
+    peerConnectFailedSilent(p);
+}
+
 static void
 peerProbeConnectTimeout(int fd, void *data)
 {
     peer * p = (peer *)data;
+    comm_remove_close_handler(fd, &peerProbeClosed, p);
     comm_close(fd);
     p->test_fd = -1;
     peerConnectFailedSilent(p);
@@ -1395,6 +1406,7 @@ peerProbeConnect(peer * p)
     if (fd < 0)
         return ret;
 
+    comm_add_close_handler(fd, &peerProbeClosed, p);
     commSetTimeout(fd, ctimeout, peerProbeConnectTimeout, p);
 
     p->test_fd = fd;
@@ -1421,6 +1433,7 @@ peerProbeConnectDone(int fd, comm_err_t status, int xerrno, void *data)
         peerConnectFailedSilent(p);
     }
 
+    comm_remove_close_handler(fd, &peerProbeClosed, p);
     comm_close(fd);
     p->test_fd = -1;
     return;