From a1727eb71dfe88233813bc287f46de9467cbbb5c Mon Sep 17 00:00:00 2001 From: hno <> Date: Wed, 22 Dec 2004 01:06:33 +0000 Subject: [PATCH] Bug #1041: assertion failed: comm_epoll.cc: assert(F->flags.open) Patch by Gonzalo Arana --- src/comm_epoll.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/comm_epoll.cc b/src/comm_epoll.cc index a61fa493d8..2ed3ccf3af 100644 --- a/src/comm_epoll.cc +++ b/src/comm_epoll.cc @@ -1,6 +1,6 @@ /* - * $Id: comm_epoll.cc,v 1.5 2003/11/09 17:11:10 hno Exp $ + * $Id: comm_epoll.cc,v 1.6 2004/12/21 18:06:33 hno Exp $ * * DEBUG: section 5 Socket functions * @@ -128,13 +128,17 @@ commSetSelect(int fd, unsigned int type, PF * handler, struct epoll_event ev; assert(fd >= 0); - assert(F->flags.open); debug(5, DEBUG_EPOLL ? 0 : 8) ("commSetSelect(fd=%d,type=%u,handler=%p,client_data=%p,timeout=%ld)\n", fd,type,handler,client_data,timeout); ev.events = 0; ev.data.fd = fd; + if (!F->flags.open) { + epoll_ctl(kdpfd, EPOLL_CTL_DEL, fd, &ev); + return; + } + // If read is an interest if (type & COMM_SELECT_READ) { @@ -215,6 +219,8 @@ comm_select(int msec) checkTimeouts(); } + PROF_start(comm_check_incoming); + if (msec > max_poll_time) msec = max_poll_time; @@ -230,9 +236,12 @@ comm_select(int msec) getCurrentTime(); + PROF_stop(comm_check_incoming); + return COMM_ERROR; } + PROF_stop(comm_check_incoming); getCurrentTime(); statHistCount(&statCounter.select_fds_hist, num); @@ -251,7 +260,7 @@ comm_select(int msec) // TODO: add EPOLLPRI?? if (cevents->events & (EPOLLIN|EPOLLHUP|EPOLLERR)) { - if((hdl = F->read_handler) != NULL) { + if ((hdl = F->read_handler) != NULL) { debug(5, DEBUG_EPOLL ? 0 : 8) ("comm_select(): Calling read handler on fd=%d\n",fd); PROF_start(comm_write_handler); F->read_handler = NULL; @@ -267,7 +276,7 @@ comm_select(int msec) } if (cevents->events & (EPOLLOUT|EPOLLHUP|EPOLLERR)) { - if((hdl = F->write_handler) != NULL) { + if ((hdl = F->write_handler) != NULL) { debug(5, DEBUG_EPOLL ? 0 : 8) ("comm_select(): Calling write handler on fd=%d\n",fd); PROF_start(comm_read_handler); F->write_handler = NULL; -- 2.47.3