diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index d14124b..5a3e03d 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -1170,7 +1170,10 @@ static int connect_to_daemon(int *sdptr, request_rec *r, "unable to create socket to cgi daemon"); } if (connect(sd, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0) { - if (errno == ECONNREFUSED && connect_tries < DEFAULT_CONNECT_ATTEMPTS) { + /* ECONNREFUSED means the listen queue is full; ENOENT means that + * the cgid server hasn't started up yet */ + if ((errno == ECONNREFUSED || errno == ENOENT) + && connect_tries < DEFAULT_CONNECT_ATTEMPTS) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, errno, r, "connect #%d to cgi daemon failed, sleeping before retry", connect_tries); @@ -1191,8 +1194,10 @@ static int connect_to_daemon(int *sdptr, request_rec *r, close_unix_socket, apr_pool_cleanup_null); break; /* we got connected! */ } - /* gotta try again, but make sure the cgid daemon is still around */ - if (kill(daemon_pid, 0) != 0) { + /* gotta try again, but make sure the cgid daemon is still around + * If we got ENOENT, that means the cgid daemon hasn't even been + * started yet, so skip this check */ + if (errno != ENOENT && kill(daemon_pid, 0) != 0) { return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, "cgid daemon is gone; is Apache terminating?"); }