to a local URL-path with the INCLUDES filter active, introduced
in 2.4.11. PR 57531. [Yann Ylavic]
+ *) mod_cgid: Within the first minute of a server start or restart,
+ allow mod_cgid to retry connecting to its daemon process. Previously,
+ 'No such file or directory: unable to connect to cgi daemon...' could
+ be logged without an actual retry. PR57685.
+ [Edward Lu <Chaosed0 gmail.com>]
+
*) core: Cleanup the request soon/even if some output filter fails to
handle the EOR bucket. [Yann Ylavic]
#define DEFAULT_CONNECT_ATTEMPTS 15
#endif
+#ifndef DEFAULT_CONNECT_STARTUP_DELAY
+#define DEFAULT_CONNECT_STARTUP_DELAY 60
+#endif
+
typedef struct {
const char *logname;
long logbytes;
{
int sd;
int connect_tries;
+ int connect_errno;
apr_interval_time_t sliding_timer;
connect_tries = 0;
sliding_timer = 100000; /* 100 milliseconds */
while (1) {
+ connect_errno = 0;
++connect_tries;
if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
return log_scripterror(r, conf, HTTP_INTERNAL_SERVER_ERROR, errno,
APLOGNO(01255) "unable to create socket to cgi daemon");
}
if (connect(sd, (struct sockaddr *)server_addr, server_addr_len) < 0) {
- if (errno == ECONNREFUSED && connect_tries < DEFAULT_CONNECT_ATTEMPTS) {
+ /* Save errno for later */
+ connect_errno = errno;
+ /* ECONNREFUSED means the listen queue is full; ENOENT means that
+ * the cgid server either hasn't started up yet, or we're pointing
+ * at the wrong socket file */
+ if ((errno == ECONNREFUSED || errno == ENOENT) &&
+ connect_tries < DEFAULT_CONNECT_ATTEMPTS) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, errno, r, APLOGNO(01256)
"connect #%d to cgi daemon failed, sleeping before retry",
connect_tries);
close_unix_socket, apr_pool_cleanup_null);
break; /* we got connected! */
}
+
+ /* If we didn't find the socket but the server was not recently restarted,
+ * chances are there's something wrong with the cgid daemon
+ */
+ if (connect_errno == ENOENT &&
+ apr_time_sec(apr_time_now() - ap_scoreboard_image->global->restart_time) >
+ DEFAULT_CONNECT_STARTUP_DELAY) {
+ return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, connect_errno,
+ apr_pstrcat(r->pool, APLOGNO(02831) "ScriptSock ", sockname, " does not exist", NULL));
+ }
+
/* gotta try again, but make sure the cgid daemon is still around */
- if (kill(daemon_pid, 0) != 0) {
- return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, APLOGNO(01258)
+ if (connect_errno != ENOENT && kill(daemon_pid, 0) != 0) {
+ return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, connect_errno, APLOGNO(01258)
"cgid daemon is gone; is Apache terminating?");
}
}