Skip to content

Commit

Permalink
main() can use ap_run_mpm() directly, so axe the old ap_mpm_run() fun…
Browse files Browse the repository at this point in the history
…ction

change the mpm hooks to return OK/DONE instead of 0/1


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@762127 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
trawick committed Apr 5, 2009
1 parent 6597f95 commit 84ddc6d
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 42 deletions.
11 changes: 5 additions & 6 deletions include/ap_mpm.h
Expand Up @@ -80,16 +80,15 @@ extern "C" {
*/

/**
* This is the function that passes control to the MPM for steady-state
* processing. It is responsible for controlling the parent and child
* processes. It will run until a restart/shutdown is indicated.
* Pass control to the MPM for steady-state processing. It is responsible
* for controlling the parent and child processes. It will run until a
* restart/shutdown is indicated.
* @param pconf the configuration pool, reset before the config file is read
* @param plog the log pool, reset after the config file is read
* @param server_conf the global server config.
* @return 1 for shutdown 0 otherwise.
* @fn int ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf)
* @return DONE for shutdown OK otherwise.
*/
AP_DECLARE(int) ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf);
AP_DECLARE_HOOK(int, mpm, (apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf))

/**
* Spawn a process with privileges that another module has requested
Expand Down
3 changes: 0 additions & 3 deletions include/mpm_common.h
Expand Up @@ -320,9 +320,6 @@ AP_DECLARE_HOOK(int,monitor,(apr_pool_t *p))
AP_DECLARE(int) ap_sys_privileges_handlers(int inc);
AP_DECLARE_HOOK(int, drop_privileges, (apr_pool_t * pchild, server_rec * s))

/* pass control to the MPM */
AP_DECLARE_HOOK(int, mpm, (apr_pool_t *pconf, apr_pool_t *plog, server_rec *s))

/* implement the ap_mpm_query() function
* The MPM should return OK+APR_ENOTIMPL for any unimplemented query codes;
* modules which intercede for specific query codes should DECLINE for others.
Expand Down
3 changes: 1 addition & 2 deletions server/main.c
Expand Up @@ -39,7 +39,6 @@
#include "apr_uri.h"
#include "util_ebcdic.h"
#include "ap_mpm.h"
#include "mpm_common.h"
#include "ap_expr.h"

#if APR_HAVE_UNISTD_H
Expand Down Expand Up @@ -779,7 +778,7 @@ int main(int argc, const char * const argv[])

ap_run_optional_fn_retrieve();

if (ap_mpm_run(pconf, plog, ap_server_conf))
if (ap_run_mpm(pconf, plog, ap_server_conf) != OK)
break;

apr_pool_lock(pconf, 0);
Expand Down
10 changes: 5 additions & 5 deletions server/mpm/event/event.c
Expand Up @@ -2210,7 +2210,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
if (!is_graceful) {
if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}
/* fix the generation number in the global score; we just got a new,
* cleared scoreboard
Expand Down Expand Up @@ -2278,7 +2278,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0,
ap_server_conf, "caught SIGTERM, shutting down");
}
return 1;
return DONE;
} else if (shutdown_pending) {
/* Time to gracefully shut down:
* Kill child processes, tell them to call child_exit, etc...
Expand Down Expand Up @@ -2339,15 +2339,15 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
ap_event_pod_killpg(pod, ap_daemons_limit, FALSE);
ap_reclaim_child_processes(1);

return 1;
return DONE;
}

/* we've been told to restart */
apr_signal(SIGHUP, SIG_IGN);

if (one_process) {
/* not worth thinking about */
return 1;
return DONE;
}

/* advance to the next generation */
Expand Down Expand Up @@ -2382,7 +2382,7 @@ static int event_run(apr_pool_t * _pconf, apr_pool_t * plog, server_rec * s)
"SIGHUP received. Attempting to restart");
}

return 0;
return OK;
}

/* This really should be a post_config hook, but the error log is already
Expand Down
16 changes: 8 additions & 8 deletions server/mpm/prefork/prefork.c
Expand Up @@ -915,7 +915,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
"Couldn't create accept lock (%s) (%d)",
ap_lock_fname, ap_accept_lock_mech);
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}

#if APR_USE_SYSVSEM_SERIALIZE
Expand All @@ -930,14 +930,14 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
"Couldn't set permissions on cross-process lock; "
"check User and Group directives");
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}
}

if (!is_graceful) {
if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}
/* fix the generation number in the global score; we just got a new,
* cleared scoreboard
Expand Down Expand Up @@ -1008,7 +1008,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
processed_status = ap_process_child_status(&pid, exitwhy, status);
if (processed_status == APEXIT_CHILDFATAL) {
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}

/* non-fatal death... note that it's gone in the scoreboard. */
Expand Down Expand Up @@ -1095,7 +1095,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf,
"caught SIGTERM, shutting down");

