bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

poll(2) emulation doesn't work well on a file descriptor


From: Daiki Ueno
Subject: poll(2) emulation doesn't work well on a file descriptor
Date: Fri, 11 Aug 2006 16:49:02 +0900
User-agent: T-gnus/6.17.2 (based on No Gnus v0.2) EMIKO/1.14.1 (Choanoflagellata) FLIM/1.14.7 (Sanjō) APEL/10.6 EasyPG/0.0.3 MULE XEmacs/21.4 (patch 17) (Jumbo Shrimp) (i686-pc-linux)

Hi,

When I tried a tiny program which uses gnulib's poll(2) emulation on
MacOS X 10.4, I found a bug.  gnulib's poll(2) uses recv(2) with
MSG_PEEK to support POLLHUP.  However, recv(2) is only applicable to a
socket, not to a file descriptor.

Though I don't know how to fix it, I think it can be by-passed if
(pfd[i].events & POLLHUP) == 0?  Here is the patch

Index: poll.c
===================================================================
RCS file: /sources/gnulib/gnulib/lib/poll.c,v
retrieving revision 1.4
diff -u -r1.4 poll.c
--- poll.c      19 Sep 2005 17:28:14 -0000      1.4
+++ poll.c      11 Aug 2006 07:32:03 -0000
@@ -155,7 +155,8 @@
            {
              /* support for POLLHUP.  An hung up descriptor does not
                 increase the return value! */
-             if (recv (pfd[i].fd, data, 64, MSG_PEEK) == -1)
+             if (pfd[i].events & POLLHUP &&
+                 recv (pfd[i].fd, data, 64, MSG_PEEK) == -1)
                {
                  if (errno == ESHUTDOWN || errno == ECONNRESET
                      || errno == ECONNABORTED || errno == ENETRESET)


Regards,
-- 
Daiki Ueno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]