| 470 | } |
| 471 | |
| 472 | int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */, |
| 473 | apr_pool_t *ptemp, server_rec *s_main) |
| 474 | { |
| 475 | apr_pool_t *stderr_p; |
| 476 | server_rec *virt, *q; |
| 477 | int replace_stderr; |
| 478 | |
| 479 | |
| 480 | /* Register to throw away the read_handles list when we |
| 481 | * cleanup plog. Upon fork() for the apache children, |
| 482 | * this read_handles list is closed so only the parent |
| 483 | * can relaunch a lost log child. These read handles |
| 484 | * are always closed on exec. |
| 485 | * We won't care what happens to our stderr log child |
| 486 | * between log phases, so we don't mind losing stderr's |
| 487 | * read_handle a little bit early. |
| 488 | */ |
| 489 | apr_pool_cleanup_register(p, &read_handles, ap_pool_cleanup_set_null, |
| 490 | apr_pool_cleanup_null); |
| 491 | |
| 492 | /* HERE we need a stdout log that outlives plog. |
| 493 | * We *presume* the parent of plog is a process |
| 494 | * or global pool which spans server restarts. |
| 495 | * Create our stderr_pool as a child of the plog's |
| 496 | * parent pool. |
| 497 | */ |
| 498 | apr_pool_create(&stderr_p, apr_pool_parent_get(p)); |
| 499 | apr_pool_tag(stderr_p, "stderr_pool"); |
| 500 | |
| 501 | if (open_error_log(s_main, 1, stderr_p) != OK) { |
| 502 | return DONE; |
| 503 | } |
| 504 | |
| 505 | replace_stderr = 1; |
| 506 | if (s_main->error_log) { |
| 507 | apr_status_t rv; |
| 508 | |
| 509 | /* Replace existing stderr with new log. */ |
| 510 | apr_file_flush(s_main->error_log); |
| 511 | rv = apr_file_dup2(stderr_log, s_main->error_log, stderr_p); |
| 512 | if (rv != APR_SUCCESS) { |
| 513 | ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s_main, APLOGNO(00092) |
| 514 | "unable to replace stderr with error_log"); |
| 515 | } |
| 516 | else { |
| 517 | /* We are done with stderr_pool, close it, killing |
| 518 | * the previous generation's stderr logger |
| 519 | */ |
| 520 | if (stderr_pool) |
| 521 | apr_pool_destroy(stderr_pool); |
| 522 | stderr_pool = stderr_p; |
| 523 | replace_stderr = 0; |
| 524 | /* |
| 525 | * Now that we have dup'ed s_main->error_log to stderr_log |
| 526 | * close it and set s_main->error_log to stderr_log. This avoids |
| 527 | * this fd being inherited by the next piped logger who would |
| 528 | * keep open the writing end of the pipe that this one uses |
| 529 | * as stdin. This in turn would prevent the piped logger from |
nothing calls this directly
no test coverage detected