You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2009/10/20 22:45:47 UTC

svn commit: r827787 - /httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proc_unix.c

Author: trawick
Date: Tue Oct 20 20:45:46 2009
New Revision: 827787

URL: http://svn.apache.org/viewvc?rev=827787&view=rev
Log:
socket_writev() tweaks:
* catch an error path that wasn't logged after r826760 and log it (something other 
than EAGAIN on the initial writev)
* catch the IO timeout condition and log it as APR_TIMEUP instead of trying the write
one more time and eventually logging it as EAGAIN

Modified:
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proc_unix.c

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proc_unix.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proc_unix.c?rev=827787&r1=827786&r2=827787&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proc_unix.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proc_unix.c Tue Oct 20 20:45:46 2009
@@ -656,6 +656,7 @@
                                   struct iovec *vec, int nvec,
                                   int *writecnt)
 {
+    apr_status_t rv;
     int retcode, unix_socket;
     fcgid_namedpipe_handle *handle_info;
     struct pollfd pollfds[1];
@@ -670,34 +671,38 @@
             return APR_SUCCESS;
         }
     } while (retcode == -1 && APR_STATUS_IS_EINTR(errno));
-    if (!APR_STATUS_IS_EAGAIN(errno))
-        return errno;
+    rv = errno;
 
-    /* poll() */
-    pollfds[0].fd = unix_socket;
-    pollfds[0].events = POLLOUT;
-    do {
-        retcode = poll(pollfds, 1, ipc_handle->communation_timeout * 1000);
-    } while (retcode <= 0 && APR_STATUS_IS_EINTR(errno));
-    if (retcode == -1)
-        return errno;
+    if (APR_STATUS_IS_EAGAIN(rv)) {
+        /* poll() */
+        pollfds[0].fd = unix_socket;
+        pollfds[0].events = POLLOUT;
+        do {
+            retcode = poll(pollfds, 1, ipc_handle->communation_timeout * 1000);
+        } while (retcode < 0 && APR_STATUS_IS_EINTR(errno));
 
-    /* Write again */
-    do {
-        if ((retcode = writev(unix_socket, vec, nvec)) > 0) {
-            *writecnt = retcode;
-            return APR_SUCCESS;
+        if (retcode < 0) {
+            rv = errno;
+        }
+        else if (retcode == 0) {
+            rv = APR_TIMEUP;
+        }
+        else {
+            /* Write again */
+            do {
+                if ((retcode = writev(unix_socket, vec, nvec)) > 0) {
+                    *writecnt = retcode;
+                    return APR_SUCCESS;
+                }
+            } while (retcode == -1 && APR_STATUS_IS_EINTR(errno));
+            rv = errno;
         }
-    } while (retcode == -1 && APR_STATUS_IS_EINTR(errno));
-
-    if (retcode == -1) {
-        ap_log_rerror(APLOG_MARK, APLOG_INFO, apr_get_os_error(),
-                      ipc_handle->request,
-                      "mod_fcgid: error writing data, FastCGI server closed connection");
-        return APR_EPIPE;
     }
 
-    return errno;
+    ap_log_rerror(APLOG_MARK, APLOG_INFO, rv,
+                  ipc_handle->request,
+                  "mod_fcgid: error writing data to FastCGI server");
+    return rv;
 }
 
 static apr_status_t writev_it_all(fcgid_ipc * ipc_handle,