From: Alex Rousskov Date: Sat, 20 Sep 2008 05:00:47 +0000 (-0600) Subject: Abort sendMoreData if our socket is being closed to avoid X-Git-Tag: SQUID_3_1_0_1~49^2~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9af2f95b4f2e5139c8824dbefcbd16f7b778435c;p=thirdparty%2Fsquid.git Abort sendMoreData if our socket is being closed to avoid 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 :-(. --- diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 94cb42bdfa..b2984a7723 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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 ||