OSSP CVS Repository

ossp - Check-in [2587]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2587
Date: 2002-Oct-15 23:14:27 (local)
2002-Oct-15 21:14:27 (UTC)
User:rse
Branch:
Comment: Added support to pth_poll(3) for the poll(2) XPG.4 flags POLLD{RD,WR}{NORM,BAND}.

Submitted by: Jason Evans <jasone@canonware.com> Final shaping by: Ralf S. Engelschall

Tickets:
Inspections:
Files:
ossp-pkg/pth/ChangeLog      1.569 -> 1.570     4 inserted, 0 deleted
ossp-pkg/pth/pth.h.in      1.131 -> 1.132     13 inserted, 0 deleted
ossp-pkg/pth/pth_high.c      1.84 -> 1.85     24 inserted, 7 deleted

ossp-pkg/pth/ChangeLog 1.569 -> 1.570

--- ChangeLog    2002/10/15 20:34:22     1.569
+++ ChangeLog    2002/10/15 21:14:27     1.570
@@ -21,6 +21,10 @@
 
   Changes between 1.4.1 and 1.5.0 (27-Jan-2002 to xx-Sep-2002)
 
+   *) Added support to pth_poll(3) for the poll(2) XPG.4 flags
+      POLLD{RD,WR}{NORM,BAND}.
+      [Jason Evans <jasone@canonware.com>, Ralf S. Engelschall]
+
    *) Fixed a long-standing termination bug in pth_exit(3):
       The event handler of pth_exit(3) didn't let pth_exit(3) finish if
       there were any threads on the "dead queue" (where non-detached


ossp-pkg/pth/pth.h.in 1.131 -> 1.132

--- pth.h.in     2002/01/27 11:03:40     1.131
+++ pth.h.in     2002/10/15 21:14:27     1.132
@@ -317,7 +317,20 @@
 #define PTH_FAKE_POLL @PTH_FAKE_POLL@
 #if !(PTH_FAKE_POLL)
 /* use vendor poll(2) environment */
+#define _XOPEN_SOURCE
 #include <poll.h>
+#ifndef POLLRDNORM
+#define POLLRDNORM POLLIN
+#endif
+#ifndef POLLRDBAND
+#define POLLRDBAND POLLIN
+#endif
+#ifndef POLLWRNORM
+#define POLLWRNORM POLLOUT
+#endif
+#ifndef POLLWRBAND
+#define POLLWRBAND POLLOUT
+#endif
 #ifndef INFTIM
 #define INFTIM (-1)
 #endif


ossp-pkg/pth/pth_high.c 1.84 -> 1.85

--- pth_high.c   2002/10/15 20:34:22     1.84
+++ pth_high.c   2002/10/15 21:14:27     1.85
@@ -413,13 +413,19 @@
     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|POLLRDNORM))
             FD_SET(pfd[i].fd, &rfds);
-        if (pfd[i].events & POLLOUT)
+        /* see select(2): "the only exceptional condition detectable
+           is out-of-band data received on a socket", hence we push
+           POLLWRBAND events onto wfds instead of efds. */
+        if (pfd[i].events & (POLLOUT|POLLWRNORM|POLLWRBAND))
             FD_SET(pfd[i].fd, &wfds);
-        if (pfd[i].events & POLLPRI)
+        if (pfd[i].events & (POLLPRI|POLLRDBAND))
             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|
+                                 POLLRDNORM|POLLRDBAND|
+                                 POLLWRNORM|POLLWRBAND)))
             maxfd = pfd[i].fd;
     }
     if (maxfd == -1)
@@ -439,7 +445,10 @@
                 continue;
             }
             if (FD_ISSET(pfd[i].fd, &rfds)) {
-                pfd[i].revents |= POLLIN;
+                if (pfd[i].events & POLLIN)
+                    pfd[i].revents |= POLLIN;
+                if (pfd[i].events & POLLRDNORM)
+                    pfd[i].revents |= POLLRDNORM;
                 ok++;
                 /* support for POLLHUP */
                 if (recv(pfd[i].fd, data, 64, MSG_PEEK) == -1) {
@@ -452,11 +461,19 @@
                 }
             }
             if (FD_ISSET(pfd[i].fd, &wfds)) {
-                pfd[i].revents |= POLLOUT;
+                if (pfd[i].events & POLLOUT)
+                    pfd[i].revents |= POLLOUT;
+                if (pfd[i].events & POLLWRNORM)
+                    pfd[i].revents |= POLLWRNORM;
+                if (pfd[i].events & POLLWRBAND)
+                    pfd[i].revents |= POLLWRBAND;
                 ok++;
             }
             if (FD_ISSET(pfd[i].fd, &efds)) {
-                pfd[i].revents |= POLLPRI;
+                if (pfd[i].events & POLLPRI)
+                    pfd[i].revents |= POLLPRI;
+                if (pfd[i].events & POLLRDBAND)
+                    pfd[i].revents |= POLLRDBAND;
                 ok++;
             }
             if (ok)

CVSTrac 2.0.1