From 511e23835bf478ae183ca182ee7ea481b2867a26 Mon Sep 17 00:00:00 2001 From: adrian <> Date: Tue, 15 Oct 2002 06:59:49 +0000 Subject: [PATCH] Call the scheduled but not completed IO callbacks on comm_close()! --- src/comm.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/comm.cc b/src/comm.cc index 5756931573..8e896c2cf8 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.338 2002/10/15 00:49:10 adrian Exp $ + * $Id: comm.cc,v 1.339 2002/10/15 00:59:49 adrian Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -1138,7 +1138,22 @@ _comm_close(int fd, char *file, int line) commSetTimeout(fd, -1, NULL, NULL); CommWriteStateCallbackAndFree(fd, COMM_ERR_CLOSING); - /* Delete any pending io callbacks */ + /* Schedule immediate callbacks for the read/accept/fill routines, if any */ + if (fdc_table[fd].read.handler) { + comm_addreadcallback(fd, fdc_table[fd].read.handler, fdc_table[fd].read.buf, + 0, COMM_ERR_CLOSING, 0, fdc_table[fd].read.handler_data); + fdc_table[fd].read.handler = NULL; + } + if (fdc_table[fd].accept.handler) { + comm_addacceptcallback(fd, -1, fdc_table[fd].accept.handler, NULL, NULL, + COMM_ERR_CLOSING, 0, fdc_table[fd].accept.handler_data); + fdc_table[fd].accept.handler = NULL; + } + if (fdc_table[fd].fill.handler) { + comm_add_fill_callback(fd, 0, COMM_ERR_CLOSING, 0); + fdc_table[fd].fill.handler = NULL; + } + /* Complete (w/ COMM_ERR_CLOSING!) any pending io callbacks */ while (fdc_table[fd].CommCallbackList.head != NULL) { node = fdc_table[fd].CommCallbackList.head; cio = (CommCallbackData *)node->data; @@ -1151,6 +1166,7 @@ _comm_close(int fd, char *file, int line) memPoolFree(comm_callback_pool, cio); } + commCallCloseHandlers(fd); if (F->uses) /* assume persistent connect count */ pconnHistCount(1, F->uses); -- 2.47.2