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

(-)include/ap_mpm.h (-1 / +6 lines)
Lines 160-165 Link Here
160
                                      /* an MPM is using a dynamic #  */
160
                                      /* an MPM is using a dynamic #  */
161
                                      /* threads or daemons.          */
161
                                      /* threads or daemons.          */
162
162
163
/* Values for AP_MPMQ_MPM_STATE */
164
#define AP_MPMQ_STARTING              0
165
#define AP_MPMQ_RUNNING               1
166
#define AP_MPMQ_STOPPING              2
167
163
#define AP_MPMQ_MAX_DAEMON_USED       1  /* Max # of daemons used so far */
168
#define AP_MPMQ_MAX_DAEMON_USED       1  /* Max # of daemons used so far */
164
#define AP_MPMQ_IS_THREADED           2  /* MPM can do threading         */
169
#define AP_MPMQ_IS_THREADED           2  /* MPM can do threading         */
165
#define AP_MPMQ_IS_FORKED             3  /* MPM can do forking           */
170
#define AP_MPMQ_IS_FORKED             3  /* MPM can do forking           */
Lines 172-178 Link Here
172
#define AP_MPMQ_MAX_SPARE_THREADS    10  /* Max # of spare threads       */
177
#define AP_MPMQ_MAX_SPARE_THREADS    10  /* Max # of spare threads       */
173
#define AP_MPMQ_MAX_REQUESTS_DAEMON  11  /* Max # of requests per daemon */
178
#define AP_MPMQ_MAX_REQUESTS_DAEMON  11  /* Max # of requests per daemon */
174
#define AP_MPMQ_MAX_DAEMONS          12  /* Max # of daemons by config   */
179
#define AP_MPMQ_MAX_DAEMONS          12  /* Max # of daemons by config   */
175
180
#define AP_MPMQ_MPM_STATE            13  /* starting, running, stopping  */
176
181
177
/**
182
/**
178
 * Query a property of the current MPM.  
183
 * Query a property of the current MPM.  
(-)server/log.c (-14 / +27 lines)
Lines 91-96 Link Here
91
#include "http_log.h"
91
#include "http_log.h"
92
#include "http_main.h"
92
#include "http_main.h"
93
#include "util_time.h"
93
#include "util_time.h"
94
#include "ap_mpm.h"
94
95
95
typedef struct {
96
typedef struct {
96
    char    *t_name;
97
    char    *t_name;
Lines 791-816 Link Here
791
{
792
{
792
    piped_log *pl = data;
793
    piped_log *pl = data;
793
    apr_status_t stats;
794
    apr_status_t stats;
795
    int mpm_state;
794
796
795
    switch (reason) {
797
    switch (reason) {
796
    case APR_OC_REASON_DEATH:
798
    case APR_OC_REASON_DEATH:
797
    case APR_OC_REASON_LOST:
799
    case APR_OC_REASON_LOST:
798
        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
799
                     "piped log program '%s' failed unexpectedly",
800
                     pl->program);
801
        pl->pid = NULL;
802
        apr_proc_other_child_unregister(pl);
800
        apr_proc_other_child_unregister(pl);
803
        if (pl->program == NULL) {
801
        stats = ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state);
804
            /* during a restart */
802
        if (stats != APR_SUCCESS) {
805
            break;
803
            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
806
        }
804
                         "can't query MPM state; not restarting "
807
        if ((stats = piped_log_spawn(pl)) != APR_SUCCESS) {
805
                         "piped log program '%s'",
808
            /* what can we do?  This could be the error log we're having
806
                         pl->program);
809
             * problems opening up... */
807
        }
810
            char buf[120];
808
        else if (mpm_state != AP_MPMQ_STOPPING) {
811
            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
809
            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
812
                         "piped_log_maintenance: unable to respawn '%s': %s",
810
                         "piped log program '%s' failed unexpectedly",
813
                         pl->program, apr_strerror(stats, buf, sizeof(buf)));
811
                         pl->program);
812
            pl->pid = NULL;
813
            if (pl->program == NULL) { /* XXX how does this work? doesn't a query
814
                                        * of the MPM state resolve this too?
815
                                        */
816
                /* during a restart */
817
                break;
818
            }
819
            if ((stats = piped_log_spawn(pl)) != APR_SUCCESS) {
820
                /* what can we do?  This could be the error log we're having
821
                 * problems opening up... */
822
                char buf[120];
823
                ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
824
                             "piped_log_maintenance: unable to respawn '%s': %s",
825
                             pl->program, apr_strerror(stats, buf, sizeof(buf)));
826
            }
814
        }
827
        }
815
        break;
828
        break;
816
829
(-)server/mpm/prefork/prefork.c (-2 / +26 lines)
Lines 141-147 Link Here
141
static int server_limit = DEFAULT_SERVER_LIMIT;
141
static int server_limit = DEFAULT_SERVER_LIMIT;
142
static int first_server_limit;
142
static int first_server_limit;
143
static int changed_limit_at_restart;
143
static int changed_limit_at_restart;
144
144
static int mpm_state = AP_MPMQ_STARTING;
145
static ap_pod_t *pod;
145
static ap_pod_t *pod;
146
146
147
/*
147
/*
Lines 229-234 Link Here
229
static void clean_child_exit(int code) __attribute__ ((noreturn));
229
static void clean_child_exit(int code) __attribute__ ((noreturn));
230
static void clean_child_exit(int code)
230
static void clean_child_exit(int code)
231
{
231
{
232
    mpm_state = AP_MPMQ_STOPPING;
233
232
    if (pchild) {
234
    if (pchild) {
233
	apr_pool_destroy(pchild);
235
	apr_pool_destroy(pchild);
234
    }
236
    }
Lines 326-331 Link Here
326
        case AP_MPMQ_MAX_DAEMONS:
328
        case AP_MPMQ_MAX_DAEMONS:
327
            *result = server_limit;
329
            *result = server_limit;
328
            return APR_SUCCESS;
330
            return APR_SUCCESS;
331
        case AP_MPMQ_MPM_STATE:
332
            *result = mpm_state;
333
            return APR_SUCCESS;
329
    }
334
    }
330
    return APR_ENOTIMPL;
335
    return APR_ENOTIMPL;
331
}
336
}
Lines 550-555 Link Here
550
    apr_status_t rv;
555
    apr_status_t rv;
551
    apr_bucket_alloc_t *bucket_alloc;
556
    apr_bucket_alloc_t *bucket_alloc;
552
557
558
    mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
559
                                  * child initializes
560
                                  */
