[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apr-cvs
Subject:    svn commit: r178844 - in /apr/apr/branches/1.1.x: CHANGES
From:       wsanchez () apache ! org
Date:       2005-05-28 0:06:56
Message-ID: 20050528000657.5365.qmail () minotaur ! apache ! org
[Download RAW message or body]

Author: wsanchez
Date: Fri May 27 17:06:56 2005
New Revision: 178844

URL: http://svn.apache.org/viewcvs?rev=178844&view=rev
Log:
Backport r178340 from trunk:

network_io/unix/sendrecv.c: Deal with EAGAIN after poll().

Following apr_wait_for_io_or_timeout(), we were doing I/O and not
dealing with EAGAIN.  It is legal for poll() to indicate that a socket
is available for writing and then for write() to fail with EAGAIN if
the state of the socket changed in between the poll() and write()
calls.  This only seems to actually happen on Mac OS 10.4 (Darwin 8).

Rather than trying write() only once, if we get an EAGAIN, continue to
call apr_wait_for_io_or_timeout() and try writing.

Modified:
    apr/apr/branches/1.1.x/CHANGES
    apr/apr/branches/1.1.x/network_io/unix/sendrecv.c

Modified: apr/apr/branches/1.1.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.1.x/CHANGES?rev=178844&r1=178843&r2=178844&view=diff
 ==============================================================================
--- apr/apr/branches/1.1.x/CHANGES (original)
+++ apr/apr/branches/1.1.x/CHANGES Fri May 27 17:06:56 2005
@@ -17,6 +17,9 @@
   *) find_apr.m4: Try installed APR before bundled copy if --with-apr not
      passed to configure.  [Justin Erenkrantz]
 
+  *) Fix issue with poll() followed by net I/O yielding EAGAIN on
+     Mac OS 10.4 (Darwin 8). [Wilfredo Sanchez]
+
 Changes for APR 1.1.0
 
   *) Added apr_procattr_user_set and apr_procattr_group_set

Modified: apr/apr/branches/1.1.x/network_io/unix/sendrecv.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.1.x/network_io/unix/sendrecv.c?rev=178844&r1=178843&r2=178844&view=diff
 ==============================================================================
--- apr/apr/branches/1.1.x/network_io/unix/sendrecv.c (original)
+++ apr/apr/branches/1.1.x/network_io/unix/sendrecv.c Fri May 27 17:06:56 2005
@@ -40,8 +40,8 @@
         rv = write(sock->socketdes, buf, (*len));
     } while (rv == -1 && errno == EINTR);
 
-    if (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) 
-                 && (sock->timeout > 0)) {
+    while (rv == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) 
+                    && (sock->timeout > 0)) {
         apr_status_t arv;
 do_select:
         arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
@@ -80,8 +80,8 @@
         rv = read(sock->socketdes, buf, (*len));
     } while (rv == -1 && errno == EINTR);
 
-    if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
-                   && (sock->timeout > 0)) {
+    while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+                      && (sock->timeout > 0)) {
 do_select:
         arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
         if (arv != APR_SUCCESS) {
@@ -120,8 +120,8 @@
                     where->salen);
     } while (rv == -1 && errno == EINTR);
 
-    if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
-                   && (sock->timeout > 0)) {
+    while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+                      && (sock->timeout > 0)) {
         apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
         if (arv != APR_SUCCESS) {
             *len = 0;
@@ -153,8 +153,8 @@
                       (struct sockaddr*)&from->sa, &from->salen);
     } while (rv == -1 && errno == EINTR);
 
-    if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
-                   && (sock->timeout > 0)) {
+    while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK)
+                      && (sock->timeout > 0)) {
         apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 1);
         if (arv != APR_SUCCESS) {
             *len = 0;
@@ -200,8 +200,8 @@
         rv = writev(sock->socketdes, vec, nvec);
     } while (rv == -1 && errno == EINTR);
 
-    if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
-                   && (sock->timeout > 0)) {
+    while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
+                      && (sock->timeout > 0)) {
         apr_status_t arv;
 do_select:
         arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
@@ -316,8 +316,8 @@
                       *len);   /* number of bytes to send */
     } while (rv == -1 && errno == EINTR);
 
-    if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
-                   && (sock->timeout > 0)) {
+    while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
+                      && (sock->timeout > 0)) {
 do_select:
         arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
         if (arv != APR_SUCCESS) {
@@ -626,8 +626,8 @@
         }
     } while (rc == -1 && errno == EINTR);
 
-    if ((rc == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
-                   && (sock->timeout > 0)) {
+    while ((rc == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
+                      && (sock->timeout > 0)) {
         apr_status_t arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
 
         if (arv != APR_SUCCESS) {
@@ -773,8 +773,8 @@
                        flags);             /* flags */
     } while (rv == -1 && errno == EINTR);
 
-    if ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
-                   && (sock->timeout > 0)) {
+    while ((rv == -1) && (errno == EAGAIN || errno == EWOULDBLOCK) 
+                      && (sock->timeout > 0)) {
 do_select:
         arv = apr_wait_for_io_or_timeout(NULL, sock, 0);
         if (arv != APR_SUCCESS) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic