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/25 03:53:01 UTC

svn commit: r178340 - in /apr/apr/trunk: CHANGES network_io/unix/sendrecv.c

Author: wsanchez
Date: Tue May 24 18:53:00 2005
New Revision: 178340

URL: http://svn.apache.org/viewcvs?rev=178340&view=rev
Log:
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/trunk/CHANGES
    apr/apr/trunk/network_io/unix/sendrecv.c

Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/CHANGES?rev=178340&r1=178339&r2=178340&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES (original)
+++ apr/apr/trunk/CHANGES Tue May 24 18:53:00 2005
@@ -8,6 +8,9 @@
    *) Include the C preprocessor flags in --cflags for pkg-config.
       [Paul Querna]
 
+   *) 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.1
 
   *) Disable sendfile support for S/390 only in kernel versions < 2.4.0. 

Modified: apr/apr/trunk/network_io/unix/sendrecv.c
URL: http://svn.apache.org/viewcvs/apr/apr/trunk/network_io/unix/sendrecv.c?rev=178340&r1=178339&r2=178340&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sendrecv.c (original)
+++ apr/apr/trunk/network_io/unix/sendrecv.c Tue May 24 18:53:00 2005
@@ -41,8 +41,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);
@@ -81,8 +81,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) {
@@ -121,8 +121,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;
@@ -154,8 +154,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;
@@ -201,8 +201,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);
@@ -317,8 +317,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) {
@@ -627,8 +627,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) {
@@ -774,8 +774,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) {