return 1;
return DONE;
} else if (shutdown_pending) {
/* Time to perform a graceful shut down:
* Reap the inactive children, and ask the active ones
Expand Down Expand Up @@ -1169,15 +1169,15 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
*/
ap_unixd_killpg(getpgrp(), SIGTERM);

return 1;
return DONE;
}

/* we've been told to restart */
apr_signal(SIGHUP, SIG_IGN);
apr_signal(AP_SIG_GRACEFUL, SIG_IGN);
if (one_process) {
/* not worth thinking about */
return 1;
return DONE;
}

/* advance to the next generation */
Expand Down Expand Up @@ -1223,7 +1223,7 @@ static int prefork_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
"SIGHUP received. Attempting to restart");
}

return 0;
return OK;
}

/* This really should be a post_config hook, but the error log is already
Expand Down
2 changes: 1 addition & 1 deletion server/mpm/simple/simple_api.c
Expand Up @@ -35,7 +35,7 @@ static int simple_run(apr_pool_t * pconf, apr_pool_t * plog, server_rec * s)

if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
sc->mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}

return simple_main_loop(sc);
Expand Down
4 changes: 2 additions & 2 deletions server/mpm/simple/simple_run.c
Expand Up @@ -177,7 +177,7 @@ static int simple_run_loop(simple_core_t * sc)
if (!APR_STATUS_IS_EINTR(rv) && !APR_STATUS_IS_TIMEUP(rv)) {
ap_log_error(APLOG_MARK, APLOG_CRIT, rv, NULL,
"simple_main_loop: apr_pollcb_poll failed");
return !OK;
return DONE;
}
}

Expand Down Expand Up @@ -225,7 +225,7 @@ static int simple_run_loop(simple_core_t * sc)
}
}

return 0;
return OK;
}

void simple_single_process_hack(simple_core_t * sc)
Expand Down
8 changes: 4 additions & 4 deletions server/mpm/winnt/mpm_winnt.c
Expand Up @@ -1671,7 +1671,7 @@ static int winnt_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s )
if (!restart && ((parent_pid == my_pid) || one_process)) {
/* Set up the scoreboard. */
if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
return 1;
return DONE;
}
}

Expand All @@ -1686,7 +1686,7 @@ static int winnt_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s )

ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf,
"Child %d: Child process is exiting", my_pid);
return 1;
return DONE;
}
else
{
Expand Down Expand Up @@ -1714,11 +1714,11 @@ static int winnt_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s )
CloseHandle(restart_event);
CloseHandle(shutdown_event);

return 1;
return DONE;
}
}

return 0; /* Restart */
return OK; /* Restart */
}

static void winnt_hooks(apr_pool_t *p)
Expand Down
12 changes: 6 additions & 6 deletions server/mpm/worker/worker.c
Expand Up @@ -1695,7 +1695,7 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
"Couldn't create accept lock");
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}

#if APR_USE_SYSVSEM_SERIALIZE
Expand All @@ -1710,14 +1710,14 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
"Couldn't set permissions on cross-process lock; "
"check User and Group directives");
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}
}

if (!is_graceful) {
if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
mpm_state = AP_MPMQ_STOPPING;
return 1;
return DONE;
}
/* fix the generation number in the global score; we just got a new,
* cleared scoreboard
Expand Down Expand Up @@ -1788,7 +1788,7 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_log_error(APLOG_MARK, APLOG_NOTICE, 0,
ap_server_conf, "caught SIGTERM, shutting down");
}
return 1;
return DONE;
} else if (shutdown_pending) {
/* Time to gracefully shut down:
* Kill child processes, tell them to call child_exit, etc...
Expand Down Expand Up @@ -1849,15 +1849,15 @@ static int worker_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s)
ap_worker_pod_killpg(pod, ap_daemons_limit, FALSE);
ap_reclaim_child_processes(1);

return 1;
return DONE;
}

/* we've been told to restart */
apr_signal(SIGHUP, SIG_IGN);

if (one_process) {
/* not worth thinking about */
return 1;
return DONE;
}

/* advance to the next generation */
Expand Down
5 changes: 0 additions & 5 deletions server/mpm_common.c
Expand Up @@ -398,11 +398,6 @@ const char *ap_mpm_set_thread_stacksize(cmd_parms *cmd, void *dummy,
return NULL;
}

AP_DECLARE(int) ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf)
{
return ap_run_mpm(pconf, plog, server_conf);
}

AP_DECLARE(apr_status_t) ap_mpm_query(int query_code, int *result)
{
apr_status_t rv;
Expand Down

0 comments on commit 84ddc6d

Please sign in to comment.