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/21 01:19:56 UTC
svn commit: r827834 - in /httpd/mod_fcgid/trunk: CHANGES-FCGID
modules/fcgid/fcgid_proc_unix.c
Author: trawick
Date: Tue Oct 20 23:19:56 2009
New Revision: 827834
URL: http://svn.apache.org/viewvc?rev=827834&view=rev
Log:
Recover from most "Resource temporarily unavailable" errors writing the
request to the FastCGI application. These were common with large request
bodies on Mac OS X and intermittent on Solaris.
I couldn't reproduce the probem on FreeBSD or Linux. A couple of old reports
I found on the web were for Mac OS X.
Two different mechanisms are used to recover from EAGAIN:
First, try writing progressively smaller buffers. This was always
sufficient to solve the issue for OS X in my testing.
Last, try sleeping 250ms between attempts to write. This was always
required in my testing on Solaris, and 1 sleep was always enough.
PR: 48025
Modified:
httpd/mod_fcgid/trunk/CHANGES-FCGID
httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proc_unix.c
Modified: httpd/mod_fcgid/trunk/CHANGES-FCGID
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/CHANGES-FCGID?rev=827834&r1=827833&r2=827834&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/CHANGES-FCGID [utf8] (original)
+++ httpd/mod_fcgid/trunk/CHANGES-FCGID [utf8] Tue Oct 20 23:19:56 2009
@@ -1,6 +1,10 @@
-*- coding: utf-8 -*-
Changes with mod_fcgid 2.3.5
+ *) Recover from most "Resource temporarily unavailable" errors writing the
+ request to the FastCGI application. These were common with large request
+ bodies on Mac OS X and intermittent on Solaris. PR 48025. [Jeff Trawick]
+
*) Fix a bug in fixconf.sed that resulted in a prefix of "FcgidFcgid" on the
updated directives. [Dan Hulme <dhulme gmail.com>]
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=827834&r1=827833&r2=827834&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 23:19:56 2009
@@ -699,6 +699,37 @@
}
}
+ if (APR_STATUS_IS_EAGAIN(rv)) {
+ /* socket is writable, but we can't write the entire buffer; try to write a
+ * smaller amount, and if even that fails then sleep
+ */
+ size_t to_write = vec[0].iov_len;
+ int slept = 0;
+ const apr_interval_time_t sleep_time = APR_USEC_PER_SEC / 4;
+ const int max_sleeps = 8;
+
+ do {
+ if ((retcode = write(unix_socket, vec[0].iov_base, to_write)) > 0) {
+ ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, ipc_handle->request,
+ "wrote %d byte(s) and slept %d time(s) after EAGAIN",
+ retcode, slept);
+ *writecnt = retcode;
+ return APR_SUCCESS;
+ }
+ if (APR_STATUS_IS_EAGAIN(errno)) {
+ if (to_write == 1) {
+ apr_sleep(sleep_time);
+ ++slept;
+ }
+ else {
+ to_write /= 2;
+ }
+ }
+ } while ((APR_STATUS_IS_EINTR(errno) || APR_STATUS_IS_EAGAIN(errno))
+ && slept < max_sleeps);
+ rv = errno;
+ }
+
ap_log_rerror(APLOG_MARK, APLOG_INFO, rv,
ipc_handle->request,
"mod_fcgid: error writing data to FastCGI server");