View | Details | Raw Unified | Return to bug 57685
Collapse All | Expand All

(-)a/modules/generators/mod_cgid.c (-2 / +15 lines)
Lines 1214-1220 static int connect_to_daemon(int *sdptr, request_rec *r, Link Here
1214
                                   APLOGNO(01255) "unable to create socket to cgi daemon");
1214
                                   APLOGNO(01255) "unable to create socket to cgi daemon");
1215
        }
1215
        }
1216
        if (connect(sd, (struct sockaddr *)server_addr, server_addr_len) < 0) {
1216
        if (connect(sd, (struct sockaddr *)server_addr, server_addr_len) < 0) {
1217
            if (errno == ECONNREFUSED && connect_tries < DEFAULT_CONNECT_ATTEMPTS) {
1217
            /* ECONNREFUSED means the listen queue is full; ENOENT means that
1218
             * the cgid server either hasn't started up yet, or we're pointing
1219
             * at the wrong socket file */
1220
            if ((errno == ECONNREFUSED || errno == ENOENT)
1221
                && connect_tries < DEFAULT_CONNECT_ATTEMPTS) {
1218
                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, errno, r, APLOGNO(01256)
1222
                ap_log_rerror(APLOG_MARK, APLOG_DEBUG, errno, r, APLOGNO(01256)
1219
                              "connect #%d to cgi daemon failed, sleeping before retry",
1223
                              "connect #%d to cgi daemon failed, sleeping before retry",
1220
                              connect_tries);
1224
                              connect_tries);
Lines 1236-1245 static int connect_to_daemon(int *sdptr, request_rec *r, Link Here
1236
            break; /* we got connected! */
1240
            break; /* we got connected! */
1237
        }
1241
        }
1238
        /* gotta try again, but make sure the cgid daemon is still around */
1242
        /* gotta try again, but make sure the cgid daemon is still around */
1239
        if (kill(daemon_pid, 0) != 0) {
1243
        if (errno != ENOENT && kill(daemon_pid, 0) != 0) {
1240
            return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, APLOGNO(01258)
1244
            return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, APLOGNO(01258)
1241
                                   "cgid daemon is gone; is Apache terminating?");
1245
                                   "cgid daemon is gone; is Apache terminating?");
1242
        }
1246
        }
1247
1248
        /* If we didn't find the socket but we started the server long ago,
1249
         * chances are there's something wrong with the cgid daemon
1250
         * XXX: Hardcoded number alert */
1251
        if (errno == ENOENT &&
1252
                apr_time_sec(apr_time_now() - ap_scoreboard_image->global->restart_time) > 60) {
1253
            return log_scripterror(r, conf, HTTP_SERVICE_UNAVAILABLE, errno, APLOGNO()
1254
                                   "the unix socket file is gone or was never created");
1255
        }
1243
    }
1256
    }
1244
    *sdptr = sd;
1257
    *sdptr = sd;
1245
    return OK;
1258
    return OK;

Return to bug 57685