561
    
553
    my_child_num = child_num_arg;
562
    my_child_num = child_num_arg;
554
    ap_my_pid = getpid();
563
    ap_my_pid = getpid();
555
    csd = NULL;
564
    csd = NULL;
Lines 601-606 Link Here
601
        pollset[i].reqevents = APR_POLLIN;
610
        pollset[i].reqevents = APR_POLLIN;
602
    }
611
    }
603
612
613
    mpm_state = AP_MPMQ_RUNNING;
614
    
604
    bucket_alloc = apr_bucket_alloc_create(pchild);
615
    bucket_alloc = apr_bucket_alloc_create(pchild);
605
616
606
    while (!die_now) {
617
    while (!die_now) {
Lines 969-974 Link Here
969
    if (rv != APR_SUCCESS) {
980
    if (rv != APR_SUCCESS) {
970
        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
981
        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
971
                     "Couldn't create accept lock");
982
                     "Couldn't create accept lock");
983
        mpm_state = AP_MPMQ_STOPPING;
972
        return 1;
984
        return 1;
973
    }
985
    }
974
986
Lines 983-994 Link Here
983
            ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
995
            ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
984
                         "Couldn't set permissions on cross-process lock; "
996
                         "Couldn't set permissions on cross-process lock; "
985
                         "check User and Group directives");
997
                         "check User and Group directives");
998
            mpm_state = AP_MPMQ_STOPPING;
986
            return 1;
999
            return 1;
987
        }
1000
        }
988
    }
1001
    }
989
1002
990
    if (!is_graceful) {
1003
    if (!is_graceful) {
991
        if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
1004
        if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
1005
            mpm_state = AP_MPMQ_STOPPING;
992
            return 1;
1006
            return 1;
993
        }
1007
        }
994
        /* fix the generation number in the global score; we just got a new,
1008
        /* fix the generation number in the global score; we just got a new,
Lines 1041-1046 Link Here
1041
#endif
1055
#endif
1042
    restart_pending = shutdown_pending = 0;
1056
    restart_pending = shutdown_pending = 0;
1043
1057
1058
    mpm_state = AP_MPMQ_RUNNING;
1059
    
1044
    while (!restart_pending && !shutdown_pending) {
1060
    while (!restart_pending && !shutdown_pending) {
1045
	int child_slot;
1061
	int child_slot;
1046
        apr_exit_why_e exitwhy;
1062
        apr_exit_why_e exitwhy;
Lines 1057-1062 Link Here
1057
	if (pid.pid != -1) {
1073
	if (pid.pid != -1) {
1058
            processed_status = ap_process_child_status(&pid, exitwhy, status);
1074
            processed_status = ap_process_child_status(&pid, exitwhy, status);
1059
            if (processed_status == APEXIT_CHILDFATAL) {
1075
            if (processed_status == APEXIT_CHILDFATAL) {
1076
                mpm_state = AP_MPMQ_STOPPING;
1060
                return 1;
1077
                return 1;
1061
            }
1078
            }
1062
1079
Lines 1123-1128 Link Here
1123
#endif /*TPF */
1140
#endif /*TPF */
1124
    }
1141
    }
1125
1142
1143
    mpm_state = AP_MPMQ_STOPPING;
1144
1126
    if (shutdown_pending) {
1145
    if (shutdown_pending) {
1127
	/* Time to gracefully shut down:
1146
	/* Time to gracefully shut down:
1128
	 * Kill child processes, tell them to call child_exit, etc...
1147
	 * Kill child processes, tell them to call child_exit, etc...
Lines 1223-1228 Link Here
1223
    int no_detach, debug, foreground;
1242
    int no_detach, debug, foreground;
1224
    apr_status_t rv;
1243
    apr_status_t rv;
1225
1244
1245
    mpm_state = AP_MPMQ_STARTING;
1246
1226
    debug = ap_exists_config_define("DEBUG");
1247
    debug = ap_exists_config_define("DEBUG");
1227
1248
1228
    if (debug) {
1249
    if (debug) {
Lines 1285-1291 Link Here
1285
#endif
1306
#endif
1286
1307
1287
    ap_hook_open_logs(prefork_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
1308
    ap_hook_open_logs(prefork_open_logs, NULL, aszSucc, APR_HOOK_MIDDLE);
1288
    ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
1309
    /* we need to set the MPM state before other pre-config hooks use MPM query
1310
     * to retrieve it, so register as REALLY_FIRST
1311
     */
1312
    ap_hook_pre_config(prefork_pre_config, NULL, NULL, APR_HOOK_REALLY_FIRST);
1289
}
1313
}
1290
1314
1291
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg) 
1315
static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, const char *arg) 

Return to bug 24805