4848#include "http_log.h"
4949#include "http_main.h"
5050#include "util_time.h"
51+ #include "ap_mpm.h"
5152
5253typedef struct {
5354 char * t_name ;
@@ -769,26 +770,34 @@ static void piped_log_maintenance(int reason, void *data, apr_wait_t status)
769770{
770771 piped_log * pl = data ;
771772 apr_status_t stats ;
773+ int mpm_state ;
772774
773775 switch (reason ) {
774776 case APR_OC_REASON_DEATH :
775777 case APR_OC_REASON_LOST :
776- ap_log_error (APLOG_MARK , APLOG_STARTUP , 0 , NULL ,
777- "piped log program '%s' failed unexpectedly" ,
778- pl -> program );
779- pl -> pid = NULL ;
778+ pl -> pid = NULL ; /* in case we don't get it going again, this
779+ * tells other logic not to try to kill it
780+ */
780781 apr_proc_other_child_unregister (pl );
781- if (pl -> program == NULL ) {
782- /* during a restart */
783- break ;
782+ stats = ap_mpm_query (AP_MPMQ_MPM_STATE , & mpm_state );
783+ if (stats != APR_SUCCESS ) {
784+ ap_log_error (APLOG_MARK , APLOG_STARTUP , 0 , NULL ,
785+ "can't query MPM state; not restarting "
786+ "piped log program '%s'" ,
787+ pl -> program );
784788 }
785- if ((stats = piped_log_spawn (pl )) != APR_SUCCESS ) {
786- /* what can we do? This could be the error log we're having
787- * problems opening up... */
788- char buf [120 ];
789+ else if (mpm_state != AP_MPMQ_STOPPING ) {
789790 ap_log_error (APLOG_MARK , APLOG_STARTUP , 0 , NULL ,
790- "piped_log_maintenance: unable to respawn '%s': %s" ,
791- pl -> program , apr_strerror (stats , buf , sizeof (buf )));
791+ "piped log program '%s' failed unexpectedly" ,
792+ pl -> program );
793+ if ((stats = piped_log_spawn (pl )) != APR_SUCCESS ) {
794+ /* what can we do? This could be the error log we're having
795+ * problems opening up... */
796+ char buf [120 ];
797+ ap_log_error (APLOG_MARK , APLOG_STARTUP , 0 , NULL ,
798+ "piped_log_maintenance: unable to respawn '%s': %s" ,
799+ pl -> program , apr_strerror (stats , buf , sizeof (buf )));
800+ }
792801 }
793802 break ;
794803
@@ -798,9 +807,9 @@ static void piped_log_maintenance(int reason, void *data, apr_wait_t status)
798807 break ;
799808
800809 case APR_OC_REASON_RESTART :
801- pl -> program = NULL ;
802810 if (pl -> pid != NULL ) {
803811 apr_proc_kill (pl -> pid , SIGTERM );
812+ pl -> pid = NULL ;
804813 }
805814 break ;
806815
0 commit comments