Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Wed, 11 Jul 2001 15:40:15 +0000 (15:40 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Wed, 11 Jul 2001 15:40:15 +0000 (15:40 +0000)
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
ircd/engine_devpoll.c
ircd/engine_poll.c

index ecce833ea533a29289ad0cdf1e1b5ef47afc9813..1e71a8a8872ea8d957be79e24163072c465c244b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-07-11  Kevin L. Mitchell  <klmitch@mit.edu>
+
+       * ircd/engine_poll.c: deal with POLLHUP properly (hopefully)
+
+       * ircd/engine_devpoll.c: deal with POLLHUP properly (hopefully)
+
 2001-07-09  Kevin L. Mitchell  <klmitch@mit.edu>
 
        * ircd/os_bsd.c (os_get_rusage): move buf into the two ifdef'd
index 8bd9c75511708b0c454d96e0846d22b35b6ace4d..ece113a0a8ecb6c5ef63c917d17586cd63e7cea8 100644 (file)
 #  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 */
index 192998c5c4bc069d4df69f11669f0c2557abb22d..b5ca2c7d498a622d5381683511cf469242ee9bf4 100644 (file)
 #  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 */