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