[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] patch to let poll() recognize eof on more architectures



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	main.c 
Log Message:
patch to let poll() recognize eof on more architectures


Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- main.c	5 Jul 2003 07:10:34 -0000	1.77
+++ main.c	6 Aug 2003 18:38:46 -0000	1.78
@@ -274,7 +274,8 @@
     connection_free(conn);
     if(i<nfds) { /* we just replaced the one at i with a new one.
                     process it too. */
-      if(poll_array[i].revents & POLLIN) /* something to read */
+      if(poll_array[i].revents & POLLIN ||
+         poll_array[i].revents & POLLHUP ) /* something to read */
         conn_read(i);
     }
   }
@@ -552,8 +553,11 @@
     if(poll_result > 0) { /* we have at least one connection to deal with */
       /* do all the reads first, so we can detect closed sockets */
       for(i=0;i<nfds;i++)
-        if(poll_array[i].revents & POLLIN) /* something to read */
+        if(poll_array[i].revents & POLLIN ||
+           poll_array[i].revents & POLLHUP ) /* something to read */
           conn_read(i); /* this also blows away broken connections */
+/* see http://www.greenend.org.uk/rjk/2001/06/poll.html for discussion
+ * of POLLIN vs POLLHUP */
 
       /* then do the writes */
       for(i=0;i<nfds;i++)