]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Abort sendMoreData if our socket is being closed to avoid
authorAlex Rousskov <rousskov@measurement-factory.com>
Sat, 20 Sep 2008 05:00:47 +0000 (23:00 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Sat, 20 Sep 2008 05:00:47 +0000 (23:00 -0600)
comm.cc:2032: "!fd_table[fd].closing()" assertions in comm_write.

The assert happens when sendMoreData is triggered by an event on the other
(server) side.  The server side does not know that client side (or something
else) have decided to close the client socket. The close callback has not been
dialed yet so the client state has not been invalidated and non-async from
Store callbacks can reach it.

A better fix for this would be to convert more store callbacks to AsyncCalls,
but that may have to wait for client_side rewrite.

Also assert that USE_ZPH_QOS code does not use a negative socket descriptor.
The "fd = conn != NULL ? conn->fd : -1" code seems to imply that our
descriptor may be negative. I do not know whether that can actually happen.

This fix was a part of the recent cleanup effort but got lost when I split
the changes into several MERGE requests :-(.

src/client_side_reply.cc

index 94cb42bdfa9d92100a7432b0e7df26f85bf15f96..b2984a7723c5fa1750adccc0b6ec064612db0f72 100644 (file)
@@ -51,9 +51,7 @@
 #include "ESI.h"
 #endif
 #include "MemObject.h"
-#if USE_ZPH_QOS
 #include "fde.h"
-#endif
 #include "ACLChecklist.h"
 #include "ACL.h"
 #if DELAY_POOLS
@@ -1843,6 +1841,11 @@ clientReplyContext::sendMoreData (StoreIOBuffer result)
     ConnStateData * conn = http->getConn();
 
     int fd = conn != NULL ? conn->fd : -1;
+    if (fd >= 0 && fd_table[fd].closing()) { // too late, our conn is closing
+        // TODO: should we also quit when fd is negative?
+        debugs(33,3, HERE << "not sending more data to a closing FD " << fd);
+        return;
+    }
 
     char *buf = next()->readBuffer.data;
 
@@ -1858,6 +1861,7 @@ clientReplyContext::sendMoreData (StoreIOBuffer result)
 #if USE_ZPH_QOS
     if (reqofs==0 && !logTypeIsATcpHit(http->logType))
     {
+        assert(fd >= 0); // the beginning of this method implies fd may be -1
         int tos = 0;
         if (Config.zph_tos_peer && 
              (http->request->hier.code==SIBLING_HIT ||