]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #3048 fix: "commio_has_callback(fd, IOCB_READ, ccb)" assertion;
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 20 Sep 2010 17:47:46 +0000 (11:47 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 20 Sep 2010 17:47:46 +0000 (11:47 -0600)
may also be applicable to a similar IOCB_WITE assertion.

When we start closing a descriptor, we call commio_finish_callback() to remove
I/O callbacks. If this is not done from commHandleRead or commHandleWrite,
then select(2) structures may still have our descriptor registration and will
call Comm back to read or write before the descriptor is closed for good. This
will trigger a commio_has_callback() assertion.

Based on lp 3p1-rock branch, r9606.

src/comm.cc

index e7064a23d6b280875aee2d39ed3e05044c64d12f..d29db3e7a2dc9b47951a0d7e1300aaab901c9d73 100644 (file)
@@ -1583,11 +1583,13 @@ _comm_close(int fd, char const *file, int line)
         commStopHalfClosedMonitor(fd);
     commSetTimeout(fd, -1, NULL, NULL);
 
-    // notify read/write handlers
+    // notify read/write handlers after canceling select reservations, if any
     if (commio_has_callback(fd, IOCB_WRITE, COMMIO_FD_WRITECB(fd))) {
+        commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
         commio_finish_callback(fd, COMMIO_FD_WRITECB(fd), COMM_ERR_CLOSING, errno);
     }
     if (commio_has_callback(fd, IOCB_READ, COMMIO_FD_READCB(fd))) {
+        commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
         commio_finish_callback(fd, COMMIO_FD_READCB(fd), COMM_ERR_CLOSING, errno);
     }