From: Alex Rousskov Date: Mon, 20 Sep 2010 17:47:46 +0000 (-0600) Subject: Bug #3048 fix: "commio_has_callback(fd, IOCB_READ, ccb)" assertion; X-Git-Tag: take1~243 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6351f16f3b3038cfe018063df487fb111736c04;p=thirdparty%2Fsquid.git Bug #3048 fix: "commio_has_callback(fd, IOCB_READ, ccb)" assertion; 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. --- diff --git a/src/comm.cc b/src/comm.cc index e7064a23d6..d29db3e7a2 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -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); }