On Tue, Jul 30, 2002 at 08:29:53PM +0200, Ralf S. Engelschall wrote:
> 
> In case there are still any problems and/or patches around
> we still have not included into the CVS state of Pth (see
> http://cvs.ossp.org/pkg/lib/pth/), please do not hesitate to repost them
> here again. Perhaps they were just lost or overlooked. I'll try to
> make sure they are considered again.

Following is a patch that I posted, and it has not been committed.  As
noted in its explanation, it may not suite the needs of the maintainers,
but if you provide some feedback, I'm perfectly willing to do the work to
make it acceptable.

Thanks,
Jason

--------------
Date: Sat, 22 Jun 2002 16:38:18 -0700
From: Jason Evans <[EMAIL PROTECTED]>
Subject: Problems with poll()
To: [EMAIL PROTECTED]

pth_poll_ev() does not provide any support for POLLRDNORM, POLLWRNORM,
POLLRDBAND, or POLLWRBAND.  This causes surprising errors when calling
poll(), if pth is configured with the --enable-syscall-hard flag.  The
following patch is adequate to support the additional poll() flags, but it
still does not solve the whole problem.  On Linux, it is necessary to
define _GNU_SOURCE or _XOPEN_SOURCE (other definitions may also work) in
order for the additional poll() flags to be exposed.  This means that pth
should probably always be built with _XOPEN_SOURCE on Linux, so that if an
application chooses to use the additional poll() flags, pth is able to
accomodate the application.  Always building pth like this won't hurt
anything in the case that the application does not know about the
additional poll() flags.

A patch for the pth_poll_ev() problems follows.

Thanks,
Jason Evans

--- pth-1.4.1.old/pth_high.c    Sun Jan 27 05:14:36 2002
+++ pth-1.4.1/pth_high.c        Sat Jun 22 16:18:12 2002
@@ -413,13 +413,42 @@
     for(i = 0; i < nfd; i++) {
         if (!pth_util_fd_valid(pfd[i].fd))
             return_errno(-1, EBADF);
-        if (pfd[i].events & POLLIN)
+        if (pfd[i].events & (POLLIN
+#ifdef POLLRDNORM
+                            | POLLRDNORM
+#endif
+                            ))
             FD_SET(pfd[i].fd, &rfds);
-        if (pfd[i].events & POLLOUT)
+        if (pfd[i].events & (POLLOUT
+#ifdef POLLWRNORM
+                            | POLLWRNORM
+#endif
+#ifdef POLLWRBAND
+                            | POLLWRBAND
+#endif
+                            ))
             FD_SET(pfd[i].fd, &wfds);
-        if (pfd[i].events & POLLPRI)
+        if (pfd[i].events & (POLLPRI
+#ifdef POLLRDBAND
+                            | POLLRDBAND
+#endif
+                            ))
             FD_SET(pfd[i].fd, &efds);
-        if (pfd[i].fd >= maxfd && (pfd[i].events & (POLLIN|POLLOUT|POLLPRI)))
+        if (pfd[i].fd >= maxfd && (pfd[i].events & (POLLIN|POLLOUT|POLLPRI
+#ifdef POLLRDNORM
+                                                   | POLLRDNORM
+#endif
+#ifdef POLLWRNORM
+                                                   | POLLWRNORM
+#endif
+#ifdef POLLWRBAND
+                                                   | POLLWRBAND
+#endif
+#ifdef POLLRDBAND
+                                                   | POLLRDBAND
+#endif
+
+                                                   )))
             maxfd = pfd[i].fd;
     }
     if (maxfd == -1)
@@ -439,7 +468,12 @@
                 continue;
             }
             if (FD_ISSET(pfd[i].fd, &rfds)) {
-                pfd[i].revents |= POLLIN;
+               if (pfd[i].events & POLLIN)
+                   pfd[i].revents |= POLLIN;
+#ifdef POLLRDNORM
+               if (pfd[i].events & POLLRDNORM)
+                   pfd[i].revents |= POLLRDNORM;
+#endif
                 ok++;
                 /* support for POLLHUP */
                 if (recv(pfd[i].fd, data, 64, MSG_PEEK) == -1) {
@@ -452,11 +486,25 @@
                 }
             }
             if (FD_ISSET(pfd[i].fd, &wfds)) {
-                pfd[i].revents |= POLLOUT;
+               if (pfd[i].events & POLLOUT)
+                   pfd[i].revents |= POLLOUT;
+#ifdef POLLWRNORM
+               if (pfd[i].events & POLLWRNORM)
+                   pfd[i].revents |= POLLWRNORM;
+#endif
+#ifdef POLLWRBAND
+               if (pfd[i].events & POLLWRBAND)
+                   pfd[i].revents |= POLLWRBAND;
+#endif
                 ok++;
             }
             if (FD_ISSET(pfd[i].fd, &efds)) {
-                pfd[i].revents |= POLLPRI;
+               if (pfd[i].events & POLLPRI)
+                   pfd[i].revents |= POLLPRI;
+#ifdef POLLRDBAND
+               if (pfd[i].events & POLLRDBAND)
+                   pfd[i].revents |= POLLRDBAND;
+#endif
                 ok++;
             }
             if (ok)
______________________________________________________________________
GNU Portable Threads (Pth)            http://www.gnu.org/software/pth/
User Support Mailing List                            [EMAIL PROTECTED]
Automated List Manager (Majordomo)           [EMAIL PROTECTED]

Reply via email to