You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ws...@apache.org on 2005/05/28 02:06:48 UTC

svn commit: r178843 - in /apr/apr/branches/1.0.x: CHANGES network_io/unix/sendrecv.c

Author: wsanchez
Date: Fri May 27 17:06:47 2005
New Revision: 178843

URL: http://svn.apache.org/viewcvs?rev=178843&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.0.x/CHANGES
    apr/apr/branches/1.0.x/network_io/unix/sendrecv.c

Modified: apr/apr/branches/1.0.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/CHANGES?rev=178843&r1=178842&r2=178843&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/CHANGES (original)
+++ apr/apr/branches/1.0.x/CHANGES Fri May 27 17:06:47 2005
@@ -11,6 +11,9 @@
      locks/netware/thread_mutex.c that prevented APR from building with the
      latest release of the LibC SDK. [Brad Nicholes]
      
+  *) Fix issue with poll() followed by net I/O yielding EAGAIN on
+     Mac OS 10.4 (Darwin 8). [Wilfredo Sanchez]
+
 Changes for APR 1.0.1
 
   *) Fix HUP return codes in pollset when using KQueue.

Modified: apr/apr/branches/1.0.x/network_io/unix/sendrecv.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.0.x/network_io/unix/sendrecv.c?rev=178843&r1=178842&r2=178843&view=diff
==============================================================================
--- apr/apr/branches/1.0.x/network_io/unix/sendrecv.c (original)
+++ apr/apr/branches/1.0.x/network_io/unix/sendrecv.c Fri May 27 17:06:47 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) {
@@ -673,8 +673,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) {
@@ -820,8 +820,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) {