From a6351f16f3b3038cfe018063df487fb111736c04 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Mon, 20 Sep 2010 11:47:46 -0600 Subject: [PATCH] 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. --- src/comm.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- 2.47.2