From c982f87bdf01f9f09606e72132c319dd57380335 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 11 Jul 2001 15:40:15 +0000 Subject: [PATCH] Author: Kev Log message: Hopefully correct a condition that can cause the server to chew CPU by not clearing a particular fd--POLLHUP was not being caught. Please test to see if this fixes the problem! git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@529 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- ChangeLog | 6 ++++++ ircd/engine_devpoll.c | 18 +++++++++++------- ircd/engine_poll.c | 18 +++++++++++------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecce833..1e71a8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-07-11 Kevin L. Mitchell + + * ircd/engine_poll.c: deal with POLLHUP properly (hopefully) + + * ircd/engine_devpoll.c: deal with POLLHUP properly (hopefully) + 2001-07-09 Kevin L. Mitchell * ircd/os_bsd.c (os_get_rusage): move buf into the two ifdef'd diff --git a/ircd/engine_devpoll.c b/ircd/engine_devpoll.c index 8bd9c75..ece113a 100644 --- a/ircd/engine_devpoll.c +++ b/ircd/engine_devpoll.c @@ -62,13 +62,6 @@ # define POLLWRITEFLAGS POLLWRNORM #endif -/* Figure out what bits indicate errors */ -#ifdef POLLHUP -# define POLLERRORS (POLLHUP|POLLERR) -#else -# define POLLERRORS POLLERR -#endif - static struct Socket** sockList; static int devpoll_max; static int devpoll_fd; @@ -318,6 +311,17 @@ engine_loop(struct Generators* gen) } } + assert(!(polls[i].revents & POLLERR)); + +#ifdef POLLHUP + if (polls[i].revents & POLLHUP) { /* hang-up on socket */ + Debug((DEBUG_ENGINE, "devpoll: EOF from client (POLLHUP)")); + event_generate(ET_EOF, sock, 0); + nfds--; + continue; + } +#endif /* POLLHUP */ + switch (s_state(sock)) { case SS_CONNECTING: if (polls[i].revents & POLLWRITEFLAGS) { /* connection completed */ diff --git a/ircd/engine_poll.c b/ircd/engine_poll.c index 192998c..b5ca2c7 100644 --- a/ircd/engine_poll.c +++ b/ircd/engine_poll.c @@ -58,13 +58,6 @@ # define POLLWRITEFLAGS POLLWRNORM #endif -/* Figure out what bits indicate errors */ -#ifdef POLLHUP -# define POLLERRORS (POLLHUP|POLLERR) -#else -# define POLLERRORS POLLERR -#endif - static struct Socket** sockList; static struct pollfd* pollfdList; static unsigned int poll_count; @@ -310,6 +303,17 @@ engine_loop(struct Generators* gen) } } + assert(!(pollfdList[i].revents & POLLERR)); + +#ifdef POLLHUP + if (pollfdList[i].revents & POLLHUP) { /* hang-up on socket */ + Debug((DEBUG_ENGINE, "poll: EOF from client (POLLHUP)")); + event_generate(ET_EOF, sock, 0); + nfds--; + continue; + } +#endif /* POLLHUP */ + switch (s_state(sock)) { case SS_CONNECTING: if (pollfdList[i].revents & POLLWRITEFLAGS) { /* connect completed */ -- 2.20.1