| 280 | |
| 281 | #if APR_HAS_OTHER_CHILD |
| 282 | static void cgid_maint(int reason, void *data, apr_wait_t status) |
| 283 | { |
| 284 | apr_proc_t *proc = data; |
| 285 | int mpm_state; |
| 286 | int stopping; |
| 287 | |
| 288 | switch (reason) { |
| 289 | case APR_OC_REASON_DEATH: |
| 290 | apr_proc_other_child_unregister(data); |
| 291 | /* If apache is not terminating or restarting, |
| 292 | * restart the cgid daemon |
| 293 | */ |
| 294 | stopping = 1; /* if MPM doesn't support query, |
| 295 | * assume we shouldn't restart daemon |
| 296 | */ |
| 297 | if (ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state) == APR_SUCCESS && |
| 298 | mpm_state != AP_MPMQ_STOPPING) { |
| 299 | stopping = 0; |
| 300 | } |
| 301 | if (!stopping) { |
| 302 | if (status == DAEMON_STARTUP_ERROR) { |
| 303 | ap_log_error(APLOG_MARK, APLOG_CRIT, 0, ap_server_conf, APLOGNO(01238) |
| 304 | "cgid daemon failed to initialize"); |
| 305 | } |
| 306 | else { |
| 307 | ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(01239) |
| 308 | "cgid daemon process died, restarting"); |
| 309 | cgid_start(root_pool, root_server, proc); |
| 310 | } |
| 311 | } |
| 312 | break; |
| 313 | case APR_OC_REASON_RESTART: |
| 314 | /* don't do anything; server is stopping or restarting */ |
| 315 | apr_proc_other_child_unregister(data); |
| 316 | break; |
| 317 | case APR_OC_REASON_LOST: |
| 318 | /* Restart the child cgid daemon process */ |
| 319 | apr_proc_other_child_unregister(data); |
| 320 | cgid_start(root_pool, root_server, proc); |
| 321 | break; |
| 322 | case APR_OC_REASON_UNREGISTER: |
| 323 | /* we get here when pcgi is cleaned up; pcgi gets cleaned |
| 324 | * up when pconf gets cleaned up |
| 325 | */ |
| 326 | kill(proc->pid, SIGHUP); /* send signal to daemon telling it to die */ |
| 327 | |
| 328 | /* Remove the cgi socket, we must do it here in order to try and |
| 329 | * guarantee the same permissions as when the socket was created. |
| 330 | */ |
| 331 | if (unlink(sockname) < 0 && errno != ENOENT) { |
| 332 | ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf, APLOGNO(01240) |
| 333 | "Couldn't unlink unix domain socket %s", |
| 334 | sockname); |
| 335 | } |
| 336 | break; |
| 337 | } |
| 338 | } |
| 339 | #endif |
nothing calls this directly
no test coverage detected