apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rob Saccoccio" <r...@fastcgi.com>
Subject [PATCH] poll/unix/poll.c & poll/unix/pollacc.c
Date Sat, 20 Jul 2002 22:17:58 GMT
I encountered some funk using ab on Win2K (patch to ab.c to follow on
dev@httpd).

apr_poll() was returning errno without aprizing it or accounting for the WIN
platform.

apr_poll() didn't properly ignore pollset entries with a type of
APR_NO_DESC.

nsds is no longer setup on error.

The HAVE_POLL version of apr_poll() requires similar changes (I didn't make
them).

find_poll_sock() didn't account for entries with a type of APR_NO_DESC in
the pollset and thus could find the wrong entry.  This effects
apr_poll_revents_get(), apr_poll_socket_mask(), and apr_poll_socket_remove()
(the case that led me here - it was leaving the socket in the pollset).

--rob


diff -u -r1.8 poll.c
--- poll.c	16 Jul 2002 20:27:43 -0000	1.8
+++ poll.c	20 Jul 2002 21:51:00 -0000
@@ -186,6 +186,13 @@
             is_pipe = aprset[i].desc.f->is_pipe;
 #endif
         }
+        else if (aprset[i].desc_type == APR_NO_DESC) {
+            continue;
+        }
+        else {
+            return APR_EINVAL;
+        }
+
         if (aprset[i].reqevents & APR_POLLIN) {
             FD_SET(fd, &readset);
         }
@@ -214,14 +221,19 @@
     }
 #endif

-    (*nsds) = rv;
-    if ((*nsds) == 0) {
+    if (rv == 0) {
         return APR_TIMEUP;
     }
-    if ((*nsds) < 0) {
-        return errno;
+    if (rv < 0) {
+#ifdef WIN32
+        return APR_FROM_OS_ERROR(WSAGetLastError());
+#else
+        return APR_FROM_OS_ERROR(errno);
+#endif
     }

+    (*nsds) = rv;
+
     for (i = 0; i < num; i++) {
         int fd;

@@ -231,6 +243,10 @@
         else if (aprset[i].desc_type == APR_POLL_FILE) {
             fd = aprset[i].desc.f->filedes;
         }
+        else if (aprset[i].desc_type == APR_NO_DESC) {
+            continue;
+        }
+
         aprset[i].rtnevents = 0;
         if (FD_ISSET(fd, &readset)) {
             aprset[i].rtnevents |= APR_POLLIN;
Index: pollacc.c
===================================================================
RCS file: /home/cvspublic/apr/poll/unix/pollacc.c,v
retrieving revision 1.2
diff -u -r1.2 pollacc.c
--- pollacc.c	16 Jul 2002 05:25:44 -0000	1.2
+++ pollacc.c	20 Jul 2002 21:51:00 -0000
@@ -77,15 +77,14 @@
 static apr_pollfd_t *find_poll_sock(apr_pollfd_t *aprset, apr_socket_t
*sock)
 {
     apr_pollfd_t *curr = aprset;
-
-    while (curr->desc.s != sock) {
-        if (curr->desc_type == APR_POLL_LASTDESC) {
-            return NULL;
-        }
+
+    while (curr->desc_type != APR_POLL_LASTDESC) {
+        if (curr->desc.s == sock && curr->desc_type != APR_NO_DESC)
+            return curr;
         curr++;
     }

-    return curr;
+    return NULL;
 }

 APR_DECLARE(apr_status_t) apr_poll_socket_add(apr_pollfd_t *aprset,



Mime
View raw message