diff options
author | Doug MacEachern <dougm@apache.org> | 2000-08-02 07:27:38 +0200 |
---|---|---|
committer | Doug MacEachern <dougm@apache.org> | 2000-08-02 07:27:38 +0200 |
commit | 059d8dd2122f0a3948c2c09549159f0931a6f236 (patch) | |
tree | 8a2937938ed4eec31f918c6c8401ce07012cd37a /server/mpm | |
parent | Use the AP_INIT_TAKE23() macro to clean up a maintainer-mode warning, (diff) | |
download | apache2-059d8dd2122f0a3948c2c09549159f0931a6f236.tar.xz apache2-059d8dd2122f0a3948c2c09549159f0931a6f236.zip |
prefix libapr functions and types with apr_
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@85976 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'server/mpm')
24 files changed, 962 insertions, 962 deletions
diff --git a/server/mpm/beos/beos.c b/server/mpm/beos/beos.c index 1e8fb63dd0..88db35e068 100644 --- a/server/mpm/beos/beos.c +++ b/server/mpm/beos/beos.c @@ -77,7 +77,7 @@ #include "ap_mpm.h" #include "beosd.h" #include "ap_iol.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "scoreboard.h" #include <kernel/OS.h> #include "mpm_common.h" @@ -100,22 +100,22 @@ static int ap_thread_limit=0; static time_t ap_restart_time=0; API_VAR_EXPORT int ap_extended_status = 0; static int num_listening_sockets = 0; /* set by open_listeners in ap_mpm_run */ -static ap_socket_t ** listening_sockets; -ap_lock_t *accept_mutex = NULL; +static apr_socket_t ** listening_sockets; +apr_lock_t *accept_mutex = NULL; -static ap_pool_t *pconf; /* Pool for config stuff */ -static ap_pool_t *pchild; /* Pool for httpd child stuff */ +static apr_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pchild; /* Pool for httpd child stuff */ static int server_pid; /* Keep track of the number of worker threads currently active */ static int worker_thread_count; -ap_lock_t *worker_thread_count_mutex; +apr_lock_t *worker_thread_count_mutex; /* The structure used to pass unique initialization info to each thread */ typedef struct { int slot; - ap_pool_t *tpool; + apr_pool_t *tpool; } proc_info; struct ap_ctable ap_child_table[HARD_SERVER_LIMIT]; @@ -151,7 +151,7 @@ API_EXPORT(int) ap_get_max_daemons(void) static void clean_child_exit(int code) { if (pchild) - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); exit(code); } @@ -304,7 +304,7 @@ int ap_graceful_stop_signalled(void) * Child process main loop. */ -static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num) +static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num) { BUFF *conn_io; conn_rec *current_conn; @@ -312,14 +312,14 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num) long conn_id = my_child_num; int csd; - (void)ap_get_os_sock(&csd, sock); + (void)apr_get_os_sock(&csd, sock); if (csd >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, "filedescriptor (%u) larger than FD_SETSIZE (%u) " "found, you probably need to rebuild Apache with a " "larger FD_SETSIZE", csd, FD_SETSIZE); - ap_close_socket(sock); + apr_close_socket(sock); return; } @@ -327,7 +327,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num) if (iol == NULL) { ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL, "error attaching to socket"); - ap_close_socket(sock); + apr_close_socket(sock); return; } @@ -360,16 +360,16 @@ static int32 worker_thread(void * dummy) { proc_info * ti = dummy; int child_slot = ti->slot; - ap_pool_t *tpool = ti->tpool; - ap_socket_t *csd = NULL; - ap_pool_t *ptrans; /* Pool for per-transaction stuff */ - ap_socket_t *sd = NULL; - ap_status_t rv = APR_EINIT; + apr_pool_t *tpool = ti->tpool; + apr_socket_t *csd = NULL; + apr_pool_t *ptrans; /* Pool for per-transaction stuff */ + apr_socket_t *sd = NULL; + apr_status_t rv = APR_EINIT; int srv , n; int curr_pollfd, last_pollfd = 0; sigset_t sig_mask; int requests_this_child = ap_max_requests_per_child; - ap_pollfd_t *pollset; + apr_pollfd_t *pollset; /* each worker thread is in control of it's own destiny...*/ int this_worker_should_exit = 0; port_id chk = find_port("the_samaritans"); @@ -379,26 +379,26 @@ static int32 worker_thread(void * dummy) sigfillset(&sig_mask); sigprocmask(SIG_BLOCK, &sig_mask, NULL); - ap_create_pool(&ptrans, tpool); + apr_create_pool(&ptrans, tpool); - ap_lock(worker_thread_count_mutex); + apr_lock(worker_thread_count_mutex); worker_thread_count++; - ap_unlock(worker_thread_count_mutex); + apr_unlock(worker_thread_count_mutex); /* now setup our own pollset...this will use APR woohoo! */ - ap_setup_poll(&pollset, num_listening_sockets, tpool); + apr_setup_poll(&pollset, num_listening_sockets, tpool); for(n=0 ; n < num_listening_sockets ; ++n) - ap_add_poll_socket(pollset, listening_sockets[n], APR_POLLIN); + apr_add_poll_socket(pollset, listening_sockets[n], APR_POLLIN); while (!this_worker_should_exit) { this_worker_should_exit |= (ap_max_requests_per_child != 0) && (requests_this_child <= 0); if (this_worker_should_exit) break; - ap_lock(accept_mutex); + apr_lock(accept_mutex); while (!this_worker_should_exit) { - ap_int16_t event; - ap_status_t ret = ap_poll(pollset, &srv, -1); + apr_int16_t event; + apr_status_t ret = apr_poll(pollset, &srv, -1); if (call_samaritans(chk)) this_worker_should_exit = 1; @@ -411,7 +411,7 @@ static int32 worker_thread(void * dummy) /* poll() will only return errors in catastrophic * circumstances. Let's try exiting gracefully, for now. */ ap_log_error(APLOG_MARK, APLOG_ERR, ret, (const server_rec *) - ap_server_conf, "ap_poll: (listen)"); + ap_server_conf, "apr_poll: (listen)"); this_worker_should_exit = 1; } @@ -430,7 +430,7 @@ static int32 worker_thread(void * dummy) curr_pollfd = 1; } /* Get the revent... */ - ap_get_revents(&event, listening_sockets[curr_pollfd], pollset); + apr_get_revents(&event, listening_sockets[curr_pollfd], pollset); if (event & APR_POLLIN) { last_pollfd = curr_pollfd; @@ -442,31 +442,31 @@ static int32 worker_thread(void * dummy) } got_fd: if (!this_worker_should_exit) { - ap_unlock(accept_mutex); - if ((rv = ap_accept(&csd, sd, ptrans)) != APR_SUCCESS) { + apr_unlock(accept_mutex); + if ((rv = apr_accept(&csd, sd, ptrans)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, - "ap_accept"); + "apr_accept"); } else { process_socket(ptrans, csd, child_slot); requests_this_child--; } } else { - ap_unlock(accept_mutex); + apr_unlock(accept_mutex); break; } - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); } - ap_destroy_pool(tpool); - ap_lock(worker_thread_count_mutex); + apr_destroy_pool(tpool); + apr_lock(worker_thread_count_mutex); worker_thread_count--; if (worker_thread_count == 0) { /* All the threads have exited, now finish the shutdown process * by signalling the sigwait thread */ kill(server_pid, SIGTERM); } - ap_unlock(worker_thread_count_mutex); + apr_unlock(worker_thread_count_mutex); return (0); } @@ -483,7 +483,7 @@ static int make_worker(server_rec *s, int slot, time_t now) } my_info->slot = slot; - ap_create_pool(&my_info->tpool, pchild); + apr_create_pool(&my_info->tpool, pchild); if (slot + 1 > ap_max_child_assigned) ap_max_child_assigned = slot + 1; @@ -592,7 +592,7 @@ static void server_main_loop(int remaining_threads_to_start) { int child_slot; ap_wait_t status; - ap_proc_t pid; + apr_proc_t pid; int i; while (!restart_pending && !shutdown_pending) { @@ -626,7 +626,7 @@ static void server_main_loop(int remaining_threads_to_start) } #if APR_HAS_OTHER_CHILD } - else if (ap_reap_other_child(&pid, status) == 0) { + else if (apr_reap_other_child(&pid, status) == 0) { /* handled */ #endif } @@ -664,10 +664,10 @@ static void server_main_loop(int remaining_threads_to_start) } } -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_threads_to_start, i; - ap_status_t rv; + apr_status_t rv; ap_listen_rec *lr; pconf = _pconf; ap_server_conf = s; @@ -694,7 +694,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) * used to lock around select so we only have one thread * in select at a time */ - if ((rv = ap_create_lock(&accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, + if ((rv = apr_create_lock(&accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, NULL, pconf)) != APR_SUCCESS) { /* tsch tsch, can't have more than one thread in the accept loop at a time so we need to fall on our sword... */ @@ -705,7 +705,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) /* worker_thread_count_mutex * locks the worker_thread_count so we have ana ccurate count... */ - if ((rv = ap_create_lock(&worker_thread_count_mutex, APR_MUTEX, APR_CROSS_PROCESS, + if ((rv = apr_create_lock(&worker_thread_count_mutex, APR_MUTEX, APR_CROSS_PROCESS, NULL, pconf)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, "Couldn't create worker thread count lock"); @@ -741,13 +741,13 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) /* setup the child pool to use for the workers. Each worker creates * a seperate pool of it's own to use. */ - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); ap_child_init_hook(pchild, ap_server_conf); /* Now that we have the child pool (pchild) we can allocate * the listenfds and creat the pollset... */ - listening_sockets = ap_palloc(pchild, + listening_sockets = apr_palloc(pchild, sizeof(*listening_sockets) * (num_listening_sockets)); for (lr = ap_listeners, i = 0; i < num_listening_sockets; lr = lr->next, ++i) listening_sockets[i]=lr->sd; @@ -841,14 +841,14 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) /* just before we go, tidy up the locks we've created to prevent a * potential leak of semaphores... */ - ap_destroy_lock(worker_thread_count_mutex); - ap_destroy_lock(accept_mutex); + apr_destroy_lock(worker_thread_count_mutex); + apr_destroy_lock(accept_mutex); delete_port(port_of_death); return 0; } -static void beos_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp) +static void beos_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; int no_detach = 0; @@ -860,7 +860,7 @@ static void beos_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp) if (restart_num++ == 1) { is_graceful = 0; if (!one_process && !no_detach) - ap_detach(); + apr_detach(); server_pid = getpid(); } @@ -875,7 +875,7 @@ static void beos_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp) ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; ap_beos_set_maintain_connection_status(1); - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } static void beos_hooks(void) @@ -1035,7 +1035,7 @@ static const char *set_maintain_connection_status(cmd_parms *cmd, static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1043,12 +1043,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1085,7 +1085,7 @@ module MODULE_VAR_EXPORT mpm_beos_module = { NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ - beos_cmds, /* command ap_table_t */ + beos_cmds, /* command apr_table_t */ NULL, /* handlers */ beos_hooks /* register_hooks */ }; diff --git a/server/mpm/beos/scoreboard.c b/server/mpm/beos/scoreboard.c index 78e6c82784..e4af0ed611 100644 --- a/server/mpm/beos/scoreboard.c +++ b/server/mpm/beos/scoreboard.c @@ -68,10 +68,10 @@ #include "beos.h" scoreboard *ap_scoreboard_image = NULL; -extern ap_pool_t * pconf; +extern apr_pool_t * pconf; static int maintain_connection_status = 1; -void reinit_scoreboard(ap_pool_t *p) +void reinit_scoreboard(apr_pool_t *p) { if (!ap_scoreboard_image) ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE); @@ -108,7 +108,7 @@ void ap_update_connection_status(long conn_id, const char *key, break; } if (0 == strcmp(ss->key, key)) { - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } i++; @@ -116,8 +116,8 @@ void ap_update_connection_status(long conn_id, const char *key, if (i >= STATUSES_PER_CONNECTION) { return; } - ap_cpystrn(ss->key, key, KEY_LENGTH); - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->key, key, KEY_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } @@ -161,62 +161,62 @@ const char *ap_get_connection_status(long conn_id, const char *key) return NULL; } -ap_array_header_t *ap_get_connections(ap_pool_t *p) +apr_array_header_t *ap_get_connections(apr_pool_t *p) { int i; - ap_array_header_t *connection_list; + apr_array_header_t *connection_list; long *array_slot; - connection_list = ap_make_array(p, 0, sizeof(long)); + connection_list = apr_make_array(p, 0, sizeof(long)); for (i = 0; i < ap_max_child_assigned; i++) { if (ap_scoreboard_image->table[i][0].key[0] != '\0') { - array_slot = ap_push_array(connection_list); + array_slot = apr_push_array(connection_list); *array_slot = i; } } return connection_list; } -ap_array_header_t *ap_get_connection_keys(ap_pool_t *p, long conn_id) +apr_array_header_t *ap_get_connection_keys(apr_pool_t *p, long conn_id) { int i = 0; status_table_entry *ss; - ap_array_header_t *key_list; + apr_array_header_t *key_list; char **array_slot; - key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char)); + key_list = apr_make_array(p, 0, KEY_LENGTH * sizeof(char)); while (i < STATUSES_PER_CONNECTION) { ss = &(ap_scoreboard_image->table[conn_id][i]); if (ss->key[0] == '\0') { break; } - array_slot = ap_push_array(key_list); - *array_slot = ap_pstrdup(p, ss->key); + array_slot = apr_push_array(key_list); + *array_slot = apr_pstrdup(p, ss->key); i++; } return key_list; } -ap_array_header_t *ap_get_status_table(ap_pool_t *p) +apr_array_header_t *ap_get_status_table(apr_pool_t *p) { int i, j; - ap_array_header_t *server_status; + apr_array_header_t *server_status; ap_status_table_row_t *array_slot; status_table_entry *ss; - server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t)); + server_status = apr_make_array(p, 0, sizeof(ap_status_table_row_t)); for (i = 0; i < ap_max_child_assigned; i++) { if (ap_scoreboard_image->table[i][0].key[0] == '\0') continue; - array_slot = ap_push_array(server_status); - array_slot->data = ap_make_table(p, 0); + array_slot = apr_push_array(server_status); + array_slot->data = apr_make_table(p, 0); array_slot->conn_id = i; for (j = 0; j < STATUSES_PER_CONNECTION; j++) { ss = &(ap_scoreboard_image->table[i][j]); if (ss->key[0] != '\0') { - ap_table_add(array_slot->data, ss->key, ss->value); + apr_table_add(array_slot->data, ss->key, ss->value); } else { break; diff --git a/server/mpm/beos/scoreboard.h b/server/mpm/beos/scoreboard.h index 8ca6d67860..53d869d252 100644 --- a/server/mpm/beos/scoreboard.h +++ b/server/mpm/beos/scoreboard.h @@ -67,11 +67,11 @@ extern "C" { #include "mpm_default.h" /* For HARD_.*_LIMIT */ API_EXPORT(int) ap_exists_scoreboard_image(void); -void reinit_scoareboard(ap_pool_t *p); +void reinit_scoareboard(apr_pool_t *p); void cleanup_scoreboard(void); void ap_beos_set_maintain_connection_status(int flag); void ap_beos_force_reset_connection_status(long conn_id); -void reinit_scoreboard(ap_pool_t *p); +void reinit_scoreboard(apr_pool_t *p); void update_scoreboard_global(void); API_EXPORT(int) find_child_by_pid(int pid); int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r); diff --git a/server/mpm/dexter/dexter.c b/server/mpm/dexter/dexter.c index 6e4e36875c..2f45da989a 100644 --- a/server/mpm/dexter/dexter.c +++ b/server/mpm/dexter/dexter.c @@ -72,7 +72,7 @@ #include "unixd.h" #include "mpm_common.h" #include "ap_iol.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "mpm_default.h" #include "mpm.h" #include "scoreboard.h" @@ -105,7 +105,7 @@ static int num_daemons=0; static int workers_may_exit = 0; static int requests_this_child; static int num_listenfds = 0; -static ap_socket_t **listenfds; +static apr_socket_t **listenfds; struct ap_ctable ap_child_table[HARD_SERVER_LIMIT]; @@ -121,8 +121,8 @@ int ap_max_daemons_limit = -1; char ap_coredump_dir[MAX_STRING_LEN]; -static ap_file_t *pipe_of_death_in = NULL; -static ap_file_t *pipe_of_death_out = NULL; +static apr_file_t *pipe_of_death_in = NULL; +static apr_file_t *pipe_of_death_out = NULL; static pthread_mutex_t pipe_of_death_mutex; /* *Non*-shared http_main globals... */ @@ -146,9 +146,9 @@ static int one_process = 0; int raise_sigstop_flags; #endif -static ap_pool_t *pconf; /* Pool for config stuff */ -static ap_pool_t *pchild; /* Pool for httpd child stuff */ -static ap_pool_t *thread_pool_parent; /* Parent of per-thread pools */ +static apr_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pchild; /* Pool for httpd child stuff */ +static apr_pool_t *thread_pool_parent; /* Parent of per-thread pools */ static pthread_mutex_t thread_pool_parent_mutex; static int child_num; @@ -169,7 +169,7 @@ static pthread_mutex_t idle_thread_count_mutex; #define SAFE_ACCEPT(stmt) APR_SUCCESS #else #define SAFE_ACCEPT(stmt) (stmt) -static ap_lock_t *process_accept_mutex; +static apr_lock_t *process_accept_mutex; #endif /* NO_SERIALIZED_ACCEPT */ static const char *lock_fname; static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -183,7 +183,7 @@ API_EXPORT(int) ap_get_max_daemons(void) static void clean_child_exit(int code) { if (pchild) { - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); } exit(code); } @@ -192,7 +192,7 @@ static void clean_child_exit(int code) static void sig_coredump(int sig) { chdir(ap_coredump_dir); - ap_signal(sig, SIG_DFL); + apr_signal(sig, SIG_DFL); kill(getpid(), sig); /* At this point we've got sig blocked, because we're still inside * the signal handler. When we leave the signal handler it will @@ -259,7 +259,7 @@ static void ap_start_restart(int graceful) restart_pending = 1; is_graceful = graceful; if (is_graceful) { - ap_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); + apr_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); } } @@ -345,36 +345,36 @@ static void set_signals(void) ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)"); #else if (!one_process) { - ap_signal(SIGSEGV, sig_coredump); + apr_signal(SIGSEGV, sig_coredump); #ifdef SIGBUS - ap_signal(SIGBUS, sig_coredump); + apr_signal(SIGBUS, sig_coredump); #endif /* SIGBUS */ #ifdef SIGABORT - ap_signal(SIGABORT, sig_coredump); + apr_signal(SIGABORT, sig_coredump); #endif /* SIGABORT */ #ifdef SIGABRT - ap_signal(SIGABRT, sig_coredump); + apr_signal(SIGABRT, sig_coredump); #endif /* SIGABRT */ #ifdef SIGILL - ap_signal(SIGILL, sig_coredump); + apr_signal(SIGILL, sig_coredump); #endif /* SIGILL */ #ifdef SIGXCPU - ap_signal(SIGXCPU, SIG_DFL); + apr_signal(SIGXCPU, SIG_DFL); #endif /* SIGXCPU */ #ifdef SIGXFSZ - ap_signal(SIGXFSZ, SIG_DFL); + apr_signal(SIGXFSZ, SIG_DFL); #endif /* SIGXFSZ */ } - ap_signal(SIGTERM, sig_term); + apr_signal(SIGTERM, sig_term); #ifdef SIGHUP - ap_signal(SIGHUP, restart); + apr_signal(SIGHUP, restart); #endif /* SIGHUP */ #ifdef SIGWINCH - ap_signal(SIGWINCH, restart); + apr_signal(SIGWINCH, restart); #endif /* SIGWINCH */ #ifdef SIGPIPE - ap_signal(SIGPIPE, SIG_IGN); + apr_signal(SIGPIPE, SIG_IGN); #endif /* SIGPIPE */ #endif @@ -394,16 +394,16 @@ int ap_graceful_stop_signalled(void) * Child process main loop. */ -static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id) +static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id) { BUFF *conn_io; conn_rec *current_conn; ap_iol *iol; int csd; - ap_status_t rv; + apr_status_t rv; - if ((rv = ap_get_os_sock(&csd, sock)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_get_os_sock"); + if ((rv = apr_get_os_sock(&csd, sock)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_get_os_sock"); } if (csd >= FD_SETSIZE) { @@ -412,7 +412,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id) "to rebuild Apache with a larger FD_SETSIZE " "(currently %d)", csd, FD_SETSIZE); - ap_close_socket(sock); + apr_close_socket(sock); return; } @@ -480,10 +480,10 @@ static void check_pipe_of_death(void) if (!workers_may_exit) { int ret; char pipe_read_char; - ap_ssize_t n = 1; + apr_ssize_t n = 1; - ret = ap_recv(listenfds[0], &pipe_read_char, &n); - if (ap_canonical_error(ret) == APR_EAGAIN) { + ret = apr_recv(listenfds[0], &pipe_read_char, &n); + if (apr_canonical_error(ret) == APR_EAGAIN) { /* It lost the lottery. It must continue to suffer * through a life of servitude. */ } @@ -500,27 +500,27 @@ static void check_pipe_of_death(void) static void *worker_thread(void *arg) { - ap_socket_t *csd = NULL; - ap_pool_t *tpool; /* Pool for this thread */ - ap_pool_t *ptrans; /* Pool for per-transaction stuff */ - ap_socket_t *sd = NULL; + apr_socket_t *csd = NULL; + apr_pool_t *tpool; /* Pool for this thread */ + apr_pool_t *ptrans; /* Pool for per-transaction stuff */ + apr_socket_t *sd = NULL; int srv; int curr_pollfd, last_pollfd = 0; int thread_just_started = 1; int thread_num = *((int *) arg); long conn_id = child_num * HARD_THREAD_LIMIT + thread_num; - ap_pollfd_t *pollset; + apr_pollfd_t *pollset; int n; - ap_status_t rv; + apr_status_t rv; pthread_mutex_lock(&thread_pool_parent_mutex); - ap_create_pool(&tpool, thread_pool_parent); + apr_create_pool(&tpool, thread_pool_parent); pthread_mutex_unlock(&thread_pool_parent_mutex); - ap_create_pool(&ptrans, tpool); + apr_create_pool(&ptrans, tpool); - ap_setup_poll(&pollset, num_listenfds+1, tpool); + apr_setup_poll(&pollset, num_listenfds+1, tpool); for(n=0 ; n <= num_listenfds ; ++n) - ap_add_poll_socket(pollset, listenfds[n], APR_POLLIN); + apr_add_poll_socket(pollset, listenfds[n], APR_POLLIN); while (!workers_may_exit) { workers_may_exit |= (max_requests_per_child != 0) && (requests_this_child <= 0); @@ -544,32 +544,32 @@ static void *worker_thread(void *arg) pthread_mutex_unlock(&thread_accept_mutex); break; } - if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_lock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_lock failed. Attempting to shutdown " + "apr_lock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } while (!workers_may_exit) { - ap_int16_t event; - srv = ap_poll(pollset, &n, -1); + apr_int16_t event; + srv = apr_poll(pollset, &n, -1); if (srv != APR_SUCCESS) { - if (ap_canonical_error(srv) == APR_EINTR) { + if (apr_canonical_error(srv) == APR_EINTR) { continue; } - /* ap_poll() will only return errors in catastrophic + /* apr_poll() will only return errors in catastrophic * circumstances. Let's try exiting gracefully, for now. */ ap_log_error(APLOG_MARK, APLOG_ERR, srv, (const server_rec *) - ap_server_conf, "ap_poll: (listen)"); + ap_server_conf, "apr_poll: (listen)"); workers_may_exit = 1; } if (workers_may_exit) break; - ap_get_revents(&event, listenfds[0], pollset); + apr_get_revents(&event, listenfds[0], pollset); if (event & APR_POLLIN) { /* A process got a signal on the shutdown pipe. Check if we're * the lucky process to die. */ @@ -590,7 +590,7 @@ static void *worker_thread(void *arg) curr_pollfd = 1; } /* XXX: Should we check for POLLERR? */ - ap_get_revents(&event, listenfds[curr_pollfd], pollset); + apr_get_revents(&event, listenfds[curr_pollfd], pollset); if (event & APR_POLLIN) { last_pollfd = curr_pollfd; sd = listenfds[curr_pollfd]; @@ -601,14 +601,14 @@ static void *worker_thread(void *arg) } got_fd: if (!workers_may_exit) { - if ((rv = ap_accept(&csd, sd, ptrans)) != APR_SUCCESS) { + if ((rv = apr_accept(&csd, sd, ptrans)) != APR_SUCCESS) { csd = NULL; - ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "ap_accept"); + ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "apr_accept"); } - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } @@ -628,10 +628,10 @@ static void *worker_thread(void *arg) requests_this_child--; } } else { - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } @@ -641,11 +641,11 @@ static void *worker_thread(void *arg) pthread_mutex_unlock(&idle_thread_count_mutex); break; } - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); } pthread_mutex_lock(&thread_pool_parent_mutex); - ap_destroy_pool(tpool); + apr_destroy_pool(tpool); pthread_mutex_unlock(&thread_pool_parent_mutex); pthread_mutex_lock(&worker_thread_count_mutex); worker_thread_count--; @@ -666,15 +666,15 @@ static void child_main(int child_num_arg) int signal_received; int i; ap_listen_rec *lr; - ap_status_t rv; + apr_status_t rv; my_pid = getpid(); child_num = child_num_arg; - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); /*stuff to do before we switch id's, so we have permissions.*/ - rv = SAFE_ACCEPT(ap_child_init_lock(&process_accept_mutex, lock_fname, + rv = SAFE_ACCEPT(apr_child_init_lock(&process_accept_mutex, lock_fname, pchild)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, @@ -710,9 +710,9 @@ static void child_main(int child_num_arg) requests_this_child = max_requests_per_child; /* Set up the pollfd array */ - listenfds = ap_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 1)); + listenfds = apr_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 1)); #if APR_FILES_AS_SOCKETS - ap_socket_from_file(&listenfds[0], pipe_of_death_in); + apr_socket_from_file(&listenfds[0], pipe_of_death_in); #endif for (lr = ap_listeners, i = 1; i <= num_listenfds; lr = lr->next, ++i) listenfds[i]=lr->sd; @@ -727,7 +727,7 @@ static void child_main(int child_num_arg) for (i = 0; i < max_threads; i++) { worker_thread_free_ids[i] = i; } - ap_create_pool(&thread_pool_parent, pchild); + apr_create_pool(&thread_pool_parent, pchild); pthread_mutex_init(&thread_pool_parent_mutex, NULL); pthread_mutex_init(&idle_thread_count_mutex, NULL); pthread_mutex_init(&worker_thread_count_mutex, NULL); @@ -810,7 +810,7 @@ static int make_child(server_rec *s, int slot, time_t now) RAISE_SIGSTOP(MAKE_CHILD); /* XXX - For an unthreaded server, a signal handler will be necessary - ap_signal(SIGTERM, just_die); + apr_signal(SIGTERM, just_die); */ child_main(slot); @@ -904,7 +904,7 @@ static void server_main_loop(int remaining_children_to_start) { int child_slot; ap_wait_t status; - ap_proc_t pid; + apr_proc_t pid; int i; while (!restart_pending && !shutdown_pending) { @@ -939,7 +939,7 @@ static void server_main_loop(int remaining_children_to_start) } #if APR_HAS_OTHER_CHILD } - else if (ap_reap_other_child(&pid, status) == 0) { + else if (apr_reap_other_child(&pid, status) == 0) { /* handled */ #endif } @@ -978,26 +978,26 @@ static void server_main_loop(int remaining_children_to_start) } } -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_children_to_start; int i; - ap_status_t rv; - ap_ssize_t one = 1; + apr_status_t rv; + apr_ssize_t one = 1; pconf = _pconf; ap_server_conf = s; - if ((rv = ap_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf)) + if ((rv = apr_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_create_pipe (pipe_of_death)"); + "apr_create_pipe (pipe_of_death)"); exit(1); } - if ((rv = ap_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { + if ((rv = apr_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_set_pipe_timeout (pipe_of_death)"); + "apr_set_pipe_timeout (pipe_of_death)"); exit(1); } ap_server_conf = s; @@ -1010,10 +1010,10 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) ap_log_pid(pconf, ap_pid_fname); /* Initialize cross-process accept lock */ - lock_fname = ap_psprintf(_pconf, "%s.%u", + lock_fname = apr_psprintf(_pconf, "%s.%u", ap_server_root_relative(_pconf, lock_fname), my_pid); - rv = SAFE_ACCEPT(ap_create_lock(&process_accept_mutex, APR_MUTEX, + rv = SAFE_ACCEPT(apr_create_lock(&process_accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, lock_fname, _pconf)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, @@ -1089,7 +1089,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* we've been told to restart */ - ap_signal(SIGHUP, SIG_IGN); + apr_signal(SIGHUP, SIG_IGN); if (one_process) { /* not worth thinking about */ @@ -1113,8 +1113,8 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* give the children the signal to die */ for (i = 0; i < num_daemons;) { - if ((rv = ap_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { - if (ap_canonical_error(rv) == APR_EINTR) continue; + if ((rv = apr_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { + if (apr_canonical_error(rv) == APR_EINTR) continue; ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, "write pipe_of_death"); } @@ -1137,7 +1137,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) return 0; } -static void dexter_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) +static void dexter_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; int no_detach = 0; @@ -1150,7 +1150,7 @@ static void dexter_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) is_graceful = 0; if (!one_process && !no_detach) { - ap_detach(); + apr_detach(); } my_pid = getpid(); @@ -1169,7 +1169,7 @@ static void dexter_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; ap_dexter_set_maintain_connection_status(1); - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } static void dexter_hooks(void) @@ -1354,7 +1354,7 @@ static const char *set_maintain_connection_status(cmd_parms *cmd, static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1362,12 +1362,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1406,7 +1406,7 @@ module MODULE_VAR_EXPORT mpm_dexter_module = { NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ - dexter_cmds, /* command ap_table_t */ + dexter_cmds, /* command apr_table_t */ NULL, /* handlers */ dexter_hooks /* register_hooks */ }; diff --git a/server/mpm/dexter/scoreboard.c b/server/mpm/dexter/scoreboard.c index 02e5dd8ed6..8630ccfb64 100644 --- a/server/mpm/dexter/scoreboard.c +++ b/server/mpm/dexter/scoreboard.c @@ -86,40 +86,40 @@ static scoreboard *ap_scoreboard_image = NULL; #if APR_HAS_SHARED_MEMORY #include "apr_shmem.h" -static ap_shmem_t *scoreboard_shm = NULL; +static apr_shmem_t *scoreboard_shm = NULL; -ap_status_t ap_cleanup_shared_mem(void *d) +apr_status_t ap_cleanup_shared_mem(void *d) { - ap_shm_free(scoreboard_shm, ap_scoreboard_image); + apr_shm_free(scoreboard_shm, ap_scoreboard_image); ap_scoreboard_image = NULL; - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); return APR_SUCCESS; } -static void setup_shared_mem(ap_pool_t *p) +static void setup_shared_mem(apr_pool_t *p) { char buf[512]; const char *fname; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { - ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", + if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", ap_server_argv0); perror(buf); exit(APEXIT_INIT); } - ap_scoreboard_image = ap_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); + ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL) { - ap_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", + apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); perror(buf); - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); exit(APEXIT_INIT); } - ap_register_cleanup(p, NULL, ap_cleanup_shared_mem, ap_null_cleanup); + apr_register_cleanup(p, NULL, ap_cleanup_shared_mem, apr_null_cleanup); } -void reinit_scoreboard(ap_pool_t *p) +void reinit_scoreboard(apr_pool_t *p) { if (ap_scoreboard_image == NULL) { setup_shared_mem(p); @@ -177,40 +177,40 @@ const char *ap_get_connection_status(long conn_id, const char *key) return NULL; } -ap_array_header_t *ap_get_connections(ap_pool_t *p) +apr_array_header_t *ap_get_connections(apr_pool_t *p) { int i; - ap_array_header_t *connection_list; + apr_array_header_t *connection_list; long *array_slot; - connection_list = ap_make_array(p, 0, sizeof(long)); + connection_list = apr_make_array(p, 0, sizeof(long)); /* We assume that there is a connection iff it has an entry in the status * table. Connections without any status sound problematic to me, so this * is probably for the best. - manoj */ for (i = 0; i < ap_max_daemons_limit*HARD_THREAD_LIMIT; i++) { if (ap_scoreboard_image->table[i][0].key[0] != '\0') { - array_slot = ap_push_array(connection_list); + array_slot = apr_push_array(connection_list); *array_slot = i; } } return connection_list; } -ap_array_header_t *ap_get_connection_keys(ap_pool_t *p, long conn_id) +apr_array_header_t *ap_get_connection_keys(apr_pool_t *p, long conn_id) { int i = 0; status_table_entry *ss; - ap_array_header_t *key_list; + apr_array_header_t *key_list; char **array_slot; - key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char)); + key_list = apr_make_array(p, 0, KEY_LENGTH * sizeof(char)); while (i < STATUSES_PER_CONNECTION) { ss = &(ap_scoreboard_image->table[conn_id][i]); if (ss->key[0] == '\0') { break; } - array_slot = ap_push_array(key_list); - *array_slot = ap_pstrdup(p, ss->key); + array_slot = apr_push_array(key_list); + *array_slot = apr_pstrdup(p, ss->key); i++; } return key_list; @@ -233,7 +233,7 @@ void ap_update_connection_status(long conn_id, const char *key, break; } if (0 == strcmp(ss->key, key)) { - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } i++; @@ -243,19 +243,19 @@ void ap_update_connection_status(long conn_id, const char *key, /* No room. Oh well, not much anyone can do about it. */ return; } - ap_cpystrn(ss->key, key, KEY_LENGTH); - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->key, key, KEY_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } -ap_array_header_t *ap_get_status_table(ap_pool_t *p) +apr_array_header_t *ap_get_status_table(apr_pool_t *p) { int i, j; - ap_array_header_t *server_status; + apr_array_header_t *server_status; ap_status_table_row_t *array_slot; status_table_entry *ss; - server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t)); + server_status = apr_make_array(p, 0, sizeof(ap_status_table_row_t)); /* Go ahead and return what's in the connection status table even if we * aren't maintaining it. We can at least look at what children from @@ -264,14 +264,14 @@ ap_array_header_t *ap_get_status_table(ap_pool_t *p) for (i = 0; i < ap_max_daemons_limit*HARD_THREAD_LIMIT; i++) { if (ap_scoreboard_image->table[i][0].key[0] == '\0') continue; - array_slot = ap_push_array(server_status); - array_slot->data = ap_make_table(p, 0); + array_slot = apr_push_array(server_status); + array_slot->data = apr_make_table(p, 0); array_slot->conn_id = i; for (j = 0; j < STATUSES_PER_CONNECTION; j++) { ss = &(ap_scoreboard_image->table[i][j]); if (ss->key[0] != '\0') { - ap_table_add(array_slot->data, ss->key, ss->value); + apr_table_add(array_slot->data, ss->key, ss->value); } else { break; diff --git a/server/mpm/dexter/scoreboard.h b/server/mpm/dexter/scoreboard.h index 73a54f1b6c..7106f350c6 100644 --- a/server/mpm/dexter/scoreboard.h +++ b/server/mpm/dexter/scoreboard.h @@ -72,9 +72,9 @@ extern "C" { #include "mpm_default.h" /* For HARD_.*_LIMIT */ /* The generic shared memory chunk code */ -void reinit_scoreboard(ap_pool_t *p); +void reinit_scoreboard(apr_pool_t *p); -API_EXPORT(void) reopen_scoreboard(ap_pool_t *p); +API_EXPORT(void) reopen_scoreboard(apr_pool_t *p); /* The stuff for Dexter's status table */ @@ -100,7 +100,7 @@ typedef struct { API_VAR_EXPORT extern const char *ap_scoreboard_fname; -ap_status_t ap_cleanup_shared_mem(void *d); +apr_status_t ap_cleanup_shared_mem(void *d); #ifdef __cplusplus } diff --git a/server/mpm/experimental/perchild/perchild.c b/server/mpm/experimental/perchild/perchild.c index 32c1a4d513..5e8d3ae0bd 100644 --- a/server/mpm/experimental/perchild/perchild.c +++ b/server/mpm/experimental/perchild/perchild.c @@ -74,7 +74,7 @@ #include "unixd.h" #include "mpm_common.h" #include "ap_iol.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "mpm_default.h" #include "mpm.h" #include "scoreboard.h" @@ -113,7 +113,7 @@ static int socket_num=0; static int workers_may_exit = 0; static int requests_this_child; static int num_listenfds = 0; -static ap_socket_t **listenfds; +static apr_socket_t **listenfds; struct child_info_t { uid_t uid; @@ -140,7 +140,7 @@ typedef struct socket_info_t socket_info_t; * process. */ static child_info_t child_info_table[HARD_SERVER_LIMIT]; -static ap_hash_t *socket_info_table = NULL; +static apr_hash_t *socket_info_table = NULL; struct ap_ctable ap_child_table[HARD_SERVER_LIMIT]; @@ -159,8 +159,8 @@ char ap_coredump_dir[MAX_STRING_LEN]; module MODULE_VAR_EXPORT mpm_perchild_module; -static ap_file_t *pipe_of_death_in = NULL; -static ap_file_t *pipe_of_death_out = NULL; +static apr_file_t *pipe_of_death_in = NULL; +static apr_file_t *pipe_of_death_out = NULL; static pthread_mutex_t pipe_of_death_mutex; /* *Non*-shared http_main globals... */ @@ -184,9 +184,9 @@ static int one_process = 0; int raise_sigstop_flags; #endif -static ap_pool_t *pconf; /* Pool for config stuff */ -static ap_pool_t *pchild; /* Pool for httpd child stuff */ -static ap_pool_t *thread_pool_parent; /* Parent of per-thread pools */ +static apr_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pchild; /* Pool for httpd child stuff */ +static apr_pool_t *thread_pool_parent; /* Parent of per-thread pools */ static pthread_mutex_t thread_pool_parent_mutex; static int child_num; @@ -207,7 +207,7 @@ static pthread_mutex_t idle_thread_count_mutex; #define SAFE_ACCEPT(stmt) APR_SUCCESS #else #define SAFE_ACCEPT(stmt) (stmt) -static ap_lock_t *process_accept_mutex; +static apr_lock_t *process_accept_mutex; #endif /* NO_SERIALIZED_ACCEPT */ static const char *lock_fname; static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -221,7 +221,7 @@ API_EXPORT(int) ap_get_max_daemons(void) static void clean_child_exit(int code) { if (pchild) { - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); } exit(code); } @@ -230,7 +230,7 @@ static void clean_child_exit(int code) static void sig_coredump(int sig) { chdir(ap_coredump_dir); - ap_signal(sig, SIG_DFL); + apr_signal(sig, SIG_DFL); kill(getpid(), sig); /* At this point we've got sig blocked, because we're still inside * the signal handler. When we leave the signal handler it will @@ -297,7 +297,7 @@ static void ap_start_restart(int graceful) restart_pending = 1; is_graceful = graceful; if (is_graceful) { - ap_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); + apr_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); } } @@ -383,36 +383,36 @@ static void set_signals(void) ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)"); #else if (!one_process) { - ap_signal(SIGSEGV, sig_coredump); + apr_signal(SIGSEGV, sig_coredump); #ifdef SIGBUS - ap_signal(SIGBUS, sig_coredump); + apr_signal(SIGBUS, sig_coredump); #endif /* SIGBUS */ #ifdef SIGABORT - ap_signal(SIGABORT, sig_coredump); + apr_signal(SIGABORT, sig_coredump); #endif /* SIGABORT */ #ifdef SIGABRT - ap_signal(SIGABRT, sig_coredump); + apr_signal(SIGABRT, sig_coredump); #endif /* SIGABRT */ #ifdef SIGILL - ap_signal(SIGILL, sig_coredump); + apr_signal(SIGILL, sig_coredump); #endif /* SIGILL */ #ifdef SIGXCPU - ap_signal(SIGXCPU, SIG_DFL); + apr_signal(SIGXCPU, SIG_DFL); #endif /* SIGXCPU */ #ifdef SIGXFSZ - ap_signal(SIGXFSZ, SIG_DFL); + apr_signal(SIGXFSZ, SIG_DFL); #endif /* SIGXFSZ */ } - ap_signal(SIGTERM, sig_term); + apr_signal(SIGTERM, sig_term); #ifdef SIGHUP - ap_signal(SIGHUP, restart); + apr_signal(SIGHUP, restart); #endif /* SIGHUP */ #ifdef SIGWINCH - ap_signal(SIGWINCH, restart); + apr_signal(SIGWINCH, restart); #endif /* SIGWINCH */ #ifdef SIGPIPE - ap_signal(SIGPIPE, SIG_IGN); + apr_signal(SIGPIPE, SIG_IGN); #endif /* SIGPIPE */ #endif @@ -432,16 +432,16 @@ int ap_graceful_stop_signalled(void) * Child process main loop. */ -static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id) +static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id) { BUFF *conn_io; conn_rec *current_conn; ap_iol *iol; int csd; - ap_status_t rv; + apr_status_t rv; - if ((rv = ap_get_os_sock(&csd, sock)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_get_os_sock"); + if ((rv = apr_get_os_sock(&csd, sock)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_get_os_sock"); } if (csd >= FD_SETSIZE) { @@ -450,7 +450,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id) "to rebuild Apache with a larger FD_SETSIZE " "(currently %d)", csd, FD_SETSIZE); - ap_close_socket(sock); + apr_close_socket(sock); return; } @@ -518,10 +518,10 @@ static void check_pipe_of_death(void) if (!workers_may_exit) { int ret; char pipe_read_char; - ap_ssize_t n = 1; + apr_ssize_t n = 1; - ret = ap_recv(listenfds[0], &pipe_read_char, &n); - if (ap_canonical_error(ret) == APR_EAGAIN) { + ret = apr_recv(listenfds[0], &pipe_read_char, &n); + if (apr_canonical_error(ret) == APR_EAGAIN) { /* It lost the lottery. It must continue to suffer * through a life of servitude. */ } @@ -538,27 +538,27 @@ static void check_pipe_of_death(void) static void *worker_thread(void *arg) { - ap_socket_t *csd = NULL; - ap_pool_t *tpool; /* Pool for this thread */ - ap_pool_t *ptrans; /* Pool for per-transaction stuff */ - ap_socket_t *sd = NULL; + apr_socket_t *csd = NULL; + apr_pool_t *tpool; /* Pool for this thread */ + apr_pool_t *ptrans; /* Pool for per-transaction stuff */ + apr_socket_t *sd = NULL; int srv; int curr_pollfd, last_pollfd = 0; int thread_just_started = 1; int thread_num = *((int *) arg); long conn_id = child_num * HARD_THREAD_LIMIT + thread_num; - ap_pollfd_t *pollset; + apr_pollfd_t *pollset; int n; - ap_status_t rv; + apr_status_t rv; pthread_mutex_lock(&thread_pool_parent_mutex); - ap_create_pool(&tpool, thread_pool_parent); + apr_create_pool(&tpool, thread_pool_parent); pthread_mutex_unlock(&thread_pool_parent_mutex); - ap_create_pool(&ptrans, tpool); + apr_create_pool(&ptrans, tpool); - ap_setup_poll(&pollset, num_listenfds+1, tpool); + apr_setup_poll(&pollset, num_listenfds+1, tpool); for(n=0 ; n <= num_listenfds ; ++n) { - ap_add_poll_socket(pollset, listenfds[n], APR_POLLIN); + apr_add_poll_socket(pollset, listenfds[n], APR_POLLIN); } while (!workers_may_exit) { @@ -583,32 +583,32 @@ static void *worker_thread(void *arg) pthread_mutex_unlock(&thread_accept_mutex); break; } - if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_lock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_lock failed. Attempting to shutdown " + "apr_lock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } while (!workers_may_exit) { - ap_int16_t event; - srv = ap_poll(pollset, &n, -1); + apr_int16_t event; + srv = apr_poll(pollset, &n, -1); if (srv != APR_SUCCESS) { - if (ap_canonical_error(srv) == APR_EINTR) { + if (apr_canonical_error(srv) == APR_EINTR) { continue; } - /* ap_poll() will only return errors in catastrophic + /* apr_poll() will only return errors in catastrophic * circumstances. Let's try exiting gracefully, for now. */ ap_log_error(APLOG_MARK, APLOG_ERR, srv, (const server_rec *) - ap_server_conf, "ap_poll: (listen)"); + ap_server_conf, "apr_poll: (listen)"); workers_may_exit = 1; } if (workers_may_exit) break; - ap_get_revents(&event, listenfds[0], pollset); + apr_get_revents(&event, listenfds[0], pollset); if (event & APR_POLLIN) { /* A process got a signal on the shutdown pipe. Check if we're * the lucky process to die. */ @@ -629,7 +629,7 @@ static void *worker_thread(void *arg) curr_pollfd = 1; } /* XXX: Should we check for POLLERR? */ - ap_get_revents(&event, listenfds[curr_pollfd], pollset); + apr_get_revents(&event, listenfds[curr_pollfd], pollset); if (event & APR_POLLIN) { last_pollfd = curr_pollfd; sd = listenfds[curr_pollfd]; @@ -640,13 +640,13 @@ static void *worker_thread(void *arg) } got_fd: if (!workers_may_exit) { - if ((rv = ap_accept(&csd, sd, ptrans)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "ap_accept"); + if ((rv = apr_accept(&csd, sd, ptrans)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "apr_accept"); } - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } @@ -664,10 +664,10 @@ static void *worker_thread(void *arg) process_socket(ptrans, csd, conn_id); requests_this_child--; } else { - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } @@ -677,11 +677,11 @@ static void *worker_thread(void *arg) pthread_mutex_unlock(&idle_thread_count_mutex); break; } - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); } pthread_mutex_lock(&thread_pool_parent_mutex); - ap_destroy_pool(tpool); + apr_destroy_pool(tpool); pthread_mutex_unlock(&thread_pool_parent_mutex); pthread_mutex_lock(&worker_thread_count_mutex); worker_thread_count--; @@ -770,7 +770,7 @@ static int perchild_setup_child(int childnum) return 0; } -static int create_child_socket(int child_num, ap_pool_t *p) +static int create_child_socket(int child_num, apr_pool_t *p) { struct sockaddr_un unix_addr; mode_t omask; @@ -779,9 +779,9 @@ static int create_child_socket(int child_num, ap_pool_t *p) perchild_server_conf *sconf = (perchild_server_conf *) ap_get_module_config(ap_server_conf->module_config, &mpm_perchild_module); int len = strlen(sconf->sockname) + strlen(child_info_table[child_num].name) + 3; - char *socket_name = ap_palloc(p, len); + char *socket_name = apr_palloc(p, len); - ap_snprintf(socket_name, len, "%s.%s", sconf->sockname, child_info_table[child_num].name); + apr_snprintf(socket_name, len, "%s.%s", sconf->sockname, child_info_table[child_num].name); if (unlink(socket_name) < 0 && errno != ENOENT) { ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf, @@ -833,15 +833,15 @@ static void child_main(int child_num_arg) int signal_received; int i; ap_listen_rec *lr; - ap_status_t rv; + apr_status_t rv; my_pid = getpid(); child_num = child_num_arg; - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); /*stuff to do before we switch id's, so we have permissions.*/ - rv = SAFE_ACCEPT(ap_child_init_lock(&process_accept_mutex, lock_fname, + rv = SAFE_ACCEPT(apr_child_init_lock(&process_accept_mutex, lock_fname, pchild)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, @@ -879,13 +879,13 @@ static void child_main(int child_num_arg) /* Set up the pollfd array, num_listenfds + 1 for the pipe and 1 for * the child socket. */ - listenfds = ap_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 2)); + listenfds = apr_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 2)); #if APR_FILES_AS_SOCKETS - ap_socket_from_file(&listenfds[0], pipe_of_death_in); + apr_socket_from_file(&listenfds[0], pipe_of_death_in); #endif /* The child socket */ - ap_put_os_sock(&listenfds[1], &child_info_table[child_num].sd, pchild); + apr_put_os_sock(&listenfds[1], &child_info_table[child_num].sd, pchild); num_listenfds++; for (lr = ap_listeners, i = 2; i <= num_listenfds; lr = lr->next, ++i) @@ -901,7 +901,7 @@ static void child_main(int child_num_arg) for (i = 0; i < max_threads; i++) { worker_thread_free_ids[i] = i; } - ap_create_pool(&thread_pool_parent, pchild); + apr_create_pool(&thread_pool_parent, pchild); pthread_mutex_init(&thread_pool_parent_mutex, NULL); pthread_mutex_init(&idle_thread_count_mutex, NULL); pthread_mutex_init(&worker_thread_count_mutex, NULL); @@ -984,7 +984,7 @@ static int make_child(server_rec *s, int slot, time_t now) RAISE_SIGSTOP(MAKE_CHILD); /* XXX - For an unthreaded server, a signal handler will be necessary - ap_signal(SIGTERM, just_die); + apr_signal(SIGTERM, just_die); */ child_main(slot); @@ -1078,7 +1078,7 @@ static void server_main_loop(int remaining_children_to_start) { int child_slot; ap_wait_t status; - ap_proc_t pid; + apr_proc_t pid; int i; while (!restart_pending && !shutdown_pending) { @@ -1113,7 +1113,7 @@ static void server_main_loop(int remaining_children_to_start) } #if APR_HAS_OTHER_CHILD } - else if (ap_reap_other_child(&pid, status) == 0) { + else if (apr_reap_other_child(&pid, status) == 0) { /* handled */ #endif } @@ -1152,26 +1152,26 @@ static void server_main_loop(int remaining_children_to_start) } } -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_children_to_start; int i; - ap_status_t rv; - ap_ssize_t one = 1; + apr_status_t rv; + apr_ssize_t one = 1; pconf = _pconf; ap_server_conf = s; - if ((rv = ap_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf)) + if ((rv = apr_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_create_pipe (pipe_of_death)"); + "apr_create_pipe (pipe_of_death)"); exit(1); } - if ((rv = ap_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { + if ((rv = apr_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_set_pipe_timeout (pipe_of_death)"); + "apr_set_pipe_timeout (pipe_of_death)"); exit(1); } ap_server_conf = s; @@ -1205,10 +1205,10 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* Initialize cross-process accept lock */ - lock_fname = ap_psprintf(_pconf, "%s.%u", + lock_fname = apr_psprintf(_pconf, "%s.%u", ap_server_root_relative(_pconf, lock_fname), my_pid); - rv = SAFE_ACCEPT(ap_create_lock(&process_accept_mutex, APR_MUTEX, + rv = SAFE_ACCEPT(apr_create_lock(&process_accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, lock_fname, _pconf)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, @@ -1284,7 +1284,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* we've been told to restart */ - ap_signal(SIGHUP, SIG_IGN); + apr_signal(SIGHUP, SIG_IGN); if (one_process) { /* not worth thinking about */ @@ -1308,8 +1308,8 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* give the children the signal to die */ for (i = 0; i < num_daemons;) { - if ((rv = ap_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { - if (ap_canonical_error(rv) == APR_EINTR) continue; + if ((rv = apr_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { + if (apr_canonical_error(rv) == APR_EINTR) continue; ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, "write pipe_of_death"); } @@ -1332,7 +1332,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) return 0; } -static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) +static void perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; int no_detach = 0; @@ -1346,7 +1346,7 @@ static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) is_graceful = 0; if (!one_process && !no_detach) { - ap_detach(); + apr_detach(); } my_pid = getpid(); @@ -1367,7 +1367,7 @@ static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) curr_child_num = 0; socket_num = 0; - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); for (i = 0; i < HARD_SERVER_LIMIT; i++) { child_info_table[i].uid = -1; @@ -1377,13 +1377,13 @@ static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) } } -static void perchild_post_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp, server_rec *s) +static void perchild_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { int i; for (i = 0; i < num_daemons; i++) { if (child_info_table[i].name == NULL) { - child_info_table[i].name = ap_pstrdup(p, "DEFAULT"); + child_info_table[i].name = apr_pstrdup(p, "DEFAULT"); child_info_table[i].num = socket_num; } } @@ -1391,13 +1391,13 @@ static void perchild_post_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp static int perchild_post_read(request_rec *r) { - const char *hostname = ap_table_get(r->headers_in, "Host"); + const char *hostname = apr_table_get(r->headers_in, "Host"); char *process_num; int num; fprintf(stderr, "In perchild_post_read\n"); fflush(stderr); - process_num = ap_hash_get(socket_info_table, hostname, 0); + process_num = apr_hash_get(socket_info_table, hostname, 0); if (process_num) { num = atoi(process_num); } @@ -1603,7 +1603,7 @@ static const char *set_maintain_connection_status(cmd_parms *cmd, static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1611,12 +1611,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1635,7 +1635,7 @@ static const char *set_child_per_uid(cmd_parms *cmd, void *dummy, const char *u, ug->uid = atoi(u); ug->gid = atoi(g); - ug->name = ap_pstrcat(cmd->pool, u, ":", g, NULL); + ug->name = apr_pstrcat(cmd->pool, u, ":", g, NULL); ug->num = socket_num; } socket_num++; @@ -1652,7 +1652,7 @@ static const char *set_socket_name(cmd_parms *cmd, void *dummy, const char *arg) return NULL; } -static ap_status_t cleanup_hash(void *dptr) +static apr_status_t cleanup_hash(void *dptr) { socket_info_table = NULL; return APR_SUCCESS; @@ -1661,12 +1661,12 @@ static ap_status_t cleanup_hash(void *dptr) static const char *assign_childuid(cmd_parms *cmd, void *dummy, const char *uid, const char *gid) { - char *socketname = ap_pstrcat(cmd->pool, uid, ":", gid, NULL); + char *socketname = apr_pstrcat(cmd->pool, uid, ":", gid, NULL); if (socket_info_table == NULL) { - socket_info_table = ap_make_hash(cmd->pool); - ap_register_cleanup(cmd->pool, socket_info_table, cleanup_hash, NULL); + socket_info_table = apr_make_hash(cmd->pool); + apr_register_cleanup(cmd->pool, socket_info_table, cleanup_hash, NULL); } - ap_hash_set(socket_info_table, cmd->server->server_hostname, 0, socketname); + apr_hash_set(socket_info_table, cmd->server->server_hostname, 0, socketname); return NULL; } @@ -1707,10 +1707,10 @@ AP_INIT_TAKE1("ChildSockName", set_socket_name, NULL, RSRC_CONF, { NULL } }; -static void *perchild_create_config(ap_pool_t *p, server_rec *s) +static void *perchild_create_config(apr_pool_t *p, server_rec *s) { perchild_server_conf *c = - (perchild_server_conf *) ap_pcalloc(p, sizeof(perchild_server_conf)); + (perchild_server_conf *) apr_pcalloc(p, sizeof(perchild_server_conf)); c->sockname = ap_server_root_relative(p, DEFAULT_PERCHILD_SOCKET); return c; @@ -1723,7 +1723,7 @@ module MODULE_VAR_EXPORT mpm_perchild_module = { NULL, /* merge per-directory config structures */ perchild_create_config, /* create per-server config structure */ NULL, /* merge per-server config structures */ - perchild_cmds, /* command ap_table_t */ + perchild_cmds, /* command apr_table_t */ NULL, /* handlers */ perchild_hooks /* register_hooks */ }; diff --git a/server/mpm/mpmt_beos/mpmt_beos.c b/server/mpm/mpmt_beos/mpmt_beos.c index ba5514f209..ff66f0440c 100644 --- a/server/mpm/mpmt_beos/mpmt_beos.c +++ b/server/mpm/mpmt_beos/mpmt_beos.c @@ -73,7 +73,7 @@ #include "ap_mpm.h" #include "beosd.h" #include "ap_iol.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "scoreboard.h" #include "poll.h" #include "mpm_common.h" @@ -98,24 +98,24 @@ static int workers_may_exit = 0; static int requests_this_child; static int num_listenfds = 0; static struct pollfd *listenfds; -ap_lock_t *accept_mutex = NULL; +apr_lock_t *accept_mutex = NULL; -static ap_pool_t *pconf; /* Pool for config stuff */ -static ap_pool_t *pchild; /* Pool for httpd child stuff */ +static apr_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pchild; /* Pool for httpd child stuff */ static int my_pid; /* Linux getpid() doesn't work except in main thread. Use this instead */ /* Keep track of the number of worker threads currently active */ static int worker_thread_count; -ap_lock_t *worker_thread_count_mutex; +apr_lock_t *worker_thread_count_mutex; /* The structure used to pass unique initialization info to each thread */ typedef struct { int pid; thread_id tid; int sd; - ap_pool_t *tpool; /* "pthread" would be confusing */ + apr_pool_t *tpool; /* "pthread" would be confusing */ } proc_info; struct ap_ctable ap_child_table[HARD_SERVER_LIMIT]; @@ -151,7 +151,7 @@ API_EXPORT(int) ap_get_max_daemons(void) void clean_child_exit(int code) { if (pchild) { - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); } exit(code); } @@ -294,7 +294,7 @@ int ap_graceful_stop_signalled(void) * Child process main loop. */ -static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, int my_thread_num) +static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num, int my_thread_num) { BUFF *conn_io; conn_rec *current_conn; @@ -314,7 +314,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, in ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL, "error attaching to socket"); } - ap_close_socket(sock); + apr_close_socket(sock); return; } @@ -333,10 +333,10 @@ static int32 worker_thread(void * dummy) proc_info * ti = dummy; int process_slot = ti->pid; int thread_slot = ti->tid; - ap_pool_t *tpool = ti->tpool; - ap_socket_t *csd = NULL; - ap_pool_t *ptrans; /* Pool for per-transaction stuff */ - ap_socket_t *sd = NULL; + apr_pool_t *tpool = ti->tpool; + apr_socket_t *csd = NULL; + apr_pool_t *ptrans; /* Pool for per-transaction stuff */ + apr_socket_t *sd = NULL; int srv; int curr_pollfd, last_pollfd = 0; sigset_t sig_mask; @@ -347,11 +347,11 @@ static int32 worker_thread(void * dummy) sigfillset(&sig_mask); sigprocmask(SIG_BLOCK, &sig_mask, NULL); - ap_create_pool(&ptrans, tpool); + apr_create_pool(&ptrans, tpool); - ap_lock(worker_thread_count_mutex); + apr_lock(worker_thread_count_mutex); worker_thread_count++; - ap_unlock(worker_thread_count_mutex); + apr_unlock(worker_thread_count_mutex); /* TODO: Switch to a system where threads reuse the results from earlier poll calls - manoj */ @@ -359,7 +359,7 @@ static int32 worker_thread(void * dummy) workers_may_exit |= (ap_max_requests_per_child != 0) && (requests_this_child <= 0); if (workers_may_exit) break; - ap_lock(accept_mutex); + apr_lock(accept_mutex); while (!workers_may_exit) { srv = poll(listenfds, num_listenfds + 1, -1); if (srv < 0) { @@ -391,7 +391,7 @@ static int32 worker_thread(void * dummy) /* XXX: Should we check for POLLERR? */ if (listenfds[curr_pollfd].revents & POLLIN) { last_pollfd = curr_pollfd; - ap_put_os_sock(&sd, &listenfds[curr_pollfd].fd, tpool); + apr_put_os_sock(&sd, &listenfds[curr_pollfd].fd, tpool); goto got_fd; } } while (curr_pollfd != last_pollfd); @@ -399,28 +399,28 @@ static int32 worker_thread(void * dummy) } got_fd: if (!workers_may_exit) { - ap_accept(&csd, sd, ptrans); - ap_unlock(accept_mutex); + apr_accept(&csd, sd, ptrans); + apr_unlock(accept_mutex); process_socket(ptrans, csd, process_slot, thread_slot); requests_this_child--; } else { - ap_unlock(accept_mutex); + apr_unlock(accept_mutex); break; } - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); } - ap_destroy_pool(tpool); - ap_lock(worker_thread_count_mutex); + apr_destroy_pool(tpool); + apr_lock(worker_thread_count_mutex); worker_thread_count--; if (worker_thread_count == 0) { /* All the threads have exited, now finish the shutdown process * by signalling the sigwait thread */ kill(my_pid, SIGTERM); } - ap_unlock(worker_thread_count_mutex); + apr_unlock(worker_thread_count_mutex); return (0); } @@ -437,10 +437,10 @@ static int32 child_main(void * data) struct sigaction sa; int32 msg; char buf; - ap_status_t rv; + apr_status_t rv; my_pid = getpid(); - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); if (beosd_setup_child()) { clean_child_exit(APEXIT_CHILDFATAL); @@ -457,9 +457,9 @@ static int32 child_main(void * data) requests_this_child = ap_max_requests_per_child; /* Set up the pollfd array */ - listenfds = ap_palloc(pchild, sizeof(struct pollfd) * (num_listenfds)); + listenfds = apr_palloc(pchild, sizeof(struct pollfd) * (num_listenfds)); for (lr = ap_listeners, i = 0; i < num_listenfds; lr = lr->next, ++i) { - ap_get_os_sock(&listenfds[i].fd , lr->sd); + apr_get_os_sock(&listenfds[i].fd , lr->sd); listenfds[i].events = POLLIN; /* should we add POLLPRI ?*/ listenfds[i].revents = 0; } @@ -467,7 +467,7 @@ static int32 child_main(void * data) /* Setup worker threads */ worker_thread_count = 0; - if ((rv = ap_create_lock(&worker_thread_count_mutex, APR_MUTEX, + if ((rv = apr_create_lock(&worker_thread_count_mutex, APR_MUTEX, APR_CROSS_PROCESS, NULL, pchild)) != APR_SUCCESS) { /* Oh dear, didn't manage to create a worker thread mutex, so there's no point on going on with this child... */ @@ -484,7 +484,7 @@ static int32 child_main(void * data) my_info->pid = my_child_num; my_info->tid = i; my_info->sd = 0; - ap_create_pool(&my_info->tpool, pchild); + apr_create_pool(&my_info->tpool, pchild); /* We are creating threads right now */ if ((thread = spawn_thread(worker_thread, "httpd_worker_thread", @@ -625,7 +625,7 @@ static void server_main_loop(int remaining_children_to_start) { int child_slot; ap_wait_t status; - ap_proc_t pid; + apr_proc_t pid; int i; while (!restart_pending && !shutdown_pending) { @@ -659,7 +659,7 @@ static void server_main_loop(int remaining_children_to_start) } #if APR_HAS_OTHER_CHILD } - else if (ap_reap_other_child(&pid, status) == 0) { + else if (apr_reap_other_child(&pid, status) == 0) { /* handled */ #endif } @@ -696,10 +696,10 @@ static void server_main_loop(int remaining_children_to_start) } } -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_children_to_start; - ap_status_t rv; + apr_status_t rv; pconf = _pconf; ap_server_conf = s; @@ -714,7 +714,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) ap_log_pid(pconf, ap_pid_fname); /* create the accept_mutex */ - if ((rv = ap_create_lock(&accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, + if ((rv = apr_create_lock(&accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, NULL, pconf)) != APR_SUCCESS) { /* tsch tsch, can't have more than one thread in the accept loop at a time so we need to fall on our sword... */ @@ -838,7 +838,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) return 0; } -static void mpmt_beos_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp) +static void mpmt_beos_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; int no_detach = 0; @@ -868,7 +868,7 @@ static void mpmt_beos_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *p ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; ap_mpmt_beos_set_maintain_connection_status(1); - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } static void mpmt_beos_hooks(void) @@ -1030,7 +1030,7 @@ static const char *set_maintain_connection_status(cmd_parms *cmd, static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1038,12 +1038,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1080,7 +1080,7 @@ module MODULE_VAR_EXPORT mpm_mpmt_beos_module = { NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ - mpmt_beos_cmds, /* command ap_table_t */ + mpmt_beos_cmds, /* command apr_table_t */ NULL, /* handlers */ mpmt_beos_hooks /* register_hooks */ }; diff --git a/server/mpm/mpmt_beos/scoreboard.c b/server/mpm/mpmt_beos/scoreboard.c index eaebe8513b..da7b6d2ad3 100644 --- a/server/mpm/mpmt_beos/scoreboard.c +++ b/server/mpm/mpmt_beos/scoreboard.c @@ -68,11 +68,11 @@ #include "mpm.h" /* includes scoreboard.h */ scoreboard *ap_scoreboard_image = NULL; -extern ap_pool_t * pconf; +extern apr_pool_t * pconf; extern int ap_max_daemons_limit; static int maintain_connection_status = 1; -void reinit_scoreboard(ap_pool_t *p) +void reinit_scoreboard(apr_pool_t *p) { ap_assert(!ap_scoreboard_image); ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE); @@ -109,7 +109,7 @@ void ap_update_connection_status(long conn_id, const char *key, break; } if (0 == strcmp(ss->key, key)) { - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } i++; @@ -117,8 +117,8 @@ void ap_update_connection_status(long conn_id, const char *key, if (i >= STATUSES_PER_CONNECTION) { return; } - ap_cpystrn(ss->key, key, KEY_LENGTH); - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->key, key, KEY_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } @@ -162,62 +162,62 @@ const char *ap_get_connection_status(long conn_id, const char *key) return NULL; } -ap_array_header_t *ap_get_connections(ap_pool_t *p) +apr_array_header_t *ap_get_connections(apr_pool_t *p) { int i; - ap_array_header_t *connection_list; + apr_array_header_t *connection_list; long *array_slot; - connection_list = ap_make_array(p, 0, sizeof(long)); + connection_list = apr_make_array(p, 0, sizeof(long)); for (i = 0; i < ap_max_daemons_limit * HARD_THREAD_LIMIT; i++) { if (ap_scoreboard_image->table[i][0].key[0] != '\0') { - array_slot = ap_push_array(connection_list); + array_slot = apr_push_array(connection_list); *array_slot = i; } } return connection_list; } -ap_array_header_t *ap_get_connection_keys(ap_pool_t *p, long conn_id) +apr_array_header_t *ap_get_connection_keys(apr_pool_t *p, long conn_id) { int i = 0; status_table_entry *ss; - ap_array_header_t *key_list; + apr_array_header_t *key_list; char **array_slot; - key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char)); + key_list = apr_make_array(p, 0, KEY_LENGTH * sizeof(char)); while (i < STATUSES_PER_CONNECTION) { ss = &(ap_scoreboard_image->table[conn_id][i]); if (ss->key[0] == '\0') { break; } - array_slot = ap_push_array(key_list); - *array_slot = ap_pstrdup(p, ss->key); + array_slot = apr_push_array(key_list); + *array_slot = apr_pstrdup(p, ss->key); i++; } return key_list; } -ap_array_header_t *ap_get_status_table(ap_pool_t *p) +apr_array_header_t *ap_get_status_table(apr_pool_t *p) { int i, j; - ap_array_header_t *server_status; + apr_array_header_t *server_status; ap_status_table_row_t *array_slot; status_table_entry *ss; - server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t)); + server_status = apr_make_array(p, 0, sizeof(ap_status_table_row_t)); for (i = 0; i < ap_max_daemons_limit * HARD_THREAD_LIMIT; i++) { if (ap_scoreboard_image->table[i][0].key[0] == '\0') continue; - array_slot = ap_push_array(server_status); - array_slot->data = ap_make_table(p, 0); + array_slot = apr_push_array(server_status); + array_slot->data = apr_make_table(p, 0); array_slot->conn_id = i; for (j = 0; j < STATUSES_PER_CONNECTION; j++) { ss = &(ap_scoreboard_image->table[i][j]); if (ss->key[0] != '\0') { - ap_table_add(array_slot->data, ss->key, ss->value); + apr_table_add(array_slot->data, ss->key, ss->value); } else { break; diff --git a/server/mpm/mpmt_beos/scoreboard.h b/server/mpm/mpmt_beos/scoreboard.h index 116be56190..cf1bbce14c 100644 --- a/server/mpm/mpmt_beos/scoreboard.h +++ b/server/mpm/mpmt_beos/scoreboard.h @@ -67,11 +67,11 @@ extern "C" { #include "mpm_default.h" /* For HARD_.*_LIMIT */ API_EXPORT(int) ap_exists_scoreboard_image(void); -void reinit_scoareboard(ap_pool_t *p); +void reinit_scoareboard(apr_pool_t *p); void cleanup_scoreboard(void); void ap_mpmt_beos_set_maintain_connection_status(int flag); void ap_mpmt_beos_force_reset_connection_status(long conn_id); -void reinit_scoreboard(ap_pool_t *p); +void reinit_scoreboard(apr_pool_t *p); void update_scoreboard_global(void); API_EXPORT(int) find_child_by_pid(int pid); int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r); diff --git a/server/mpm/mpmt_pthread/mpmt_pthread.c b/server/mpm/mpmt_pthread/mpmt_pthread.c index c9e7dc3deb..761df42513 100644 --- a/server/mpm/mpmt_pthread/mpmt_pthread.c +++ b/server/mpm/mpmt_pthread/mpmt_pthread.c @@ -105,14 +105,14 @@ API_VAR_EXPORT int ap_extended_status = 0; static int workers_may_exit = 0; static int requests_this_child; static int num_listensocks = 0; -static ap_socket_t **listensocks; +static apr_socket_t **listensocks; /* The structure used to pass unique initialization info to each thread */ typedef struct { int pid; int tid; int sd; - ap_pool_t *tpool; /* "pthread" would be confusing */ + apr_pool_t *tpool; /* "pthread" would be confusing */ } proc_info; /* @@ -124,8 +124,8 @@ int ap_max_daemons_limit = -1; char ap_coredump_dir[MAX_STRING_LEN]; -static ap_file_t *pipe_of_death_in = NULL; -static ap_file_t *pipe_of_death_out = NULL; +static apr_file_t *pipe_of_death_in = NULL; +static apr_file_t *pipe_of_death_out = NULL; static pthread_mutex_t pipe_of_death_mutex; /* *Non*-shared http_main globals... */ @@ -149,8 +149,8 @@ static int one_process = 0; int raise_sigstop_flags; #endif -static ap_pool_t *pconf; /* Pool for config stuff */ -static ap_pool_t *pchild; /* Pool for httpd child stuff */ +static apr_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pchild; /* Pool for httpd child stuff */ unsigned int ap_my_pid; /* Linux getpid() doesn't work except in main thread. Use this instead */ @@ -160,7 +160,7 @@ static pthread_mutex_t worker_thread_count_mutex; /* Locks for accept serialization */ static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER; -static ap_lock_t *process_accept_mutex; +static apr_lock_t *process_accept_mutex; static const char *lock_fname; #ifdef NO_SERIALIZED_ACCEPT @@ -179,7 +179,7 @@ static void clean_child_exit(int code) __attribute__ ((noreturn)); void clean_child_exit(int code) { if (pchild) { - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); } exit(code); } @@ -188,7 +188,7 @@ void clean_child_exit(int code) static void sig_coredump(int sig) { chdir(ap_coredump_dir); - ap_signal(sig, SIG_DFL); + apr_signal(sig, SIG_DFL); kill(ap_my_pid, sig); /* At this point we've got sig blocked, because we're still inside * the signal handler. When we leave the signal handler it will @@ -256,7 +256,7 @@ static void ap_start_restart(int graceful) restart_pending = 1; is_graceful = graceful; if (is_graceful) { - ap_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); + apr_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); } } @@ -342,36 +342,36 @@ static void set_signals(void) ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)"); #else if (!one_process) { - ap_signal(SIGSEGV, sig_coredump); + apr_signal(SIGSEGV, sig_coredump); #ifdef SIGBUS - ap_signal(SIGBUS, sig_coredump); + apr_signal(SIGBUS, sig_coredump); #endif /* SIGBUS */ #ifdef SIGABORT - ap_signal(SIGABORT, sig_coredump); + apr_signal(SIGABORT, sig_coredump); #endif /* SIGABORT */ #ifdef SIGABRT - ap_signal(SIGABRT, sig_coredump); + apr_signal(SIGABRT, sig_coredump); #endif /* SIGABRT */ #ifdef SIGILL - ap_signal(SIGILL, sig_coredump); + apr_signal(SIGILL, sig_coredump); #endif /* SIGILL */ #ifdef SIGXCPU - ap_signal(SIGXCPU, SIG_DFL); + apr_signal(SIGXCPU, SIG_DFL); #endif /* SIGXCPU */ #ifdef SIGXFSZ - ap_signal(SIGXFSZ, SIG_DFL); + apr_signal(SIGXFSZ, SIG_DFL); #endif /* SIGXFSZ */ } - ap_signal(SIGTERM, sig_term); + apr_signal(SIGTERM, sig_term); #ifdef SIGHUP - ap_signal(SIGHUP, restart); + apr_signal(SIGHUP, restart); #endif /* SIGHUP */ #ifdef SIGWINCH - ap_signal(SIGWINCH, restart); + apr_signal(SIGWINCH, restart); #endif /* SIGWINCH */ #ifdef SIGPIPE - ap_signal(SIGPIPE, SIG_IGN); + apr_signal(SIGPIPE, SIG_IGN); #endif /* SIGPIPE */ #endif @@ -391,7 +391,7 @@ int ap_graceful_stop_signalled(void) * Child process main loop. */ -static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, int my_thread_num) +static void process_socket(apr_pool_t *p, apr_socket_t *sock, int my_child_num, int my_thread_num) { BUFF *conn_io; conn_rec *current_conn; @@ -399,7 +399,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, in long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num; int csd; - (void) ap_get_os_sock(&csd, sock); + (void) apr_get_os_sock(&csd, sock); if (csd >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, @@ -407,7 +407,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, int my_child_num, in "to rebuild Apache with a larger FD_SETSIZE " "(currently %d)", csd, FD_SETSIZE); - ap_close_socket(sock); + apr_close_socket(sock); return; } @@ -431,12 +431,12 @@ static void check_pipe_of_death(void) { pthread_mutex_lock(&pipe_of_death_mutex); if (!workers_may_exit) { - ap_status_t ret; + apr_status_t ret; char pipe_read_char; - ap_ssize_t n = 1; + apr_ssize_t n = 1; - ret = ap_recv(listensocks[0], &pipe_read_char, &n); - if (ap_canonical_error(ret) == APR_EAGAIN) { + ret = apr_recv(listensocks[0], &pipe_read_char, &n); + if (apr_canonical_error(ret) == APR_EAGAIN) { /* It lost the lottery. It must continue to suffer * through a life of servitude. */ } @@ -454,26 +454,26 @@ static void * worker_thread(void * dummy) proc_info * ti = dummy; int process_slot = ti->pid; int thread_slot = ti->tid; - ap_pool_t *tpool = ti->tpool; - ap_socket_t *csd = NULL; - ap_pool_t *ptrans; /* Pool for per-transaction stuff */ - ap_socket_t *sd = NULL; + apr_pool_t *tpool = ti->tpool; + apr_socket_t *csd = NULL; + apr_pool_t *ptrans; /* Pool for per-transaction stuff */ + apr_socket_t *sd = NULL; int n; int curr_pollfd, last_pollfd = 0; - ap_pollfd_t *pollset; - ap_status_t rv; + apr_pollfd_t *pollset; + apr_status_t rv; free(ti); - ap_create_pool(&ptrans, tpool); + apr_create_pool(&ptrans, tpool); pthread_mutex_lock(&worker_thread_count_mutex); worker_thread_count++; pthread_mutex_unlock(&worker_thread_count_mutex); - ap_setup_poll(&pollset, num_listensocks+1, tpool); + apr_setup_poll(&pollset, num_listensocks+1, tpool); for(n=0 ; n <= num_listensocks ; ++n) - ap_add_poll_socket(pollset, listensocks[n], APR_POLLIN); + apr_add_poll_socket(pollset, listensocks[n], APR_POLLIN); /* TODO: Switch to a system where threads reuse the results from earlier poll calls - manoj */ @@ -488,34 +488,34 @@ static void * worker_thread(void * dummy) pthread_mutex_unlock(&thread_accept_mutex); break; } - if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_lock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_lock failed. Attempting to shutdown " + "apr_lock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } while (!workers_may_exit) { - ap_status_t ret; - ap_int16_t event; + apr_status_t ret; + apr_int16_t event; - ret = ap_poll(pollset, &n, -1); + ret = apr_poll(pollset, &n, -1); if (ret != APR_SUCCESS) { - if (ap_canonical_error(ret) == APR_EINTR) { + if (apr_canonical_error(ret) == APR_EINTR) { continue; } - /* ap_poll() will only return errors in catastrophic + /* apr_poll() will only return errors in catastrophic * circumstances. Let's try exiting gracefully, for now. */ ap_log_error(APLOG_MARK, APLOG_ERR, ret, (const server_rec *) - ap_server_conf, "ap_poll: (listen)"); + ap_server_conf, "apr_poll: (listen)"); workers_may_exit = 1; } if (workers_may_exit) break; - ap_get_revents(&event, listensocks[0], pollset); + apr_get_revents(&event, listensocks[0], pollset); if (event & APR_POLLIN) { /* A process got a signal on the shutdown pipe. Check if we're * the lucky process to die. */ @@ -536,7 +536,7 @@ static void * worker_thread(void * dummy) curr_pollfd = 1; } /* XXX: Should we check for POLLERR? */ - ap_get_revents(&event, listensocks[curr_pollfd], pollset); + apr_get_revents(&event, listensocks[curr_pollfd], pollset); if (event & APR_POLLIN) { last_pollfd = curr_pollfd; sd=listensocks[curr_pollfd]; @@ -547,15 +547,15 @@ static void * worker_thread(void * dummy) } got_fd: if (!workers_may_exit) { - if ((rv = ap_accept(&csd, sd, ptrans)) != APR_SUCCESS) { + if ((rv = apr_accept(&csd, sd, ptrans)) != APR_SUCCESS) { csd = NULL; ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, - "ap_accept"); + "apr_accept"); } - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } @@ -566,20 +566,20 @@ static void * worker_thread(void * dummy) } } else { - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } pthread_mutex_unlock(&thread_accept_mutex); break; } - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); } - ap_destroy_pool(tpool); + apr_destroy_pool(tpool); ap_update_child_status(process_slot, thread_slot, SERVER_DEAD, (request_rec *) NULL); pthread_mutex_lock(&worker_thread_count_mutex); @@ -605,16 +605,16 @@ static void child_main(int child_num_arg) int my_child_num = child_num_arg; proc_info *my_info = NULL; ap_listen_rec *lr; - ap_status_t rv; + apr_status_t rv; ap_my_pid = getpid(); - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); /*stuff to do before we switch id's, so we have permissions.*/ reopen_scoreboard(pchild); - rv = SAFE_ACCEPT(ap_child_init_lock(&process_accept_mutex, lock_fname, + rv = SAFE_ACCEPT(apr_child_init_lock(&process_accept_mutex, lock_fname, pchild)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, @@ -649,10 +649,10 @@ static void child_main(int child_num_arg) requests_this_child = ap_max_requests_per_child; /* Set up the pollfd array */ - listensocks = ap_pcalloc(pchild, + listensocks = apr_pcalloc(pchild, sizeof(*listensocks) * (num_listensocks + 1)); #if APR_FILES_AS_SOCKETS - ap_socket_from_file(&listensocks[0], pipe_of_death_in); + apr_socket_from_file(&listensocks[0], pipe_of_death_in); #endif for (lr = ap_listeners, i = 1; i <= num_listensocks; lr = lr->next, ++i) listensocks[i]=lr->sd; @@ -683,7 +683,7 @@ static void child_main(int child_num_arg) my_info->pid = my_child_num; my_info->tid = i; my_info->sd = 0; - ap_create_pool(&my_info->tpool, pchild); + apr_create_pool(&my_info->tpool, pchild); /* We are creating threads right now */ (void) ap_update_child_status(my_child_num, i, SERVER_STARTING, @@ -780,7 +780,7 @@ static int make_child(server_rec *s, int slot, time_t now) RAISE_SIGSTOP(MAKE_CHILD); - ap_signal(SIGTERM, just_die); + apr_signal(SIGTERM, just_die); child_main(slot); return 0; @@ -829,8 +829,8 @@ static void perform_idle_server_maintenance(void) int free_slots[MAX_SPAWN_RATE]; int last_non_dead; int total_non_dead; - ap_ssize_t one = 1; - ap_status_t rv; + apr_ssize_t one = 1; + apr_status_t rv; /* initialize the free_list */ free_length = 0; @@ -885,7 +885,7 @@ static void perform_idle_server_maintenance(void) if (idle_thread_count > max_spare_threads) { /* Kill off one child */ char char_of_death = '!'; - if ((rv = ap_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { + if ((rv = apr_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, "write pipe_of_death"); } idle_spawn_rate = 1; @@ -938,7 +938,7 @@ static void server_main_loop(int remaining_children_to_start) { int child_slot; ap_wait_t status; - ap_proc_t pid; + apr_proc_t pid; int i; while (!restart_pending && !shutdown_pending) { @@ -963,7 +963,7 @@ static void server_main_loop(int remaining_children_to_start) } #if APR_HAS_OTHER_CHILD } - else if (ap_reap_other_child(&pid, status) == 0) { + else if (apr_reap_other_child(&pid, status) == 0) { /* handled */ #endif } @@ -1001,26 +1001,26 @@ static void server_main_loop(int remaining_children_to_start) } } -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_children_to_start; - ap_status_t rv; - ap_ssize_t one = 1; + apr_status_t rv; + apr_ssize_t one = 1; pconf = _pconf; ap_server_conf = s; - rv = ap_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf); + rv = apr_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_create_pipe (pipe_of_death)"); + "apr_create_pipe (pipe_of_death)"); exit(1); } - if ((rv = ap_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { + if ((rv = apr_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_set_pipe_timeout (pipe_of_death)"); + "apr_set_pipe_timeout (pipe_of_death)"); exit(1); } ap_server_conf = s; @@ -1033,10 +1033,10 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) ap_log_pid(pconf, ap_pid_fname); /* Initialize cross-process accept lock */ - lock_fname = ap_psprintf(_pconf, "%s.%u", + lock_fname = apr_psprintf(_pconf, "%s.%u", ap_server_root_relative(_pconf, lock_fname), ap_my_pid); - rv = ap_create_lock(&process_accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, + rv = apr_create_lock(&process_accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, lock_fname, _pconf); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, @@ -1112,7 +1112,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* we've been told to restart */ - ap_signal(SIGHUP, SIG_IGN); + apr_signal(SIGHUP, SIG_IGN); if (one_process) { /* not worth thinking about */ @@ -1136,8 +1136,8 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) /* give the children the signal to die */ for (i = 0; i < ap_daemons_limit;) { - if ((rv = ap_write(pipe_of_death_in, &char_of_death, &one)) != APR_SUCCESS) { - if (ap_canonical_error(rv) == APR_EINTR) continue; + if ((rv = apr_write(pipe_of_death_in, &char_of_death, &one)) != APR_SUCCESS) { + if (apr_canonical_error(rv) == APR_EINTR) continue; ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, "write pipe_of_death"); } i++; @@ -1173,7 +1173,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) return 0; } -static void mpmt_pthread_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp) +static void mpmt_pthread_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; int no_detach = 0; @@ -1186,7 +1186,7 @@ static void mpmt_pthread_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t is_graceful = 0; if (!one_process && !no_detach) { - ap_detach(); + apr_detach(); } ap_my_pid = getpid(); } @@ -1204,7 +1204,7 @@ static void mpmt_pthread_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; ap_extended_status = 0; - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } static void mpmt_pthread_hooks(void) @@ -1372,7 +1372,7 @@ static const char *set_max_requests(cmd_parms *cmd, void *dummy, static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1380,12 +1380,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1422,7 +1422,7 @@ module MODULE_VAR_EXPORT mpm_mpmt_pthread_module = { NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ - mpmt_pthread_cmds, /* command ap_table_t */ + mpmt_pthread_cmds, /* command apr_table_t */ NULL, /* handlers */ mpmt_pthread_hooks /* register_hooks */ }; diff --git a/server/mpm/mpmt_pthread/scoreboard.c b/server/mpm/mpmt_pthread/scoreboard.c index 456dff247a..22e37745ca 100644 --- a/server/mpm/mpmt_pthread/scoreboard.c +++ b/server/mpm/mpmt_pthread/scoreboard.c @@ -88,49 +88,49 @@ static int maintain_connection_status = 1; #if APR_HAS_SHARED_MEMORY #include "apr_shmem.h" -static ap_shmem_t *scoreboard_shm = NULL; +static apr_shmem_t *scoreboard_shm = NULL; -ap_status_t ap_cleanup_shared_mem(void *d) +apr_status_t ap_cleanup_shared_mem(void *d) { - ap_shm_free(scoreboard_shm, ap_scoreboard_image); + apr_shm_free(scoreboard_shm, ap_scoreboard_image); ap_scoreboard_image = NULL; - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); return APR_SUCCESS; } -static void setup_shared_mem(ap_pool_t *p) +static void setup_shared_mem(apr_pool_t *p) { char buf[512]; const char *fname; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { - ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", + if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", ap_server_argv0); perror(buf); exit(APEXIT_INIT); } - ap_scoreboard_image = ap_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); - ap_new_scoreboard_image = ap_shm_malloc(scoreboard_shm, NEW_SCOREBOARD_SIZE); + ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); + ap_new_scoreboard_image = apr_shm_malloc(scoreboard_shm, NEW_SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL || ap_new_scoreboard_image == NULL) { - ap_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", + apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); perror(buf); - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); exit(APEXIT_INIT); } - ap_register_cleanup(p, NULL, ap_cleanup_shared_mem, ap_null_cleanup); + apr_register_cleanup(p, NULL, ap_cleanup_shared_mem, apr_null_cleanup); ap_scoreboard_image->global.running_generation = 0; } -void reopen_scoreboard(ap_pool_t *p) +void reopen_scoreboard(apr_pool_t *p) { } #endif /* APR_SHARED_MEM */ /* Called by parent process */ -void reinit_scoreboard(ap_pool_t *p) +void reinit_scoreboard(apr_pool_t *p) { int running_gen = 0; if (ap_scoreboard_image) @@ -206,7 +206,7 @@ void increment_counts(int child_num, int thread_num, request_rec *r) } -API_EXPORT(int) find_child_by_pid(ap_proc_t *pid) +API_EXPORT(int) find_child_by_pid(apr_proc_t *pid) { int i; int max_daemons_limit = ap_get_max_daemons(); @@ -253,15 +253,15 @@ int ap_update_child_status(int child_num, int thread_num, int status, request_re } if (r) { conn_rec *c = r->connection; - ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, + apr_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, REMOTE_NOLOOKUP), sizeof(ss->client)); if (r->the_request == NULL) { - ap_cpystrn(ss->request, "NULL", sizeof(ss->request)); + apr_cpystrn(ss->request, "NULL", sizeof(ss->request)); } else if (r->parsed_uri.password == NULL) { - ap_cpystrn(ss->request, r->the_request, sizeof(ss->request)); + apr_cpystrn(ss->request, r->the_request, sizeof(ss->request)); } else { /* Don't reveal the password in the server-status view */ - ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ", + apr_cpystrn(ss->request, apr_pstrcat(r->pool, r->method, " ", ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD), r->assbackwards ? NULL : " ", r->protocol, NULL), sizeof(ss->request)); @@ -284,10 +284,10 @@ void ap_time_process_request(int child_num, int thread_num, int status) ss = &ap_scoreboard_image->servers[child_num][thread_num]; if (status == START_PREQUEST) { - ss->start_time = ap_now(); + ss->start_time = apr_now(); } else if (status == STOP_PREQUEST) { - ss->stop_time = ap_now(); + ss->stop_time = apr_now(); } put_scoreboard_info(child_num, thread_num, ss); } @@ -326,41 +326,41 @@ const char *ap_get_connection_status(long conn_id, const char *key) return NULL; } -ap_array_header_t *ap_get_connections(ap_pool_t *p) +apr_array_header_t *ap_get_connections(apr_pool_t *p) { int i; - ap_array_header_t *connection_list; + apr_array_header_t *connection_list; long *array_slot; int max_daemons_limit = ap_get_max_daemons(); - connection_list = ap_make_array(p, 0, sizeof(long)); + connection_list = apr_make_array(p, 0, sizeof(long)); /* We assume that there is a connection iff it has an entry in the status * table. Connections without any status sound problematic to me, so this * is probably for the best. - manoj */ for (i = 0; i < max_daemons_limit*HARD_THREAD_LIMIT; i++) { if (ap_new_scoreboard_image->table[i][0].key[0] != '\0') { - array_slot = ap_push_array(connection_list); + array_slot = apr_push_array(connection_list); *array_slot = i; } } return connection_list; } -ap_array_header_t *ap_get_connection_keys(ap_pool_t *p, long conn_id) +apr_array_header_t *ap_get_connection_keys(apr_pool_t *p, long conn_id) { int i = 0; status_table_entry *ss; - ap_array_header_t *key_list; + apr_array_header_t *key_list; char **array_slot; - key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char)); + key_list = apr_make_array(p, 0, KEY_LENGTH * sizeof(char)); while (i < STATUSES_PER_CONNECTION) { ss = &(ap_new_scoreboard_image->table[conn_id][i]); if (ss->key[0] == '\0') { break; } - array_slot = ap_push_array(key_list); - *array_slot = ap_pstrdup(p, ss->key); + array_slot = apr_push_array(key_list); + *array_slot = apr_pstrdup(p, ss->key); i++; } return key_list; @@ -381,7 +381,7 @@ void ap_update_connection_status(long conn_id, const char *key, ss = &(ap_new_scoreboard_image->table[conn_id][i]); if (ss->key[0] == '\0') { break; } if (0 == strcmp(ss->key, key)) { - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } i++; @@ -391,20 +391,20 @@ void ap_update_connection_status(long conn_id, const char *key, /* No room. Oh well, not much anyone can do about it. */ return; } - ap_cpystrn(ss->key, key, KEY_LENGTH); - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->key, key, KEY_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } -ap_array_header_t *ap_get_status_table(ap_pool_t *p) +apr_array_header_t *ap_get_status_table(apr_pool_t *p) { int i, j; - ap_array_header_t *server_status; + apr_array_header_t *server_status; ap_status_table_row_t *array_slot; int max_daemons_limit = ap_get_max_daemons(); status_table_entry *ss; - server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t)); + server_status = apr_make_array(p, 0, sizeof(ap_status_table_row_t)); /* Go ahead and return what's in the connection status table even if we * aren't maintaining it. We can at least look at what children from @@ -413,14 +413,14 @@ ap_array_header_t *ap_get_status_table(ap_pool_t *p) for (i = 0; i < max_daemons_limit*HARD_THREAD_LIMIT; i++) { if (ap_new_scoreboard_image->table[i][0].key[0] == '\0') continue; - array_slot = ap_push_array(server_status); - array_slot->data = ap_make_table(p, 0); + array_slot = apr_push_array(server_status); + array_slot->data = apr_make_table(p, 0); array_slot->conn_id = i; for (j = 0; j < STATUSES_PER_CONNECTION; j++) { ss = &(ap_new_scoreboard_image->table[i][j]); if (ss->key[0] != '\0') { - ap_table_add(array_slot->data, ss->key, ss->value); + apr_table_add(array_slot->data, ss->key, ss->value); } else { break; diff --git a/server/mpm/mpmt_pthread/scoreboard.h b/server/mpm/mpmt_pthread/scoreboard.h index 21e37e34dd..822ae8b6e1 100644 --- a/server/mpm/mpmt_pthread/scoreboard.h +++ b/server/mpm/mpmt_pthread/scoreboard.h @@ -152,8 +152,8 @@ typedef struct { unsigned long my_bytes_served; unsigned long conn_bytes; unsigned short conn_count; - ap_time_t start_time; - ap_time_t stop_time; + apr_time_t start_time; + apr_time_t stop_time; #ifdef HAVE_TIMES struct tms times; #endif @@ -210,17 +210,17 @@ typedef struct { #endif API_EXPORT(int) ap_exists_scoreboard_image(void); -void reinit_scoreboard(ap_pool_t *p); -ap_status_t ap_cleanup_shared_mem(void *d); +void reinit_scoreboard(apr_pool_t *p); +apr_status_t ap_cleanup_shared_mem(void *d); API_EXPORT(void) ap_sync_scoreboard_image(void); void ap_mpmt_pthread_force_reset_connection_status(long conn_id); -API_EXPORT(void) reopen_scoreboard(ap_pool_t *p); +API_EXPORT(void) reopen_scoreboard(apr_pool_t *p); ap_inline void ap_sync_scoreboard_image(void); void increment_counts(int child_num, int thread_num, request_rec *r); void update_scoreboard_global(void); -API_EXPORT(int) find_child_by_pid(ap_proc_t *pid); +API_EXPORT(int) find_child_by_pid(apr_proc_t *pid); int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r); void ap_time_process_request(int child_num, int thread_num, int status); diff --git a/server/mpm/perchild/perchild.c b/server/mpm/perchild/perchild.c index 32c1a4d513..5e8d3ae0bd 100644 --- a/server/mpm/perchild/perchild.c +++ b/server/mpm/perchild/perchild.c @@ -74,7 +74,7 @@ #include "unixd.h" #include "mpm_common.h" #include "ap_iol.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "mpm_default.h" #include "mpm.h" #include "scoreboard.h" @@ -113,7 +113,7 @@ static int socket_num=0; static int workers_may_exit = 0; static int requests_this_child; static int num_listenfds = 0; -static ap_socket_t **listenfds; +static apr_socket_t **listenfds; struct child_info_t { uid_t uid; @@ -140,7 +140,7 @@ typedef struct socket_info_t socket_info_t; * process. */ static child_info_t child_info_table[HARD_SERVER_LIMIT]; -static ap_hash_t *socket_info_table = NULL; +static apr_hash_t *socket_info_table = NULL; struct ap_ctable ap_child_table[HARD_SERVER_LIMIT]; @@ -159,8 +159,8 @@ char ap_coredump_dir[MAX_STRING_LEN]; module MODULE_VAR_EXPORT mpm_perchild_module; -static ap_file_t *pipe_of_death_in = NULL; -static ap_file_t *pipe_of_death_out = NULL; +static apr_file_t *pipe_of_death_in = NULL; +static apr_file_t *pipe_of_death_out = NULL; static pthread_mutex_t pipe_of_death_mutex; /* *Non*-shared http_main globals... */ @@ -184,9 +184,9 @@ static int one_process = 0; int raise_sigstop_flags; #endif -static ap_pool_t *pconf; /* Pool for config stuff */ -static ap_pool_t *pchild; /* Pool for httpd child stuff */ -static ap_pool_t *thread_pool_parent; /* Parent of per-thread pools */ +static apr_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pchild; /* Pool for httpd child stuff */ +static apr_pool_t *thread_pool_parent; /* Parent of per-thread pools */ static pthread_mutex_t thread_pool_parent_mutex; static int child_num; @@ -207,7 +207,7 @@ static pthread_mutex_t idle_thread_count_mutex; #define SAFE_ACCEPT(stmt) APR_SUCCESS #else #define SAFE_ACCEPT(stmt) (stmt) -static ap_lock_t *process_accept_mutex; +static apr_lock_t *process_accept_mutex; #endif /* NO_SERIALIZED_ACCEPT */ static const char *lock_fname; static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -221,7 +221,7 @@ API_EXPORT(int) ap_get_max_daemons(void) static void clean_child_exit(int code) { if (pchild) { - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); } exit(code); } @@ -230,7 +230,7 @@ static void clean_child_exit(int code) static void sig_coredump(int sig) { chdir(ap_coredump_dir); - ap_signal(sig, SIG_DFL); + apr_signal(sig, SIG_DFL); kill(getpid(), sig); /* At this point we've got sig blocked, because we're still inside * the signal handler. When we leave the signal handler it will @@ -297,7 +297,7 @@ static void ap_start_restart(int graceful) restart_pending = 1; is_graceful = graceful; if (is_graceful) { - ap_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); + apr_kill_cleanup(pconf, NULL, ap_cleanup_shared_mem); } } @@ -383,36 +383,36 @@ static void set_signals(void) ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGWINCH)"); #else if (!one_process) { - ap_signal(SIGSEGV, sig_coredump); + apr_signal(SIGSEGV, sig_coredump); #ifdef SIGBUS - ap_signal(SIGBUS, sig_coredump); + apr_signal(SIGBUS, sig_coredump); #endif /* SIGBUS */ #ifdef SIGABORT - ap_signal(SIGABORT, sig_coredump); + apr_signal(SIGABORT, sig_coredump); #endif /* SIGABORT */ #ifdef SIGABRT - ap_signal(SIGABRT, sig_coredump); + apr_signal(SIGABRT, sig_coredump); #endif /* SIGABRT */ #ifdef SIGILL - ap_signal(SIGILL, sig_coredump); + apr_signal(SIGILL, sig_coredump); #endif /* SIGILL */ #ifdef SIGXCPU - ap_signal(SIGXCPU, SIG_DFL); + apr_signal(SIGXCPU, SIG_DFL); #endif /* SIGXCPU */ #ifdef SIGXFSZ - ap_signal(SIGXFSZ, SIG_DFL); + apr_signal(SIGXFSZ, SIG_DFL); #endif /* SIGXFSZ */ } - ap_signal(SIGTERM, sig_term); + apr_signal(SIGTERM, sig_term); #ifdef SIGHUP - ap_signal(SIGHUP, restart); + apr_signal(SIGHUP, restart); #endif /* SIGHUP */ #ifdef SIGWINCH - ap_signal(SIGWINCH, restart); + apr_signal(SIGWINCH, restart); #endif /* SIGWINCH */ #ifdef SIGPIPE - ap_signal(SIGPIPE, SIG_IGN); + apr_signal(SIGPIPE, SIG_IGN); #endif /* SIGPIPE */ #endif @@ -432,16 +432,16 @@ int ap_graceful_stop_signalled(void) * Child process main loop. */ -static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id) +static void process_socket(apr_pool_t *p, apr_socket_t *sock, long conn_id) { BUFF *conn_io; conn_rec *current_conn; ap_iol *iol; int csd; - ap_status_t rv; + apr_status_t rv; - if ((rv = ap_get_os_sock(&csd, sock)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_get_os_sock"); + if ((rv = apr_get_os_sock(&csd, sock)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "apr_get_os_sock"); } if (csd >= FD_SETSIZE) { @@ -450,7 +450,7 @@ static void process_socket(ap_pool_t *p, ap_socket_t *sock, long conn_id) "to rebuild Apache with a larger FD_SETSIZE " "(currently %d)", csd, FD_SETSIZE); - ap_close_socket(sock); + apr_close_socket(sock); return; } @@ -518,10 +518,10 @@ static void check_pipe_of_death(void) if (!workers_may_exit) { int ret; char pipe_read_char; - ap_ssize_t n = 1; + apr_ssize_t n = 1; - ret = ap_recv(listenfds[0], &pipe_read_char, &n); - if (ap_canonical_error(ret) == APR_EAGAIN) { + ret = apr_recv(listenfds[0], &pipe_read_char, &n); + if (apr_canonical_error(ret) == APR_EAGAIN) { /* It lost the lottery. It must continue to suffer * through a life of servitude. */ } @@ -538,27 +538,27 @@ static void check_pipe_of_death(void) static void *worker_thread(void *arg) { - ap_socket_t *csd = NULL; - ap_pool_t *tpool; /* Pool for this thread */ - ap_pool_t *ptrans; /* Pool for per-transaction stuff */ - ap_socket_t *sd = NULL; + apr_socket_t *csd = NULL; + apr_pool_t *tpool; /* Pool for this thread */ + apr_pool_t *ptrans; /* Pool for per-transaction stuff */ + apr_socket_t *sd = NULL; int srv; int curr_pollfd, last_pollfd = 0; int thread_just_started = 1; int thread_num = *((int *) arg); long conn_id = child_num * HARD_THREAD_LIMIT + thread_num; - ap_pollfd_t *pollset; + apr_pollfd_t *pollset; int n; - ap_status_t rv; + apr_status_t rv; pthread_mutex_lock(&thread_pool_parent_mutex); - ap_create_pool(&tpool, thread_pool_parent); + apr_create_pool(&tpool, thread_pool_parent); pthread_mutex_unlock(&thread_pool_parent_mutex); - ap_create_pool(&ptrans, tpool); + apr_create_pool(&ptrans, tpool); - ap_setup_poll(&pollset, num_listenfds+1, tpool); + apr_setup_poll(&pollset, num_listenfds+1, tpool); for(n=0 ; n <= num_listenfds ; ++n) { - ap_add_poll_socket(pollset, listenfds[n], APR_POLLIN); + apr_add_poll_socket(pollset, listenfds[n], APR_POLLIN); } while (!workers_may_exit) { @@ -583,32 +583,32 @@ static void *worker_thread(void *arg) pthread_mutex_unlock(&thread_accept_mutex); break; } - if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_lock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_lock failed. Attempting to shutdown " + "apr_lock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } while (!workers_may_exit) { - ap_int16_t event; - srv = ap_poll(pollset, &n, -1); + apr_int16_t event; + srv = apr_poll(pollset, &n, -1); if (srv != APR_SUCCESS) { - if (ap_canonical_error(srv) == APR_EINTR) { + if (apr_canonical_error(srv) == APR_EINTR) { continue; } - /* ap_poll() will only return errors in catastrophic + /* apr_poll() will only return errors in catastrophic * circumstances. Let's try exiting gracefully, for now. */ ap_log_error(APLOG_MARK, APLOG_ERR, srv, (const server_rec *) - ap_server_conf, "ap_poll: (listen)"); + ap_server_conf, "apr_poll: (listen)"); workers_may_exit = 1; } if (workers_may_exit) break; - ap_get_revents(&event, listenfds[0], pollset); + apr_get_revents(&event, listenfds[0], pollset); if (event & APR_POLLIN) { /* A process got a signal on the shutdown pipe. Check if we're * the lucky process to die. */ @@ -629,7 +629,7 @@ static void *worker_thread(void *arg) curr_pollfd = 1; } /* XXX: Should we check for POLLERR? */ - ap_get_revents(&event, listenfds[curr_pollfd], pollset); + apr_get_revents(&event, listenfds[curr_pollfd], pollset); if (event & APR_POLLIN) { last_pollfd = curr_pollfd; sd = listenfds[curr_pollfd]; @@ -640,13 +640,13 @@ static void *worker_thread(void *arg) } got_fd: if (!workers_may_exit) { - if ((rv = ap_accept(&csd, sd, ptrans)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "ap_accept"); + if ((rv = apr_accept(&csd, sd, ptrans)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, ap_server_conf, "apr_accept"); } - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } @@ -664,10 +664,10 @@ static void *worker_thread(void *arg) process_socket(ptrans, csd, conn_id); requests_this_child--; } else { - if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex))) + if ((rv = SAFE_ACCEPT(apr_unlock(process_accept_mutex))) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, - "ap_unlock failed. Attempting to shutdown " + "apr_unlock failed. Attempting to shutdown " "process gracefully."); workers_may_exit = 1; } @@ -677,11 +677,11 @@ static void *worker_thread(void *arg) pthread_mutex_unlock(&idle_thread_count_mutex); break; } - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); } pthread_mutex_lock(&thread_pool_parent_mutex); - ap_destroy_pool(tpool); + apr_destroy_pool(tpool); pthread_mutex_unlock(&thread_pool_parent_mutex); pthread_mutex_lock(&worker_thread_count_mutex); worker_thread_count--; @@ -770,7 +770,7 @@ static int perchild_setup_child(int childnum) return 0; } -static int create_child_socket(int child_num, ap_pool_t *p) +static int create_child_socket(int child_num, apr_pool_t *p) { struct sockaddr_un unix_addr; mode_t omask; @@ -779,9 +779,9 @@ static int create_child_socket(int child_num, ap_pool_t *p) perchild_server_conf *sconf = (perchild_server_conf *) ap_get_module_config(ap_server_conf->module_config, &mpm_perchild_module); int len = strlen(sconf->sockname) + strlen(child_info_table[child_num].name) + 3; - char *socket_name = ap_palloc(p, len); + char *socket_name = apr_palloc(p, len); - ap_snprintf(socket_name, len, "%s.%s", sconf->sockname, child_info_table[child_num].name); + apr_snprintf(socket_name, len, "%s.%s", sconf->sockname, child_info_table[child_num].name); if (unlink(socket_name) < 0 && errno != ENOENT) { ap_log_error(APLOG_MARK, APLOG_ERR, errno, ap_server_conf, @@ -833,15 +833,15 @@ static void child_main(int child_num_arg) int signal_received; int i; ap_listen_rec *lr; - ap_status_t rv; + apr_status_t rv; my_pid = getpid(); child_num = child_num_arg; - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); /*stuff to do before we switch id's, so we have permissions.*/ - rv = SAFE_ACCEPT(ap_child_init_lock(&process_accept_mutex, lock_fname, + rv = SAFE_ACCEPT(apr_child_init_lock(&process_accept_mutex, lock_fname, pchild)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf, @@ -879,13 +879,13 @@ static void child_main(int child_num_arg) /* Set up the pollfd array, num_listenfds + 1 for the pipe and 1 for * the child socket. */ - listenfds = ap_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 2)); + listenfds = apr_pcalloc(pchild, sizeof(*listenfds) * (num_listenfds + 2)); #if APR_FILES_AS_SOCKETS - ap_socket_from_file(&listenfds[0], pipe_of_death_in); + apr_socket_from_file(&listenfds[0], pipe_of_death_in); #endif /* The child socket */ - ap_put_os_sock(&listenfds[1], &child_info_table[child_num].sd, pchild); + apr_put_os_sock(&listenfds[1], &child_info_table[child_num].sd, pchild); num_listenfds++; for (lr = ap_listeners, i = 2; i <= num_listenfds; lr = lr->next, ++i) @@ -901,7 +901,7 @@ static void child_main(int child_num_arg) for (i = 0; i < max_threads; i++) { worker_thread_free_ids[i] = i; } - ap_create_pool(&thread_pool_parent, pchild); + apr_create_pool(&thread_pool_parent, pchild); pthread_mutex_init(&thread_pool_parent_mutex, NULL); pthread_mutex_init(&idle_thread_count_mutex, NULL); pthread_mutex_init(&worker_thread_count_mutex, NULL); @@ -984,7 +984,7 @@ static int make_child(server_rec *s, int slot, time_t now) RAISE_SIGSTOP(MAKE_CHILD); /* XXX - For an unthreaded server, a signal handler will be necessary - ap_signal(SIGTERM, just_die); + apr_signal(SIGTERM, just_die); */ child_main(slot); @@ -1078,7 +1078,7 @@ static void server_main_loop(int remaining_children_to_start) { int child_slot; ap_wait_t status; - ap_proc_t pid; + apr_proc_t pid; int i; while (!restart_pending && !shutdown_pending) { @@ -1113,7 +1113,7 @@ static void server_main_loop(int remaining_children_to_start) } #if APR_HAS_OTHER_CHILD } - else if (ap_reap_other_child(&pid, status) == 0) { + else if (apr_reap_other_child(&pid, status) == 0) { /* handled */ #endif } @@ -1152,26 +1152,26 @@ static void server_main_loop(int remaining_children_to_start) } } -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_children_to_start; int i; - ap_status_t rv; - ap_ssize_t one = 1; + apr_status_t rv; + apr_ssize_t one = 1; pconf = _pconf; ap_server_conf = s; - if ((rv = ap_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf)) + if ((rv = apr_create_pipe(&pipe_of_death_in, &pipe_of_death_out, pconf)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_create_pipe (pipe_of_death)"); + "apr_create_pipe (pipe_of_death)"); exit(1); } - if ((rv = ap_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { + if ((rv = apr_set_pipe_timeout(pipe_of_death_in, 0)) != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR, rv, (const server_rec*) ap_server_conf, - "ap_set_pipe_timeout (pipe_of_death)"); + "apr_set_pipe_timeout (pipe_of_death)"); exit(1); } ap_server_conf = s; @@ -1205,10 +1205,10 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* Initialize cross-process accept lock */ - lock_fname = ap_psprintf(_pconf, "%s.%u", + lock_fname = apr_psprintf(_pconf, "%s.%u", ap_server_root_relative(_pconf, lock_fname), my_pid); - rv = SAFE_ACCEPT(ap_create_lock(&process_accept_mutex, APR_MUTEX, + rv = SAFE_ACCEPT(apr_create_lock(&process_accept_mutex, APR_MUTEX, APR_CROSS_PROCESS, lock_fname, _pconf)); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, @@ -1284,7 +1284,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* we've been told to restart */ - ap_signal(SIGHUP, SIG_IGN); + apr_signal(SIGHUP, SIG_IGN); if (one_process) { /* not worth thinking about */ @@ -1308,8 +1308,8 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* give the children the signal to die */ for (i = 0; i < num_daemons;) { - if ((rv = ap_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { - if (ap_canonical_error(rv) == APR_EINTR) continue; + if ((rv = apr_write(pipe_of_death_out, &char_of_death, &one)) != APR_SUCCESS) { + if (apr_canonical_error(rv) == APR_EINTR) continue; ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, "write pipe_of_death"); } @@ -1332,7 +1332,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) return 0; } -static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) +static void perchild_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; int no_detach = 0; @@ -1346,7 +1346,7 @@ static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) is_graceful = 0; if (!one_process && !no_detach) { - ap_detach(); + apr_detach(); } my_pid = getpid(); @@ -1367,7 +1367,7 @@ static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) curr_child_num = 0; socket_num = 0; - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); for (i = 0; i < HARD_SERVER_LIMIT; i++) { child_info_table[i].uid = -1; @@ -1377,13 +1377,13 @@ static void perchild_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) } } -static void perchild_post_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp, server_rec *s) +static void perchild_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { int i; for (i = 0; i < num_daemons; i++) { if (child_info_table[i].name == NULL) { - child_info_table[i].name = ap_pstrdup(p, "DEFAULT"); + child_info_table[i].name = apr_pstrdup(p, "DEFAULT"); child_info_table[i].num = socket_num; } } @@ -1391,13 +1391,13 @@ static void perchild_post_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp static int perchild_post_read(request_rec *r) { - const char *hostname = ap_table_get(r->headers_in, "Host"); + const char *hostname = apr_table_get(r->headers_in, "Host"); char *process_num; int num; fprintf(stderr, "In perchild_post_read\n"); fflush(stderr); - process_num = ap_hash_get(socket_info_table, hostname, 0); + process_num = apr_hash_get(socket_info_table, hostname, 0); if (process_num) { num = atoi(process_num); } @@ -1603,7 +1603,7 @@ static const char *set_maintain_connection_status(cmd_parms *cmd, static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1611,12 +1611,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1635,7 +1635,7 @@ static const char *set_child_per_uid(cmd_parms *cmd, void *dummy, const char *u, ug->uid = atoi(u); ug->gid = atoi(g); - ug->name = ap_pstrcat(cmd->pool, u, ":", g, NULL); + ug->name = apr_pstrcat(cmd->pool, u, ":", g, NULL); ug->num = socket_num; } socket_num++; @@ -1652,7 +1652,7 @@ static const char *set_socket_name(cmd_parms *cmd, void *dummy, const char *arg) return NULL; } -static ap_status_t cleanup_hash(void *dptr) +static apr_status_t cleanup_hash(void *dptr) { socket_info_table = NULL; return APR_SUCCESS; @@ -1661,12 +1661,12 @@ static ap_status_t cleanup_hash(void *dptr) static const char *assign_childuid(cmd_parms *cmd, void *dummy, const char *uid, const char *gid) { - char *socketname = ap_pstrcat(cmd->pool, uid, ":", gid, NULL); + char *socketname = apr_pstrcat(cmd->pool, uid, ":", gid, NULL); if (socket_info_table == NULL) { - socket_info_table = ap_make_hash(cmd->pool); - ap_register_cleanup(cmd->pool, socket_info_table, cleanup_hash, NULL); + socket_info_table = apr_make_hash(cmd->pool); + apr_register_cleanup(cmd->pool, socket_info_table, cleanup_hash, NULL); } - ap_hash_set(socket_info_table, cmd->server->server_hostname, 0, socketname); + apr_hash_set(socket_info_table, cmd->server->server_hostname, 0, socketname); return NULL; } @@ -1707,10 +1707,10 @@ AP_INIT_TAKE1("ChildSockName", set_socket_name, NULL, RSRC_CONF, { NULL } }; -static void *perchild_create_config(ap_pool_t *p, server_rec *s) +static void *perchild_create_config(apr_pool_t *p, server_rec *s) { perchild_server_conf *c = - (perchild_server_conf *) ap_pcalloc(p, sizeof(perchild_server_conf)); + (perchild_server_conf *) apr_pcalloc(p, sizeof(perchild_server_conf)); c->sockname = ap_server_root_relative(p, DEFAULT_PERCHILD_SOCKET); return c; @@ -1723,7 +1723,7 @@ module MODULE_VAR_EXPORT mpm_perchild_module = { NULL, /* merge per-directory config structures */ perchild_create_config, /* create per-server config structure */ NULL, /* merge per-server config structures */ - perchild_cmds, /* command ap_table_t */ + perchild_cmds, /* command apr_table_t */ NULL, /* handlers */ perchild_hooks /* register_hooks */ }; diff --git a/server/mpm/perchild/scoreboard.c b/server/mpm/perchild/scoreboard.c index b44d29e260..5700349b8f 100644 --- a/server/mpm/perchild/scoreboard.c +++ b/server/mpm/perchild/scoreboard.c @@ -86,40 +86,40 @@ static scoreboard *ap_scoreboard_image = NULL; #if APR_HAS_SHARED_MEMORY #include "apr_shmem.h" -static ap_shmem_t *scoreboard_shm = NULL; +static apr_shmem_t *scoreboard_shm = NULL; -ap_status_t ap_cleanup_shared_mem(void *d) +apr_status_t ap_cleanup_shared_mem(void *d) { - ap_shm_free(scoreboard_shm, ap_scoreboard_image); + apr_shm_free(scoreboard_shm, ap_scoreboard_image); ap_scoreboard_image = NULL; - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); return APR_SUCCESS; } -static void setup_shared_mem(ap_pool_t *p) +static void setup_shared_mem(apr_pool_t *p) { char buf[512]; const char *fname; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { - ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", + if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", ap_server_argv0); perror(buf); exit(APEXIT_INIT); } - ap_scoreboard_image = ap_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); + ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL) { - ap_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", + apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); perror(buf); - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); exit(APEXIT_INIT); } - ap_register_cleanup(p, NULL, ap_cleanup_shared_mem, ap_null_cleanup); + apr_register_cleanup(p, NULL, ap_cleanup_shared_mem, apr_null_cleanup); } -void reinit_scoreboard(ap_pool_t *p) +void reinit_scoreboard(apr_pool_t *p) { if (ap_scoreboard_image == NULL) { setup_shared_mem(p); @@ -177,40 +177,40 @@ const char *ap_get_connection_status(long conn_id, const char *key) return NULL; } -ap_array_header_t *ap_get_connections(ap_pool_t *p) +apr_array_header_t *ap_get_connections(apr_pool_t *p) { int i; - ap_array_header_t *connection_list; + apr_array_header_t *connection_list; long *array_slot; - connection_list = ap_make_array(p, 0, sizeof(long)); + connection_list = apr_make_array(p, 0, sizeof(long)); /* We assume that there is a connection iff it has an entry in the status * table. Connections without any status sound problematic to me, so this * is probably for the best. - manoj */ for (i = 0; i < ap_max_daemons_limit*HARD_THREAD_LIMIT; i++) { if (ap_scoreboard_image->table[i][0].key[0] != '\0') { - array_slot = ap_push_array(connection_list); + array_slot = apr_push_array(connection_list); *array_slot = i; } } return connection_list; } -ap_array_header_t *ap_get_connection_keys(ap_pool_t *p, long conn_id) +apr_array_header_t *ap_get_connection_keys(apr_pool_t *p, long conn_id) { int i = 0; status_table_entry *ss; - ap_array_header_t *key_list; + apr_array_header_t *key_list; char **array_slot; - key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char)); + key_list = apr_make_array(p, 0, KEY_LENGTH * sizeof(char)); while (i < STATUSES_PER_CONNECTION) { ss = &(ap_scoreboard_image->table[conn_id][i]); if (ss->key[0] == '\0') { break; } - array_slot = ap_push_array(key_list); - *array_slot = ap_pstrdup(p, ss->key); + array_slot = apr_push_array(key_list); + *array_slot = apr_pstrdup(p, ss->key); i++; } return key_list; @@ -233,7 +233,7 @@ void ap_update_connection_status(long conn_id, const char *key, break; } if (0 == strcmp(ss->key, key)) { - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } i++; @@ -243,19 +243,19 @@ void ap_update_connection_status(long conn_id, const char *key, /* No room. Oh well, not much anyone can do about it. */ return; } - ap_cpystrn(ss->key, key, KEY_LENGTH); - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->key, key, KEY_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } -ap_array_header_t *ap_get_status_table(ap_pool_t *p) +apr_array_header_t *ap_get_status_table(apr_pool_t *p) { int i, j; - ap_array_header_t *server_status; + apr_array_header_t *server_status; ap_status_table_row_t *array_slot; status_table_entry *ss; - server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t)); + server_status = apr_make_array(p, 0, sizeof(ap_status_table_row_t)); /* Go ahead and return what's in the connection status table even if we * aren't maintaining it. We can at least look at what children from @@ -264,14 +264,14 @@ ap_array_header_t *ap_get_status_table(ap_pool_t *p) for (i = 0; i < ap_max_daemons_limit*HARD_THREAD_LIMIT; i++) { if (ap_scoreboard_image->table[i][0].key[0] == '\0') continue; - array_slot = ap_push_array(server_status); - array_slot->data = ap_make_table(p, 0); + array_slot = apr_push_array(server_status); + array_slot->data = apr_make_table(p, 0); array_slot->conn_id = i; for (j = 0; j < STATUSES_PER_CONNECTION; j++) { ss = &(ap_scoreboard_image->table[i][j]); if (ss->key[0] != '\0') { - ap_table_add(array_slot->data, ss->key, ss->value); + apr_table_add(array_slot->data, ss->key, ss->value); } else { break; diff --git a/server/mpm/perchild/scoreboard.h b/server/mpm/perchild/scoreboard.h index 9e15e6a5cc..ded7cdce72 100644 --- a/server/mpm/perchild/scoreboard.h +++ b/server/mpm/perchild/scoreboard.h @@ -72,9 +72,9 @@ extern "C" { #include "mpm_default.h" /* For HARD_.*_LIMIT */ /* The generic shared memory chunk code */ -void reinit_scoreboard(ap_pool_t *p); +void reinit_scoreboard(apr_pool_t *p); -API_EXPORT(void) reopen_scoreboard(ap_pool_t *p); +API_EXPORT(void) reopen_scoreboard(apr_pool_t *p); /* The stuff for perchild's status table */ @@ -99,7 +99,7 @@ typedef struct { #define SCOREBOARD_SIZE sizeof(scoreboard) API_VAR_EXPORT extern const char *ap_scoreboard_fname; -ap_status_t ap_cleanup_shared_mem(void *d); +apr_status_t ap_cleanup_shared_mem(void *d); #ifdef __cplusplus } diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c index 16a7425ea0..cf1f18aab4 100644 --- a/server/mpm/prefork/prefork.c +++ b/server/mpm/prefork/prefork.c @@ -104,7 +104,7 @@ #include "unixd.h" #include "mpm_common.h" #include "ap_iol.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "ap_mmn.h" #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -138,7 +138,7 @@ static int ap_max_requests_per_child=0; static const char *ap_pid_fname=NULL; -static ap_lock_t *accept_lock; +static apr_lock_t *accept_lock; static const char *ap_scoreboard_fname=NULL; static const char *ap_lock_fname; static int ap_daemons_to_start=0; @@ -161,7 +161,7 @@ char ap_coredump_dir[MAX_STRING_LEN]; /* *Non*-shared http_main globals... */ -static ap_socket_t *sd; +static apr_socket_t *sd; static fd_set listenfds; static int listenmaxfd; @@ -178,8 +178,8 @@ static int listenmaxfd; static int one_process = 0; -static ap_pool_t *pconf; /* Pool for config stuff */ -static ap_pool_t *pchild; /* Pool for httpd child stuff */ +static apr_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pchild; /* Pool for httpd child stuff */ int ap_my_pid; /* it seems silly to call getpid all the time */ #ifndef MULTITHREAD @@ -212,7 +212,7 @@ static void chdir_for_gprof(void) int len = strlen(sconf->gprof_dir) - 1; if(*(dir + len) == '%') { dir[len] = '\0'; - ap_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid()); + apr_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid()); } dir = ap_server_root_relative(pconf, buf[0] ? buf : dir); if(mkdir(dir, 0755) < 0 && errno != EEXIST) { @@ -239,27 +239,27 @@ static void clean_child_exit(int code) __attribute__ ((noreturn)); static void clean_child_exit(int code) { if (pchild) { - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); } chdir_for_gprof(); exit(code); } -static void expand_lock_fname(ap_pool_t *p) +static void expand_lock_fname(apr_pool_t *p) { /* XXXX possibly bogus cast */ - ap_lock_fname = ap_psprintf(p, "%s.%lu", + ap_lock_fname = apr_psprintf(p, "%s.%lu", ap_server_root_relative(p, ap_lock_fname), (unsigned long)getpid()); } /* Initialize mutex lock. * Done by each child at its birth */ -static void accept_mutex_child_init(ap_pool_t *p) +static void accept_mutex_child_init(apr_pool_t *p) { - ap_status_t rv; + apr_status_t rv; - rv = ap_child_init_lock(&accept_lock, ap_lock_fname, p); + rv = apr_child_init_lock(&accept_lock, ap_lock_fname, p); if (rv) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't do child init for accept mutex"); @@ -270,12 +270,12 @@ static void accept_mutex_child_init(ap_pool_t *p) /* Initialize mutex lock. * Must be safe to call this on a restart. */ -static void accept_mutex_init(ap_pool_t *p) +static void accept_mutex_init(apr_pool_t *p) { - ap_status_t rv; + apr_status_t rv; expand_lock_fname(p); - rv = ap_create_lock(&accept_lock, APR_MUTEX, APR_CROSS_PROCESS, ap_lock_fname, p); + rv = apr_create_lock(&accept_lock, APR_MUTEX, APR_CROSS_PROCESS, ap_lock_fname, p); if (rv) { ap_log_error(APLOG_MARK, APLOG_EMERG, rv, NULL, "couldn't create accept mutex"); exit(APEXIT_INIT); @@ -284,13 +284,13 @@ static void accept_mutex_init(ap_pool_t *p) static void accept_mutex_on(void) { - ap_status_t rv = ap_lock(accept_lock); + apr_status_t rv = apr_lock(accept_lock); ap_assert(!rv); } static void accept_mutex_off(void) { - ap_status_t rv = ap_unlock(accept_lock); + apr_status_t rv = apr_unlock(accept_lock); ap_assert(!rv); } @@ -308,48 +308,48 @@ static void accept_mutex_off(void) #if APR_HAS_SHARED_MEMORY #include "apr_shmem.h" -static ap_shmem_t *scoreboard_shm = NULL; +static apr_shmem_t *scoreboard_shm = NULL; -static ap_status_t cleanup_shared_mem(void *d) +static apr_status_t cleanup_shared_mem(void *d) { - ap_shm_free(scoreboard_shm, ap_scoreboard_image); + apr_shm_free(scoreboard_shm, ap_scoreboard_image); ap_scoreboard_image = NULL; - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); return APR_SUCCESS; } -static void setup_shared_mem(ap_pool_t *p) +static void setup_shared_mem(apr_pool_t *p) { char buf[512]; const char *fname; fname = ap_server_root_relative(p, ap_scoreboard_fname); - if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { - ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", + if (apr_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + NEW_SCOREBOARD_SIZE + 40, fname, p) != APR_SUCCESS) { + apr_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard", ap_server_argv0); perror(buf); exit(APEXIT_INIT); } - ap_scoreboard_image = ap_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); - ap_new_scoreboard_image = ap_shm_malloc(scoreboard_shm, NEW_SCOREBOARD_SIZE); + ap_scoreboard_image = apr_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE); + ap_new_scoreboard_image = apr_shm_malloc(scoreboard_shm, NEW_SCOREBOARD_SIZE); if (ap_scoreboard_image == NULL) { - ap_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", + apr_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard", ap_server_argv0); perror(buf); - ap_shm_destroy(scoreboard_shm); + apr_shm_destroy(scoreboard_shm); exit(APEXIT_INIT); } - ap_register_cleanup(p, NULL, cleanup_shared_mem, ap_null_cleanup); + apr_register_cleanup(p, NULL, cleanup_shared_mem, apr_null_cleanup); ap_scoreboard_image->global.running_generation = 0; } -static void reopen_scoreboard(ap_pool_t *p) +static void reopen_scoreboard(apr_pool_t *p) { } #endif /* Called by parent process */ -static void reinit_scoreboard(ap_pool_t *p) +static void reinit_scoreboard(apr_pool_t *p) { int running_gen = 0; if (ap_scoreboard_image) @@ -429,15 +429,15 @@ int ap_update_child_status(int child_num, int status, request_rec *r) } if (r) { conn_rec *c = r->connection; - ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, + apr_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, REMOTE_NOLOOKUP), sizeof(ss->client)); if (r->the_request == NULL) { - ap_cpystrn(ss->request, "NULL", sizeof(ss->request)); + apr_cpystrn(ss->request, "NULL", sizeof(ss->request)); } else if (r->parsed_uri.password == NULL) { - ap_cpystrn(ss->request, r->the_request, sizeof(ss->request)); + apr_cpystrn(ss->request, r->the_request, sizeof(ss->request)); } else { /* Don't reveal the password in the server-status view */ - ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ", + apr_cpystrn(ss->request, apr_pstrcat(r->pool, r->method, " ", ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD), r->assbackwards ? NULL : " ", r->protocol, NULL), sizeof(ss->request)); @@ -483,10 +483,10 @@ void ap_time_process_request(int child_num, int status) ss = &ap_scoreboard_image->servers[child_num]; if (status == START_PREQUEST) { - ss->start_time = ap_now(); + ss->start_time = apr_now(); } else if (status == STOP_PREQUEST) { - ss->stop_time = ap_now(); + ss->stop_time = apr_now(); } put_scoreboard_info(child_num, ss); @@ -518,7 +518,7 @@ static void increment_counts(int child_num, request_rec *r) } */ -static int find_child_by_pid(ap_proc_t *pid) +static int find_child_by_pid(apr_proc_t *pid) { int i; @@ -556,7 +556,7 @@ int reap_children(ap_wait_t *status) static void sig_coredump(int sig) { chdir(ap_coredump_dir); - ap_signal(sig, SIG_DFL); + apr_signal(sig, SIG_DFL); kill(getpid(), sig); /* At this point we've got sig blocked, because we're still inside * the signal handler. When we leave the signal handler it will @@ -613,7 +613,7 @@ static void restart(int sig) } restart_pending = 1; if ((is_graceful = (sig == SIGUSR1))) { - ap_kill_cleanup(pconf, NULL, cleanup_shared_mem); + apr_kill_cleanup(pconf, NULL, cleanup_shared_mem); } } @@ -685,36 +685,36 @@ static void set_signals(void) ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, "sigaction(SIGUSR1)"); #else if (!one_process) { - ap_signal(SIGSEGV, sig_coredump); + apr_signal(SIGSEGV, sig_coredump); #ifdef SIGBUS - ap_signal(SIGBUS, sig_coredump); + apr_signal(SIGBUS, sig_coredump); #endif /* SIGBUS */ #ifdef SIGABORT - ap_signal(SIGABORT, sig_coredump); + apr_signal(SIGABORT, sig_coredump); #endif /* SIGABORT */ #ifdef SIGABRT - ap_signal(SIGABRT, sig_coredump); + apr_signal(SIGABRT, sig_coredump); #endif /* SIGABRT */ #ifdef SIGILL - ap_signal(SIGILL, sig_coredump); + apr_signal(SIGILL, sig_coredump); #endif /* SIGILL */ #ifdef SIGXCPU - ap_signal(SIGXCPU, SIG_DFL); + apr_signal(SIGXCPU, SIG_DFL); #endif /* SIGXCPU */ #ifdef SIGXFSZ - ap_signal(SIGXFSZ, SIG_DFL); + apr_signal(SIGXFSZ, SIG_DFL); #endif /* SIGXFSZ */ } - ap_signal(SIGTERM, sig_term); + apr_signal(SIGTERM, sig_term); #ifdef SIGHUP - ap_signal(SIGHUP, restart); + apr_signal(SIGHUP, restart); #endif /* SIGHUP */ #ifdef SIGUSR1 - ap_signal(SIGUSR1, restart); + apr_signal(SIGUSR1, restart); #endif /* SIGUSR1 */ #ifdef SIGPIPE - ap_signal(SIGPIPE, SIG_IGN); + apr_signal(SIGPIPE, SIG_IGN); #endif /* SIGPIPE */ #endif @@ -727,7 +727,7 @@ static void set_signals(void) */ static int srv; -static ap_socket_t *csd; +static apr_socket_t *csd; static int requests_this_child; static fd_set main_fds; @@ -746,10 +746,10 @@ static void child_main(int child_num_arg) ap_listen_rec *lr; ap_listen_rec *last_lr; ap_listen_rec *first_lr; - ap_pool_t *ptrans; + apr_pool_t *ptrans; conn_rec *current_conn; ap_iol *iol; - ap_status_t stat = APR_EINIT; + apr_status_t stat = APR_EINIT; int sockdes; ap_my_pid = getpid(); @@ -761,9 +761,9 @@ static void child_main(int child_num_arg) /* Get a sub context for global allocations in this child, so that * we can have cleanups occur when the child exits. */ - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); - ap_create_pool(&ptrans, pchild); + apr_create_pool(&ptrans, pchild); /* needs to be done before we switch UIDs so we have permissions */ reopen_scoreboard(pchild); @@ -777,8 +777,8 @@ static void child_main(int child_num_arg) (void) ap_update_child_status(my_child_num, SERVER_READY, (request_rec *) NULL); - ap_signal(SIGHUP, just_die); - ap_signal(SIGTERM, just_die); + apr_signal(SIGHUP, just_die); + apr_signal(SIGTERM, just_die); #ifdef OS2 /* Stop Ctrl-C/Ctrl-Break signals going to child processes */ @@ -795,7 +795,7 @@ static void child_main(int child_num_arg) * we can exit cleanly. */ usr1_just_die = 1; - ap_signal(SIGUSR1, usr1_handler); + apr_signal(SIGUSR1, usr1_handler); /* * (Re)initialize this child to a pre-connection state. @@ -803,7 +803,7 @@ static void child_main(int child_num_arg) current_conn = NULL; - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); if ((ap_max_requests_per_child > 0 && requests_this_child++ >= ap_max_requests_per_child)) { @@ -851,7 +851,7 @@ static void child_main(int child_num_arg) } first_lr=lr; do { - ap_get_os_sock(&sockdes, lr->sd); + apr_get_os_sock(&sockdes, lr->sd); if (FD_ISSET(sockdes, &main_fds)) goto got_listener; lr = lr->next; @@ -881,7 +881,7 @@ static void child_main(int child_num_arg) /* we didn't get a socket, and we were told to die */ clean_child_exit(0); } - stat = ap_accept(&csd, sd, ptrans); + stat = apr_accept(&csd, sd, ptrans); if (stat == APR_SUCCESS || stat != APR_EINTR) break; } @@ -961,7 +961,7 @@ static void child_main(int child_num_arg) * occur in mobile IP. */ ap_log_error(APLOG_MARK, APLOG_EMERG, stat, ap_server_conf, - "ap_accept: giving up."); + "apr_accept: giving up."); clean_child_exit(APEXIT_CHILDFATAL); #endif /*ENETDOWN*/ @@ -978,7 +978,7 @@ static void child_main(int child_num_arg) #else default: ap_log_error(APLOG_MARK, APLOG_ERR, stat, ap_server_conf, - "ap_accept: (client socket)"); + "apr_accept: (client socket)"); clean_child_exit(1); #endif } @@ -997,13 +997,13 @@ static void child_main(int child_num_arg) * the signal to ignore because we don't want to disturb any * third party code. */ - ap_signal(SIGUSR1, SIG_IGN); + apr_signal(SIGUSR1, SIG_IGN); /* * We now have a connection, so set it up with the appropriate * socket options, file descriptors, and read/write buffers. */ - ap_get_os_sock(&sockdes, csd); + apr_get_os_sock(&sockdes, csd); if (sockdes >= FD_SETSIZE) { ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL, @@ -1011,7 +1011,7 @@ static void child_main(int child_num_arg) "to rebuild Apache with a larger FD_SETSIZE " "(currently %d)", sockdes, FD_SETSIZE); - ap_close_socket(csd); + apr_close_socket(csd); continue; } @@ -1048,12 +1048,12 @@ static int make_child(server_rec *s, int slot, time_t now) } if (one_process) { - ap_signal(SIGHUP, just_die); - ap_signal(SIGINT, just_die); + apr_signal(SIGHUP, just_die); + apr_signal(SIGINT, just_die); #ifdef SIGQUIT - ap_signal(SIGQUIT, SIG_DFL); + apr_signal(SIGQUIT, SIG_DFL); #endif - ap_signal(SIGTERM, just_die); + apr_signal(SIGTERM, just_die); child_main(slot); } @@ -1101,9 +1101,9 @@ static int make_child(server_rec *s, int slot, time_t now) * Note that since restart() just notes that a restart has been * requested there's no race condition here. */ - ap_signal(SIGHUP, just_die); - ap_signal(SIGUSR1, just_die); - ap_signal(SIGTERM, just_die); + apr_signal(SIGHUP, just_die); + apr_signal(SIGUSR1, just_die); + apr_signal(SIGTERM, just_die); child_main(slot); } @@ -1280,7 +1280,7 @@ static int setup_listeners(server_rec *s) listenmaxfd = -1; FD_ZERO(&listenfds); for (lr = ap_listeners; lr; lr = lr->next) { - ap_get_os_sock(&sockdes, lr->sd); + apr_get_os_sock(&sockdes, lr->sd); FD_SET(sockdes, &listenfds); if (sockdes > listenmaxfd) { listenmaxfd = sockdes; @@ -1310,7 +1310,7 @@ void ap_reset_connection_status(long conn_id) * Executive routines. */ -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_children_to_start; @@ -1374,7 +1374,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) int child_slot; ap_wait_t status; /* this is a memory leak, but I'll fix it later. */ - ap_proc_t pid; + apr_proc_t pid; ap_wait_or_timeout(&status, &pid, pconf); @@ -1401,7 +1401,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } #if APR_HAS_OTHER_CHILD } - else if (ap_reap_other_child(&pid, status) == 0) { + else if (apr_reap_other_child(&pid, status) == 0) { /* handled */ #endif } @@ -1469,8 +1469,8 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) } /* we've been told to restart */ - ap_signal(SIGHUP, SIG_IGN); - ap_signal(SIGUSR1, SIG_IGN); + apr_signal(SIGHUP, SIG_IGN); + apr_signal(SIGUSR1, SIG_IGN); if (one_process) { /* not worth thinking about */ return 1; @@ -1526,7 +1526,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) return 0; } -static void prefork_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) +static void prefork_pre_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp) { static int restart_num = 0; int no_detach = 0; @@ -1539,7 +1539,7 @@ static void prefork_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) is_graceful = 0; if (!one_process && !no_detach) { - ap_detach(); + apr_detach(); } ap_my_pid = getpid(); @@ -1557,7 +1557,7 @@ static void prefork_pre_config(ap_pool_t *p, ap_pool_t *plog, ap_pool_t *ptemp) ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; ap_extended_status = 0; - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } static void prefork_hooks(void) @@ -1692,7 +1692,7 @@ static const char *set_max_requests(cmd_parms *cmd, void *dummy, const char *arg static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1700,12 +1700,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, const char *arg } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1730,40 +1730,40 @@ const char *ap_get_connection_status(long conn_id, const char *key) return NULL; } -ap_array_header_t *ap_get_connections(ap_pool_t *p) +apr_array_header_t *ap_get_connections(apr_pool_t *p) { int i; - ap_array_header_t *connection_list; + apr_array_header_t *connection_list; long *array_slot; - connection_list = ap_make_array(p, 0, sizeof(long)); + connection_list = apr_make_array(p, 0, sizeof(long)); /* We assume that there is a connection iff it has an entry in the status * table. Connections without any status sound problematic to me, so this * is probably for the best. - manoj */ for (i = 0; i < ap_max_daemons_limit; i++) { if (ap_new_scoreboard_image->table[i][0].key[0] != '\0') { - array_slot = ap_push_array(connection_list); + array_slot = apr_push_array(connection_list); *array_slot = i; } } return connection_list; } -ap_array_header_t *ap_get_connection_keys(ap_pool_t *p, long conn_id) +apr_array_header_t *ap_get_connection_keys(apr_pool_t *p, long conn_id) { int i = 0; status_table_entry *ss; - ap_array_header_t *key_list; + apr_array_header_t *key_list; char **array_slot; - key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char)); + key_list = apr_make_array(p, 0, KEY_LENGTH * sizeof(char)); while (i < STATUSES_PER_CONNECTION) { ss = &(ap_new_scoreboard_image->table[conn_id][i]); if (ss->key[0] == '\0') { break; } - array_slot = ap_push_array(key_list); - *array_slot = ap_pstrdup(p, ss->key); + array_slot = apr_push_array(key_list); + *array_slot = apr_pstrdup(p, ss->key); i++; } return key_list; @@ -1786,7 +1786,7 @@ void ap_update_connection_status(long conn_id, const char *key, break; } if (0 == strcmp(ss->key, key)) { - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } i++; @@ -1796,19 +1796,19 @@ void ap_update_connection_status(long conn_id, const char *key, /* No room. Oh well, not much anyone can do about it. */ return; } - ap_cpystrn(ss->key, key, KEY_LENGTH); - ap_cpystrn(ss->value, value, VALUE_LENGTH); + apr_cpystrn(ss->key, key, KEY_LENGTH); + apr_cpystrn(ss->value, value, VALUE_LENGTH); return; } -ap_array_header_t *ap_get_status_table(ap_pool_t *p) +apr_array_header_t *ap_get_status_table(apr_pool_t *p) { int i, j; - ap_array_header_t *server_status; + apr_array_header_t *server_status; ap_status_table_row_t *array_slot; status_table_entry *ss; - server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t)); + server_status = apr_make_array(p, 0, sizeof(ap_status_table_row_t)); /* Go ahead and return what's in the connection status table even if we * aren't maintaining it. We can at least look at what children from @@ -1817,14 +1817,14 @@ ap_array_header_t *ap_get_status_table(ap_pool_t *p) for (i = 0; i < ap_max_daemons_limit; i++) { if (ap_new_scoreboard_image->table[i][0].key[0] == '\0') continue; - array_slot = ap_push_array(server_status); - array_slot->data = ap_make_table(p, 0); + array_slot = apr_push_array(server_status); + array_slot->data = apr_make_table(p, 0); array_slot->conn_id = i; for (j = 0; j < STATUSES_PER_CONNECTION; j++) { ss = &(ap_new_scoreboard_image->table[i][j]); if (ss->key[0] != '\0') { - ap_table_add(array_slot->data, ss->key, ss->value); + apr_table_add(array_slot->data, ss->key, ss->value); } else { break; @@ -1865,7 +1865,7 @@ module MODULE_VAR_EXPORT mpm_prefork_module = { NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ - prefork_cmds, /* command ap_table_t */ + prefork_cmds, /* command apr_table_t */ NULL, /* handlers */ prefork_hooks, /* register hooks */ }; diff --git a/server/mpm/prefork/scoreboard.h b/server/mpm/prefork/scoreboard.h index d66c606d34..97ed8e8413 100644 --- a/server/mpm/prefork/scoreboard.h +++ b/server/mpm/prefork/scoreboard.h @@ -151,8 +151,8 @@ typedef struct { unsigned long my_bytes_served; unsigned long conn_bytes; unsigned short conn_count; - ap_time_t start_time; - ap_time_t stop_time; + apr_time_t start_time; + apr_time_t stop_time; #ifdef HAVE_TIMES struct tms times; #endif diff --git a/server/mpm/spmt_os2/scoreboard.h b/server/mpm/spmt_os2/scoreboard.h index 41e594b888..5ef4c4d1fe 100644 --- a/server/mpm/spmt_os2/scoreboard.h +++ b/server/mpm/spmt_os2/scoreboard.h @@ -145,8 +145,8 @@ typedef struct { unsigned long my_bytes_served; unsigned long conn_bytes; unsigned short conn_count; - ap_time_t start_time; - ap_time_t stop_time; + apr_time_t start_time; + apr_time_t stop_time; #ifdef HAVE_TIMES struct tms times; #endif diff --git a/server/mpm/spmt_os2/spmt_os2.c b/server/mpm/spmt_os2/spmt_os2.c index c004e925aa..b19c133c4c 100644 --- a/server/mpm/spmt_os2/spmt_os2.c +++ b/server/mpm/spmt_os2/spmt_os2.c @@ -70,7 +70,7 @@ #include "http_connection.h" #include "scoreboard.h" #include "ap_mpm.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "ap_iol.h" #include "apr_portable.h" #include "mpm_common.h" @@ -119,12 +119,12 @@ server_rec *ap_server_conf; static int one_process = 0; -static ap_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pconf; /* Pool for config stuff */ static scoreboard *ap_scoreboard_image = NULL; struct thread_globals { int child_num; - ap_pool_t *pchild; /* Pool for httpd child stuff */ + apr_pool_t *pchild; /* Pool for httpd child stuff */ int usr1_just_die; }; @@ -133,7 +133,7 @@ static struct thread_globals **ppthread_globals = NULL; #define THREAD_GLOBAL(gvar) ((*ppthread_globals)->gvar) -void reinit_scoreboard(ap_pool_t *p) +void reinit_scoreboard(apr_pool_t *p) { if (ap_scoreboard_image == NULL) { ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE); @@ -159,7 +159,7 @@ void cleanup_scoreboard(void) static void clean_child_exit(int code) { if (THREAD_GLOBAL(pchild)) { - ap_destroy_pool(THREAD_GLOBAL(pchild)); + apr_destroy_pool(THREAD_GLOBAL(pchild)); } ap_scoreboard_image->servers[THREAD_GLOBAL(child_num)].thread_retval = code; @@ -168,29 +168,29 @@ static void clean_child_exit(int code) -static ap_lock_t *accept_mutex = NULL; +static apr_lock_t *accept_mutex = NULL; -static ap_status_t accept_mutex_child_cleanup(void *foo) +static apr_status_t accept_mutex_child_cleanup(void *foo) { - return ap_unlock(accept_mutex); + return apr_unlock(accept_mutex); } /* * Initialize mutex lock. * Done by each child at it's birth */ -static void accept_mutex_child_init(ap_pool_t *p) +static void accept_mutex_child_init(apr_pool_t *p) { - ap_register_cleanup(p, NULL, accept_mutex_child_cleanup, ap_null_cleanup); + apr_register_cleanup(p, NULL, accept_mutex_child_cleanup, apr_null_cleanup); } /* * Initialize mutex lock. * Must be safe to call this on a restart. */ -static void accept_mutex_init(ap_pool_t *p) +static void accept_mutex_init(apr_pool_t *p) { - ap_status_t rc = ap_create_lock(&accept_mutex, APR_MUTEX, APR_INTRAPROCESS, NULL, p); + apr_status_t rc = apr_create_lock(&accept_mutex, APR_MUTEX, APR_INTRAPROCESS, NULL, p); if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rc, ap_server_conf, @@ -201,7 +201,7 @@ static void accept_mutex_init(ap_pool_t *p) static void accept_mutex_on(void) { - ap_status_t rc = ap_lock(accept_mutex); + apr_status_t rc = apr_lock(accept_mutex); if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rc, ap_server_conf, @@ -212,7 +212,7 @@ static void accept_mutex_on(void) static void accept_mutex_off(void) { - ap_status_t rc = ap_unlock(accept_mutex); + apr_status_t rc = apr_unlock(accept_mutex); if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_EMERG, rc, ap_server_conf, @@ -270,15 +270,15 @@ int ap_update_child_status(int child_num, int status, request_rec *r) } if (r) { conn_rec *c = r->connection; - ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, + apr_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, REMOTE_NOLOOKUP), sizeof(ss->client)); if (r->the_request == NULL) { - ap_cpystrn(ss->request, "NULL", sizeof(ss->request)); + apr_cpystrn(ss->request, "NULL", sizeof(ss->request)); } else if (r->parsed_uri.password == NULL) { - ap_cpystrn(ss->request, r->the_request, sizeof(ss->request)); + apr_cpystrn(ss->request, r->the_request, sizeof(ss->request)); } else { /* Don't reveal the password in the server-status view */ - ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ", + apr_cpystrn(ss->request, apr_pstrcat(r->pool, r->method, " ", ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD), r->assbackwards ? NULL : " ", r->protocol, NULL), sizeof(ss->request)); @@ -308,10 +308,10 @@ void ap_time_process_request(int child_num, int status) ss = &ap_scoreboard_image->servers[child_num]; if (status == START_PREQUEST) { - ss->start_time = ap_now(); + ss->start_time = apr_now(); } else if (status == STOP_PREQUEST) { - ss->stop_time = ap_now(); + ss->stop_time = apr_now(); } } @@ -367,7 +367,7 @@ static int wait_or_timeout(ap_wait_t *status) if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) { wait_or_timeout_counter = 0; #if APR_HAS_OTHER_CHILD - ap_probe_writable_fds(); + apr_probe_writable_fds(); #endif } @@ -716,7 +716,7 @@ int ap_stop_signalled(void) -static int setup_listen_poll(ap_pool_t *pchild, ap_pollfd_t **listen_poll) +static int setup_listen_poll(apr_pool_t *pchild, apr_pollfd_t **listen_poll) { ap_listen_rec *lr; int numfds = 0; @@ -725,10 +725,10 @@ static int setup_listen_poll(ap_pool_t *pchild, ap_pollfd_t **listen_poll) numfds++; } - ap_setup_poll(listen_poll, numfds, pchild); + apr_setup_poll(listen_poll, numfds, pchild); for (lr = ap_listeners; lr; lr = lr->next) { - ap_add_poll_socket(*listen_poll, lr->sd, APR_POLLIN); + apr_add_poll_socket(*listen_poll, lr->sd, APR_POLLIN); } return 0; } @@ -739,14 +739,14 @@ static void child_main(void *child_num_arg) { ap_listen_rec *lr = NULL; ap_listen_rec *first_lr = NULL; - ap_pool_t *ptrans; + apr_pool_t *ptrans; conn_rec *current_conn; ap_iol *iol; - ap_pool_t *pchild; + apr_pool_t *pchild; parent_score *sc_parent_rec; int requests_this_child = 0; - ap_pollfd_t *listen_poll; - ap_socket_t *csd = NULL; + apr_pollfd_t *listen_poll; + apr_socket_t *csd = NULL; int nsds, rv; /* Disable the restart signal handlers and enable the just_die stuff. @@ -762,12 +762,12 @@ static void child_main(void *child_num_arg) /* Get a sub pool for global allocations in this child, so that * we can have cleanups occur when the child exits. */ - ap_create_pool(&pchild, pconf); - *ppthread_globals = (struct thread_globals *)ap_palloc(pchild, sizeof(struct thread_globals)); + apr_create_pool(&pchild, pconf); + *ppthread_globals = (struct thread_globals *)apr_palloc(pchild, sizeof(struct thread_globals)); THREAD_GLOBAL(child_num) = (int)child_num_arg; sc_parent_rec = ap_scoreboard_image->parent + THREAD_GLOBAL(child_num); THREAD_GLOBAL(pchild) = pchild; - ap_create_pool(&ptrans, pchild); + apr_create_pool(&ptrans, pchild); if (setup_listen_poll(pchild, &listen_poll)) { clean_child_exit(1); @@ -787,7 +787,7 @@ static void child_main(void *child_num_arg) while (!ap_stop_signalled()) { BUFF *conn_io; int srv; - ap_socket_t *sd; + apr_socket_t *sd; /* Prepare to receive a SIGUSR1 due to graceful restart so that * we can exit cleanly. @@ -801,7 +801,7 @@ static void child_main(void *child_num_arg) current_conn = NULL; - ap_clear_pool(ptrans); + apr_clear_pool(ptrans); if ((ap_max_requests_per_child > 0 && requests_this_child++ >= ap_max_requests_per_child)) { @@ -824,7 +824,7 @@ static void child_main(void *child_num_arg) for (;;) { if (ap_listeners->next) { /* more than one socket */ - srv = ap_poll(listen_poll, &nsds, -1); + srv = apr_poll(listen_poll, &nsds, -1); if (srv != APR_SUCCESS) { /* Single Unix documents select as returning errnos @@ -846,13 +846,13 @@ static void child_main(void *child_num_arg) lr = first_lr; do { - ap_int16_t event; + apr_int16_t event; if (!lr) { lr = ap_listeners; } - ap_get_revents(&event, lr->sd, listen_poll); + apr_get_revents(&event, lr->sd, listen_poll); if (event == APR_POLLIN) { first_lr = lr->next; @@ -875,7 +875,7 @@ static void child_main(void *child_num_arg) * defer the exit */ THREAD_GLOBAL(usr1_just_die) = 0; - rv = ap_accept(&csd, sd, ptrans); + rv = apr_accept(&csd, sd, ptrans); if (rv == APR_SUCCESS) break; /* We have a socket ready for reading */ @@ -891,7 +891,7 @@ static void child_main(void *child_num_arg) * lead to never-ending loops here. So it seems best * to just exit in most cases. */ - switch (ap_canonical_error(rv)) { + switch (apr_canonical_error(rv)) { #ifdef EPROTO /* EPROTO on certain older kernels really means * ECONNABORTED, so we need to ignore it for them. @@ -972,7 +972,7 @@ static void child_main(void *child_num_arg) if (iol == NULL) { ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, NULL, "error attaching to socket"); - ap_close_socket(csd); + apr_close_socket(csd); continue; } @@ -1178,11 +1178,11 @@ static void perform_idle_server_maintenance(void) * Executive routines. */ -int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) +int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) { int remaining_children_to_start; int i; - ap_status_t status; + apr_status_t status; pconf = _pconf; ap_server_conf = s; @@ -1208,7 +1208,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) "Error allocating thread local storage" "Apache is exiting!"); } else { - *ppthread_globals = (struct thread_globals *)ap_palloc(pconf, sizeof(struct thread_globals)); + *ppthread_globals = (struct thread_globals *)apr_palloc(pconf, sizeof(struct thread_globals)); } } @@ -1254,7 +1254,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) * extra child */ if (tid >= 0) { - ap_proc_t dummyproc; + apr_proc_t dummyproc; dummyproc.pid = tid; ap_process_child_status(&dummyproc, status); /* non-fatal death... note that it's gone in the scoreboard. */ @@ -1318,7 +1318,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) ap_listen_rec *lr; for (lr = ap_listeners; lr; lr = lr->next) { - ap_close_socket(lr->sd); + apr_close_socket(lr->sd); DosSleep(0); } @@ -1408,7 +1408,7 @@ int ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s) return 0; } -static void spmt_os2_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp) +static void spmt_os2_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) { one_process = !!getenv("ONE_PROCESS"); @@ -1422,7 +1422,7 @@ static void spmt_os2_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *pt ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; ap_extended_status = 0; - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } static void spmt_os2_hooks(void) @@ -1532,7 +1532,7 @@ static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg) static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -1540,12 +1540,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -1588,7 +1588,7 @@ module MODULE_VAR_EXPORT mpm_spmt_os2_module = { NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ - spmt_os2_cmds, /* command ap_table_t */ + spmt_os2_cmds, /* command apr_table_t */ NULL, /* handlers */ spmt_os2_hooks, /* register_hooks */ }; diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index b5bec3ed75..7361c21080 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -68,7 +68,7 @@ #include "apr_strings.h" #include "ap_mpm.h" #include "ap_config.h" -#include "ap_listen.h" +#include "apr_listen.h" #include "mpm_default.h" #include "ap_iol.h" #include "mpm_winnt.h" @@ -97,7 +97,7 @@ static struct fd_set listenfds; static int num_listenfds = 0; static SOCKET listenmaxfd = INVALID_SOCKET; -static ap_pool_t *pconf; /* Pool for config stuff */ +static apr_pool_t *pconf; /* Pool for config stuff */ static char ap_coredump_dir[MAX_STRING_LEN]; @@ -114,7 +114,7 @@ int ap_daemons_to_start=0; static event *exit_event; HANDLE maintenance_event; -ap_lock_t *start_mutex; +apr_lock_t *start_mutex; DWORD my_pid; DWORD parent_pid; @@ -142,11 +142,11 @@ FARPROC ap_load_dll_func(ap_dlltoken_e fnLib, char* fnName, int ordinal) return GetProcAddress(lateDllHandle[fnLib], fnName); } -static ap_status_t socket_cleanup(void *sock) +static apr_status_t socket_cleanup(void *sock) { - ap_socket_t *thesocket = sock; + apr_socket_t *thesocket = sock; SOCKET sd; - if (ap_get_os_sock(&sd, thesocket) == APR_SUCCESS) { + if (apr_get_os_sock(&sd, thesocket) == APR_SUCCESS) { closesocket(sd); } return APR_SUCCESS; @@ -354,10 +354,10 @@ API_EXPORT(void) ap_start_restart(int gracefully) void setup_signal_names(char *prefix) { - ap_snprintf(signal_name_prefix, sizeof(signal_name_prefix), prefix); - ap_snprintf(signal_shutdown_name, sizeof(signal_shutdown_name), + apr_snprintf(signal_name_prefix, sizeof(signal_name_prefix), prefix); + apr_snprintf(signal_shutdown_name, sizeof(signal_shutdown_name), "%s_shutdown", signal_name_prefix); - ap_snprintf(signal_restart_name, sizeof(signal_restart_name), + apr_snprintf(signal_restart_name, sizeof(signal_restart_name), "%s_restart", signal_name_prefix); } @@ -396,7 +396,7 @@ static ap_inline ap_listen_rec *find_ready_listener(fd_set * main_fds) SOCKET nsd; for (lr = head_listener; lr ; lr = lr->next) { - ap_get_os_sock(&nsd, lr->sd); + apr_get_os_sock(&nsd, lr->sd); if (FD_ISSET(nsd, main_fds)) { head_listener = lr->next; if (head_listener == NULL) @@ -423,7 +423,7 @@ static int setup_listeners(server_rec *s) for (lr = ap_listeners; lr; lr = lr->next) { num_listeners++; if (lr->sd != NULL) { - ap_get_os_sock(&nsd, lr->sd); + apr_get_os_sock(&nsd, lr->sd); FD_SET(nsd, &listenfds); if (listenmaxfd == INVALID_SOCKET || nsd > listenmaxfd) { listenmaxfd = nsd; @@ -453,7 +453,7 @@ static int setup_inherited_listeners(server_rec *s) if (ap_listeners == NULL) { ap_listen_rec *lr; - lr = ap_palloc(s->process->pool, sizeof(ap_listen_rec)); + lr = apr_palloc(s->process->pool, sizeof(ap_listen_rec)); if (!lr) return 0; lr->sd = NULL; @@ -489,7 +489,7 @@ static int setup_inherited_listeners(server_rec *s) listenmaxfd = nsd; } } - ap_put_os_sock(&lr->sd, &nsd, pconf); + apr_put_os_sock(&lr->sd, &nsd, pconf); lr->count = 0; } /* Now, read the AcceptExCompPort from the parent */ @@ -514,7 +514,7 @@ static void bind_listeners_to_completion_port() if (osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { for (lr = ap_listeners; lr; lr = lr->next) { int nsd; - ap_get_os_sock(&nsd,lr->sd); + apr_get_os_sock(&nsd,lr->sd); CreateIoCompletionPort((HANDLE) nsd, AcceptExCompPort, 0, 0); } } @@ -602,7 +602,7 @@ typedef struct globals_s { semaphore *jobsemaphore; joblist *jobhead; joblist *jobtail; - ap_lock_t *jobmutex; + apr_lock_t *jobmutex; int jobcount; } globals; @@ -641,7 +641,7 @@ static void add_job(int sock) new_job->next = NULL; new_job->sock = sock; - ap_lock(allowed_globals.jobmutex); + apr_lock(allowed_globals.jobmutex); if (allowed_globals.jobtail != NULL) allowed_globals.jobtail->next = new_job; @@ -651,7 +651,7 @@ static void add_job(int sock) allowed_globals.jobcount++; release_semaphore(allowed_globals.jobsemaphore); - ap_unlock(allowed_globals.jobmutex); + apr_unlock(allowed_globals.jobmutex); } static int remove_job(void) @@ -660,10 +660,10 @@ static int remove_job(void) int sock; acquire_semaphore(allowed_globals.jobsemaphore); - ap_lock(allowed_globals.jobmutex); + apr_lock(allowed_globals.jobmutex); if (shutdown_in_progress && !allowed_globals.jobhead) { - ap_unlock(allowed_globals.jobmutex); + apr_unlock(allowed_globals.jobmutex); return (-1); } job = allowed_globals.jobhead; @@ -671,7 +671,7 @@ static int remove_job(void) allowed_globals.jobhead = job->next; if (allowed_globals.jobhead == NULL) allowed_globals.jobtail = NULL; - ap_unlock(allowed_globals.jobmutex); + apr_unlock(allowed_globals.jobmutex); sock = job->sock; free(job); @@ -726,7 +726,7 @@ static void accept_and_queue_connections(void * dummy) lr = find_ready_listener(&main_fds); if (lr != NULL) { /* fetch the native socket descriptor */ - ap_get_os_sock(&nsd, lr->sd); + apr_get_os_sock(&nsd, lr->sd); } } @@ -757,24 +757,24 @@ static PCOMP_CONTEXT win9x_get_connection(PCOMP_CONTEXT context) if (context == NULL) { /* allocate the completion context and the transaction pool */ - context = ap_pcalloc(pconf, sizeof(COMP_CONTEXT)); + context = apr_pcalloc(pconf, sizeof(COMP_CONTEXT)); if (!context) { ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf, - "win9x_get_connection: ap_pcalloc() failed. Process will exit."); + "win9x_get_connection: apr_pcalloc() failed. Process will exit."); return NULL; } - ap_create_pool(&context->ptrans, pconf); + apr_create_pool(&context->ptrans, pconf); } while (1) { - ap_clear_pool(context->ptrans); + apr_clear_pool(context->ptrans); context->accept_socket = remove_job(); if (context->accept_socket == -1) { return NULL; } len = sizeof(struct sockaddr); - context->sa_server = ap_palloc(context->ptrans, len); + context->sa_server = apr_palloc(context->ptrans, len); if (getsockname(context->accept_socket, context->sa_server, &len)== SOCKET_ERROR) { ap_log_error(APLOG_MARK, APLOG_WARNING, WSAGetLastError(), server_conf, @@ -782,7 +782,7 @@ static PCOMP_CONTEXT win9x_get_connection(PCOMP_CONTEXT context) continue; } len = sizeof(struct sockaddr); - context->sa_client = ap_palloc(context->ptrans, len); + context->sa_client = apr_palloc(context->ptrans, len); if ((getpeername(context->accept_socket, context->sa_client, &len)) == SOCKET_ERROR) { ap_log_error(APLOG_MARK, APLOG_WARNING, WSAGetLastError(), server_conf, @@ -840,7 +840,7 @@ static void drain_acceptex_complport(HANDLE hComplPort, BOOLEAN bCleanUp) } } } -static int create_acceptex_context(ap_pool_t *_pconf, ap_listen_rec *lr) +static int create_acceptex_context(apr_pool_t *_pconf, ap_listen_rec *lr) { PCOMP_CONTEXT context; DWORD BytesRead; @@ -848,10 +848,10 @@ static int create_acceptex_context(ap_pool_t *_pconf, ap_listen_rec *lr) int lasterror; /* allocate the completion context */ - context = ap_pcalloc(_pconf, sizeof(COMP_CONTEXT)); + context = apr_pcalloc(_pconf, sizeof(COMP_CONTEXT)); if (!context) { ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf, - "create_acceptex_context: ap_pcalloc() failed. Process will exit."); + "create_acceptex_context: apr_pcalloc() failed. Process will exit."); return -1; } @@ -865,7 +865,7 @@ static int create_acceptex_context(ap_pool_t *_pconf, ap_listen_rec *lr) } /* create and initialize the accept socket */ - ap_get_os_sock(&nsd, context->lr->sd); + apr_get_os_sock(&nsd, context->lr->sd); context->accept_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (context->accept_socket == INVALID_SOCKET) { ap_log_error(APLOG_MARK,APLOG_ERR, WSAGetLastError(), server_conf, @@ -882,7 +882,7 @@ static int create_acceptex_context(ap_pool_t *_pconf, ap_listen_rec *lr) /* Not a failure condition. Keep running. */ } - ap_create_pool(&context->ptrans, _pconf); + apr_create_pool(&context->ptrans, _pconf); context->conn_io = ap_bcreate(context->ptrans, B_RDWR); context->recv_buf = context->conn_io->inbase; context->recv_buf_size = context->conn_io->bufsiz - 2*PADDED_ADDR_SIZE; @@ -908,7 +908,7 @@ static int create_acceptex_context(ap_pool_t *_pconf, ap_listen_rec *lr) return 0; } -static ap_inline ap_status_t reset_acceptex_context(PCOMP_CONTEXT context) +static ap_inline apr_status_t reset_acceptex_context(PCOMP_CONTEXT context) { DWORD BytesRead; SOCKET nsd; @@ -917,7 +917,7 @@ static ap_inline ap_status_t reset_acceptex_context(PCOMP_CONTEXT context) context->lr->count++; /* recreate and initialize the accept socket if it is not being reused */ - ap_get_os_sock(&nsd, context->lr->sd); + apr_get_os_sock(&nsd, context->lr->sd); if (context->accept_socket == INVALID_SOCKET) { context->accept_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (context->accept_socket == INVALID_SOCKET) { @@ -939,7 +939,7 @@ static ap_inline ap_status_t reset_acceptex_context(PCOMP_CONTEXT context) } /* reset the completion context */ - ap_clear_pool(context->ptrans); + apr_clear_pool(context->ptrans); context->sock = NULL; context->conn_io = ap_bcreate(context->ptrans, B_RDWR); context->recv_buf = context->conn_io->inbase; @@ -1055,12 +1055,12 @@ static PCOMP_CONTEXT winnt_get_connection(PCOMP_CONTEXT context) * but only if we are not in the process of shutting down */ if (!shutdown_in_progress) { - ap_lock(allowed_globals.jobmutex); + apr_lock(allowed_globals.jobmutex); context->lr->count--; if (context->lr->count < 2) { SetEvent(maintenance_event); } - ap_unlock(allowed_globals.jobmutex); + apr_unlock(allowed_globals.jobmutex); } /* Received a connection */ @@ -1104,7 +1104,7 @@ static void worker_main(int child_num) while (1) { conn_rec *c; ap_iol *iol; - ap_int32_t disconnected; + apr_int32_t disconnected; /* Grab a connection off the network */ if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { @@ -1117,7 +1117,7 @@ static void worker_main(int child_num) if (!context) break; sock_disable_nagle(context->accept_socket); - ap_put_os_sock(&context->sock, &context->accept_socket, context->ptrans); + apr_put_os_sock(&context->sock, &context->accept_socket, context->ptrans); iol = ap_iol_attach_socket(context->ptrans, context->sock); if (iol == NULL) { @@ -1135,7 +1135,7 @@ static void worker_main(int child_num) ap_process_connection(c); - ap_getsocketopt(context->sock, APR_SO_DISCONNECTED, &disconnected); + apr_getsocketopt(context->sock, APR_SO_DISCONNECTED, &disconnected); if (disconnected) { /* Kill the clean-up registered by the iol. We want to leave * the accept socket open because we are about to try to @@ -1201,7 +1201,7 @@ static void create_listeners() */ static void child_main() { - ap_status_t status; + apr_status_t status; HANDLE child_events[2]; char* exit_event_name; int nthreads = ap_threads_per_child; @@ -1211,18 +1211,18 @@ static void child_main() time_t end_time; int i; int cld; - ap_pool_t *pchild; + apr_pool_t *pchild; /* This is the child process or we are running in single process * mode. */ - exit_event_name = ap_psprintf(pconf, "apC%d", my_pid); - setup_signal_names(ap_psprintf(pconf,"ap%d", parent_pid)); + exit_event_name = apr_psprintf(pconf, "apC%d", my_pid); + setup_signal_names(apr_psprintf(pconf,"ap%d", parent_pid)); if (one_process) { /* Single process mode */ - ap_create_lock(&start_mutex,APR_MUTEX, APR_CROSS_PROCESS,signal_name_prefix,pconf); + apr_create_lock(&start_mutex,APR_MUTEX, APR_CROSS_PROCESS,signal_name_prefix,pconf); exit_event = CreateEvent(NULL, TRUE, FALSE, exit_event_name); setup_listeners(server_conf); @@ -1230,7 +1230,7 @@ static void child_main() } else { /* Child process mode */ - ap_child_init_lock(&start_mutex, signal_name_prefix, pconf); + apr_child_init_lock(&start_mutex, signal_name_prefix, pconf); exit_event = OpenEvent(EVENT_ALL_ACCESS, FALSE, exit_event_name); ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf, "Child %d: exit_event_name = %s", my_pid, exit_event_name); @@ -1247,16 +1247,16 @@ static void child_main() ap_assert(exit_event); ap_assert(maintenance_event); - ap_create_pool(&pchild, pconf); + apr_create_pool(&pchild, pconf); allowed_globals.jobsemaphore = create_semaphore(0); - ap_create_lock(&allowed_globals.jobmutex, APR_MUTEX, APR_INTRAPROCESS, NULL, pchild); + apr_create_lock(&allowed_globals.jobmutex, APR_MUTEX, APR_INTRAPROCESS, NULL, pchild); /* * Wait until we have permission to start accepting connections. * start_mutex is used to ensure that only one child ever * goes into the listen/accept loop at once. */ - status = ap_lock(start_mutex); + status = apr_lock(start_mutex); if (status != APR_SUCCESS) { ap_log_error(APLOG_MARK,APLOG_ERR, status, server_conf, "Child %d: Failed to acquire the start_mutex. Process will exit.", my_pid); @@ -1360,7 +1360,7 @@ static void child_main() workers_may_exit = 1; /* Unblock threads blocked on the completion port */ - ap_lock(allowed_globals.jobmutex); + apr_lock(allowed_globals.jobmutex); while (g_blocked_threads > 0) { ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf, "Child %d: %d threads blocked on the completion port", my_pid, g_blocked_threads); @@ -1369,11 +1369,11 @@ static void child_main() } Sleep(1000); } - ap_unlock(allowed_globals.jobmutex); + apr_unlock(allowed_globals.jobmutex); /* Cancel any remaining pending AcceptEx completion contexts */ for (lr = ap_listeners; lr != NULL; lr = lr->next) { - ap_get_os_sock(&nsd,lr->sd); + apr_get_os_sock(&nsd,lr->sd); CancelIo((HANDLE) nsd); } @@ -1386,7 +1386,7 @@ static void child_main() */ ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf, "Child %d: Releasing the start mutex", my_pid); - ap_unlock(start_mutex); + apr_unlock(start_mutex); /* Give busy worker threads a chance to service their connections. * Kill them off if they take too long @@ -1413,9 +1413,9 @@ static void child_main() CloseHandle(AcceptExCompPort); destroy_semaphore(allowed_globals.jobsemaphore); - ap_destroy_lock(allowed_globals.jobmutex); + apr_destroy_lock(allowed_globals.jobmutex); - ap_destroy_pool(pchild); + apr_destroy_pool(pchild); CloseHandle(exit_event); } @@ -1464,7 +1464,7 @@ static void cleanup_process(HANDLE *handles, HANDLE *events, int position, int * (*processes)--; } -static int create_process(ap_pool_t *p, HANDLE *handles, HANDLE *events, int *processes) +static int create_process(apr_pool_t *p, HANDLE *handles, HANDLE *events, int *processes) { int rv; char buf[1024]; @@ -1506,13 +1506,13 @@ static int create_process(ap_pool_t *p, HANDLE *handles, HANDLE *events, int *pr } /* Build the command line */ - pCommand = ap_psprintf(p, "\"%s\"", buf); + pCommand = apr_psprintf(p, "\"%s\"", buf); for (i = 1; i < server_conf->process->argc; i++) { - pCommand = ap_pstrcat(p, pCommand, " \"", server_conf->process->argv[i], "\"", NULL); + pCommand = apr_pstrcat(p, pCommand, " \"", server_conf->process->argv[i], "\"", NULL); } /* Build the environment, since Win9x disrespects the active env */ - pEnvVar = ap_psprintf(p, "AP_PARENT_PID=%i", parent_pid); + pEnvVar = apr_psprintf(p, "AP_PARENT_PID=%i", parent_pid); /* * Win32's CreateProcess call requires that the environment * be passed in an environment block, a null terminated block of @@ -1525,7 +1525,7 @@ static int create_process(ap_pool_t *p, HANDLE *handles, HANDLE *events, int *pr i++; } - pEnvBlock = (char *)ap_pcalloc(p, iEnvBlockLen + strlen(pEnvVar) + 1); + pEnvBlock = (char *)apr_pcalloc(p, iEnvBlockLen + strlen(pEnvVar) + 1); strcpy(pEnvBlock, pEnvVar); pEnvVar = strchr(pEnvBlock, '\0') + 1; @@ -1579,7 +1579,7 @@ static int create_process(ap_pool_t *p, HANDLE *handles, HANDLE *events, int *pr sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; - kill_event = CreateEvent(&sa, TRUE, FALSE, ap_psprintf(pconf,"apC%d", pi.dwProcessId)); + kill_event = CreateEvent(&sa, TRUE, FALSE, apr_psprintf(pconf,"apC%d", pi.dwProcessId)); if (!kill_event) { ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf, "Parent: Could not create exit event for child process"); @@ -1602,8 +1602,8 @@ static int create_process(ap_pool_t *p, HANDLE *handles, HANDLE *events, int *pr * (returned by dup socket) to the child */ for (lr = ap_listeners; lr; lr = lr->next) { int nsd; - lpWSAProtocolInfo = ap_pcalloc(p, sizeof(WSAPROTOCOL_INFO)); - ap_get_os_sock(&nsd,lr->sd); + lpWSAProtocolInfo = apr_pcalloc(p, sizeof(WSAPROTOCOL_INFO)); + apr_get_os_sock(&nsd,lr->sd); ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf, "Parent: Duplicating socket %d and sending it to child process %d", nsd, pi.dwProcessId); if (WSADuplicateSocket(nsd, pi.dwProcessId, @@ -1721,7 +1721,7 @@ static int master_main(server_rec *s, HANDLE shutdown_event, HANDLE restart_even * We are making a big assumption here that the child process, once signaled, * will REALLY go away. Since this is a restart, we do not want to hold the * new child process up waiting for the old child to die. Remove the old - * child out of the process_handles ap_table_t and hope for the best... + * child out of the process_handles apr_table_t and hope for the best... */ for (i = 0; i < children_to_kill; i++) { if (SetEvent(process_kill_events[i]) == 0) @@ -1733,7 +1733,7 @@ static int master_main(server_rec *s, HANDLE shutdown_event, HANDLE restart_even else { /* A child process must have exited because of a fatal error condition (seg fault, etc.). * Remove the dead process - * from the process_handles and process_kill_events ap_table_t and create a new + * from the process_handles and process_kill_events apr_table_t and create a new * child process. * TODO: Consider restarting the child immediately without looping through http_main * and without rereading the configuration. Will need this if we ever support multiple @@ -1796,14 +1796,14 @@ die_now: /* service_nt_main_fn needs to append the StartService() args * outside of our call stack and thread as the service starts... */ -ap_array_header_t *mpm_new_argv; +apr_array_header_t *mpm_new_argv; /* Remember service_to_start failures to log and fail in pre_config. * Remember inst_argc and inst_argv for installing or starting the * service after we preflight the config. */ -static ap_status_t service_to_start_success; +static apr_status_t service_to_start_success; static int inst_argc; static char **inst_argv; @@ -1817,8 +1817,8 @@ void winnt_rewrite_args(process_rec *process) * We can't leave this phase until we know our identity * and modify the command arguments appropriately. */ - ap_status_t service_named = SERVICE_UNNAMED; - ap_status_t rv; + apr_status_t service_named = SERVICE_UNNAMED; + apr_status_t rv; char *def_server_root; char fnbuf[MAX_PATH]; char optbuf[3]; @@ -1877,7 +1877,7 @@ void winnt_rewrite_args(process_rec *process) "Failed to get the running module's file name"); exit(1); } - def_server_root = (char *) ap_filename_of_pathname(fnbuf); + def_server_root = (char *) apr_filename_of_pathname(fnbuf); if (def_server_root > fnbuf) { *(def_server_root - 1) = '\0'; def_server_root = ap_os_canonical_filename(process->pool, fnbuf); @@ -1889,19 +1889,19 @@ void winnt_rewrite_args(process_rec *process) * initial pre-flight of the config parser. */ - mpm_new_argv = ap_make_array(process->pool, process->argc + 2, sizeof(char *)); - new_arg = (char**) ap_push_array(mpm_new_argv); + mpm_new_argv = apr_make_array(process->pool, process->argc + 2, sizeof(char *)); + new_arg = (char**) apr_push_array(mpm_new_argv); *new_arg = (char *) process->argv[0]; - new_arg = (char**) ap_push_array(mpm_new_argv); + new_arg = (char**) apr_push_array(mpm_new_argv); *new_arg = "-d"; - new_arg = (char**) ap_push_array(mpm_new_argv); + new_arg = (char**) apr_push_array(mpm_new_argv); *new_arg = def_server_root; fixed_args = mpm_new_argv->nelts; optbuf[0] = '-'; optbuf[2] = '\0'; - while (ap_getopt(process->argc, (char**) process->argv, + while (apr_getopt(process->argc, (char**) process->argv, "n:k:iu" AP_SERVER_BASEARGS, &opt, process->pool) == APR_SUCCESS) { switch (opt) { @@ -1921,16 +1921,16 @@ void winnt_rewrite_args(process_rec *process) break; default: optbuf[1] = (char) opt; - new_arg = (char**) ap_push_array(mpm_new_argv); - *new_arg = ap_pstrdup(process->pool, optbuf); + new_arg = (char**) apr_push_array(mpm_new_argv); + *new_arg = apr_pstrdup(process->pool, optbuf); if (ap_optarg) { - new_arg = (char**) ap_push_array(mpm_new_argv); + new_arg = (char**) apr_push_array(mpm_new_argv); *new_arg = ap_optarg; } break; } } - /* Set optreset and optind to allow ap_getopt to work correctly + /* Set optreset and optind to allow apr_getopt to work correctly * when called from http_main.c */ ap_optreset = 1; @@ -2010,7 +2010,7 @@ void winnt_rewrite_args(process_rec *process) } -static void winnt_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp) +static void winnt_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp) { /* Handle the following SCM aspects in this phase: * @@ -2020,7 +2020,7 @@ static void winnt_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp * * in these cases we -don't- care if httpd.conf has config errors! */ - ap_status_t rv; + apr_status_t rv; if (!strcasecmp(signal_arg, "runservice") && (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) @@ -2047,13 +2047,13 @@ static void winnt_pre_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp ap_pid_fname = DEFAULT_PIDLOG; max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD; - ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); } -static void winnt_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptemp, server_rec* server) +static void winnt_post_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec* server) { static int restart_num = 0; - ap_status_t rv = 0; + apr_status_t rv = 0; server_conf = server; @@ -2094,7 +2094,7 @@ static void winnt_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptem * across a restart */ PSECURITY_ATTRIBUTES sa = GetNullACL(); /* returns NULL if invalid (Win95?) */ - setup_signal_names(ap_psprintf(pconf,"ap%d", parent_pid)); + setup_signal_names(apr_psprintf(pconf,"ap%d", parent_pid)); if (osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { /* Create the AcceptEx IoCompletionPort once in the parent. * The completion port persists across restarts. @@ -2163,7 +2163,7 @@ static void winnt_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptem * Ths start mutex is used during a restart to prevent more than one * child process from entering the accept loop at once. */ - ap_create_lock(&start_mutex,APR_MUTEX, APR_CROSS_PROCESS, signal_name_prefix, + apr_create_lock(&start_mutex,APR_MUTEX, APR_CROSS_PROCESS, signal_name_prefix, server_conf->process->pool); } } @@ -2173,7 +2173,7 @@ static void winnt_post_config(ap_pool_t *pconf, ap_pool_t *plog, ap_pool_t *ptem } } -API_EXPORT(int) ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s ) +API_EXPORT(int) ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s ) { static int restart = 0; /* Default is "not a restart" */ @@ -2202,7 +2202,7 @@ API_EXPORT(int) ap_mpm_run(ap_pool_t *_pconf, ap_pool_t *plog, server_rec *s ) server_conf, "removed PID file %s (pid=%ld)", pidfile, GetCurrentProcessId()); } - ap_destroy_lock(start_mutex); + apr_destroy_lock(start_mutex); CloseHandle(restart_event); CloseHandle(shutdown_event); @@ -2280,7 +2280,7 @@ static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg) static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) { - ap_finfo_t finfo; + apr_finfo_t finfo; const char *fname; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { @@ -2288,12 +2288,12 @@ static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg) } fname = ap_server_root_relative(cmd->pool, arg); - if ((ap_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || + if ((apr_stat(&finfo, fname, cmd->pool) != APR_SUCCESS) || (finfo.filetype != APR_DIR)) { - return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, + return apr_pstrcat(cmd->pool, "CoreDumpDirectory ", fname, " does not exist or is not a directory", NULL); } - ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); + apr_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir)); return NULL; } @@ -2310,7 +2310,7 @@ API_EXPORT(void) ap_reset_connection_status(long conn_id) /* NOP */ } -API_EXPORT(ap_array_header_t *) ap_get_status_table(ap_pool_t *p) +API_EXPORT(apr_array_header_t *) ap_get_status_table(apr_pool_t *p) { /* NOP */ return NULL; @@ -2336,7 +2336,7 @@ MODULE_VAR_EXPORT module mpm_winnt_module = { NULL, /* merge per-directory config structures */ NULL, /* create per-server config structure */ NULL, /* merge per-server config structures */ - winnt_cmds, /* command ap_table_t */ + winnt_cmds, /* command apr_table_t */ NULL, /* handlers */ winnt_hooks /* register_hooks */ }; diff --git a/server/mpm/winnt/mpm_winnt.h b/server/mpm/winnt/mpm_winnt.h index 4beb22c346..4d6c753130 100644 --- a/server/mpm/winnt/mpm_winnt.h +++ b/server/mpm/winnt/mpm_winnt.h @@ -59,24 +59,24 @@ #ifndef APACHE_MPM_WINNT_H #define APACHE_MPM_WINNT_H -#include "ap_listen.h" +#include "apr_listen.h" /* From registry.c: */ -ap_status_t ap_registry_create_key(const char *key); -ap_status_t ap_registry_delete_key(const char *key); +apr_status_t ap_registry_create_key(const char *key); +apr_status_t ap_registry_delete_key(const char *key); -ap_status_t ap_registry_store_value(const char *key, const char *name, +apr_status_t ap_registry_store_value(const char *key, const char *name, const char *value); -ap_status_t ap_registry_get_value(ap_pool_t *p, const char *key, +apr_status_t ap_registry_get_value(apr_pool_t *p, const char *key, const char *name, char **ppValue); -ap_status_t ap_registry_store_array(ap_pool_t *p, const char *key, +apr_status_t ap_registry_store_array(apr_pool_t *p, const char *key, const char *name, int nelts, char const* const* elts); -ap_status_t ap_registry_get_array(ap_pool_t *p, const char *key, +apr_status_t ap_registry_get_array(apr_pool_t *p, const char *key, const char *name, - ap_array_header_t **parray); -ap_status_t ap_registry_delete_value(const char *key, const char *name); + apr_array_header_t **parray); +apr_status_t ap_registry_delete_value(const char *key, const char *name); /* From service.c: */ @@ -91,20 +91,20 @@ ap_status_t ap_registry_delete_value(const char *key, const char *name); extern char *service_name; extern char *display_name; -ap_status_t mpm_service_set_name(ap_pool_t *p, char *name); -ap_status_t mpm_merge_service_args(ap_pool_t *p, ap_array_header_t *args, +apr_status_t mpm_service_set_name(apr_pool_t *p, char *name); +apr_status_t mpm_merge_service_args(apr_pool_t *p, apr_array_header_t *args, int fixed_args); -ap_status_t mpm_service_to_start(void); -ap_status_t mpm_service_started(void); -ap_status_t mpm_service_install(ap_pool_t *ptemp, int argc, +apr_status_t mpm_service_to_start(void); +apr_status_t mpm_service_started(void); +apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc, char const* const* argv); -ap_status_t mpm_service_uninstall(void); +apr_status_t mpm_service_uninstall(void); -ap_status_t mpm_service_start(ap_pool_t *ptemp, int argc, +apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc, char const* const* argv); -void mpm_signal_service(ap_pool_t *ptemp, int signal); +void mpm_signal_service(apr_pool_t *ptemp, int signal); void mpm_service_stopping(void); @@ -128,12 +128,12 @@ void signal_parent(int type); typedef struct CompContext { OVERLAPPED Overlapped; SOCKET accept_socket; - ap_socket_t *sock; + apr_socket_t *sock; ap_listen_rec *lr; BUFF *conn_io; char *recv_buf; int recv_buf_size; - ap_pool_t *ptrans; + apr_pool_t *ptrans; struct sockaddr *sa_server; int sa_server_len; struct sockaddr *sa_client; diff --git a/server/mpm/winnt/registry.c b/server/mpm/winnt/registry.c index d51cbcf6a3..be0bfaa1db 100644 --- a/server/mpm/winnt/registry.c +++ b/server/mpm/winnt/registry.c @@ -97,7 +97,7 @@ */ #define return_error(rv) return (SetLastError(rv), rv); -ap_status_t ap_registry_create_key(const char *key) +apr_status_t ap_registry_create_key(const char *key) { HKEY hKey = HKEY_LOCAL_MACHINE; HKEY hKeyNext; @@ -107,7 +107,7 @@ ap_status_t ap_registry_create_key(const char *key) DWORD result; int rv; - ap_cpystrn(keystr, key, sizeof(keystr) - 1); + apr_cpystrn(keystr, key, sizeof(keystr) - 1); /* Walk the tree, creating at each stage if necessary */ while (parsekey) { @@ -141,15 +141,15 @@ ap_status_t ap_registry_create_key(const char *key) return_error(rv); } -ap_status_t ap_registry_delete_key(const char *key) +apr_status_t ap_registry_delete_key(const char *key) { - ap_status_t rv; + apr_status_t rv; HKEY hKey; int nSize = 0; char tempkey[MAX_PATH + 1]; char *parsekey; - ap_cpystrn(tempkey, key, sizeof(parsekey) - 1); + apr_cpystrn(tempkey, key, sizeof(parsekey) - 1); parsekey = strrchr(tempkey, '\\'); if (parsekey) { @@ -184,9 +184,9 @@ ap_status_t ap_registry_delete_key(const char *key) * The return value is APR_SUCCESS, APR_ENOPATH, APR_NOTFOUND, or the OS error */ -ap_status_t ap_registry_get_value(ap_pool_t *p, const char *key, const char *name, char **ppValue) +apr_status_t ap_registry_get_value(apr_pool_t *p, const char *key, const char *name, char **ppValue) { - ap_status_t rv; + apr_status_t rv; HKEY hKey; int nSize = 0; @@ -216,7 +216,7 @@ ap_status_t ap_registry_get_value(ap_pool_t *p, const char *key, const char *nam if (rv != ERROR_SUCCESS) return_error(rv); - *ppValue = ap_palloc(p, nSize); + *ppValue = apr_palloc(p, nSize); rv = RegQueryValueEx(hKey, name, /* key name */ NULL, /* reserved */ @@ -232,12 +232,12 @@ ap_status_t ap_registry_get_value(ap_pool_t *p, const char *key, const char *nam return_error(rv); } -ap_status_t ap_registry_get_array(ap_pool_t *p, const char *key, const char *name, ap_array_header_t **parray) +apr_status_t ap_registry_get_array(apr_pool_t *p, const char *key, const char *name, apr_array_header_t **parray) { char *pValue; char *tmp; char **newelem; - ap_status_t rv; + apr_status_t rv; HKEY hKey; int nSize = 0; @@ -272,7 +272,7 @@ ap_status_t ap_registry_get_array(ap_pool_t *p, const char *key, const char *nam } else { - pValue = ap_palloc(p, nSize); + pValue = apr_palloc(p, nSize); rv = RegQueryValueEx(hKey, name, /* key name */ NULL, /* reserved */ @@ -289,14 +289,14 @@ ap_status_t ap_registry_get_array(ap_pool_t *p, const char *key, const char *nam ++tmp; } - *parray = ap_make_array(p, nSize, sizeof(char *)); + *parray = apr_make_array(p, nSize, sizeof(char *)); tmp = pValue; - newelem = (char **) ap_push_array(*parray); + newelem = (char **) apr_push_array(*parray); *newelem = tmp; while (tmp[0] || tmp[1]) { if (!tmp[0]) { - newelem = (char **) ap_push_array(*parray); + newelem = (char **) apr_push_array(*parray); *newelem = tmp + 1; } ++tmp; @@ -323,7 +323,7 @@ ap_status_t ap_registry_get_array(ap_pool_t *p, const char *key, const char *nam * logged via aplog_error(). */ -ap_status_t ap_registry_store_value(const char *key, const char *name, const char *value) +apr_status_t ap_registry_store_value(const char *key, const char *name, const char *value) { long rv; HKEY hKey; @@ -375,7 +375,7 @@ ap_status_t ap_registry_store_value(const char *key, const char *name, const cha return_error(rv); } -ap_status_t ap_registry_store_array(ap_pool_t *p, const char *key, const char *name, int nelts, char const* const* elts) +apr_status_t ap_registry_store_array(apr_pool_t *p, const char *key, const char *name, int nelts, char const* const* elts) { int bufsize, i; char *buf, *tmp; @@ -416,7 +416,7 @@ ap_status_t ap_registry_store_array(ap_pool_t *p, const char *key, const char *n if (!nelts) ++bufsize; - buf = ap_palloc(p, bufsize); + buf = apr_palloc(p, bufsize); tmp = buf; for (i = 0; i < nelts; ++i) { @@ -450,9 +450,9 @@ ap_status_t ap_registry_store_array(ap_pool_t *p, const char *key, const char *n /* A key or value that does not exist is _not_ an error while deleting. */ -ap_status_t ap_registry_delete_value(const char *key, const char *name) +apr_status_t ap_registry_delete_value(const char *key, const char *name) { - ap_status_t rv; + apr_status_t rv; HKEY hKey; rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE, @@ -483,9 +483,9 @@ ap_status_t ap_registry_delete_value(const char *key, const char *name) * dir will contain an empty string), or -1 if there was * an error getting the key. */ -ap_status_t ap_registry_get_server_root(ap_pool_t *p, char **buf) +apr_status_t ap_registry_get_server_root(apr_pool_t *p, char **buf) { - ap_status_t rv; + apr_status_t rv; rv = ap_registry_get_value(p, REGKEY, "ServerRoot", buf); if (rv) @@ -501,7 +501,7 @@ ap_status_t ap_registry_get_server_root(ap_pool_t *p, char **buf) * logged via aplog_error(). */ -ap_status_t ap_registry_set_server_root(char *dir) +apr_status_t ap_registry_set_server_root(char *dir) { return ap_registry_store_value(REGKEY, "ServerRoot", dir); } diff --git a/server/mpm/winnt/service.c b/server/mpm/winnt/service.c index 3e5b177008..aec1d49a8c 100644 --- a/server/mpm/winnt/service.c +++ b/server/mpm/winnt/service.c @@ -512,7 +512,7 @@ long __stdcall service_stderr_thread(LPVOID hPipe) * primary server thread... so now we _really_ need a placeholder! * The winnt_rewrite_args has created and shared mpm_new_argv with us. */ -extern ap_array_header_t *mpm_new_argv; +extern apr_array_header_t *mpm_new_argv; static void __stdcall service_nt_main_fn(DWORD argc, LPTSTR *argv) { @@ -592,7 +592,7 @@ static void __stdcall service_nt_main_fn(DWORD argc, LPTSTR *argv) if (argc > 1) { char **cmb_data; - cmb_data = ap_palloc(mpm_new_argv->cont, + cmb_data = apr_palloc(mpm_new_argv->cont, (mpm_new_argv->nelts + argc - 1) * sizeof(char *)); /* mpm_new_argv remains first (of lower significance) */ @@ -624,7 +624,7 @@ static void __stdcall service_nt_main_fn(DWORD argc, LPTSTR *argv) DWORD WINAPI service_nt_dispatch_thread(LPVOID nada) { - ap_status_t rv = APR_SUCCESS; + apr_status_t rv = APR_SUCCESS; SERVICE_TABLE_ENTRY dispatchTable[] = { @@ -645,32 +645,32 @@ DWORD WINAPI service_nt_dispatch_thread(LPVOID nada) } -ap_status_t mpm_service_set_name(ap_pool_t *p, char *name) +apr_status_t mpm_service_set_name(apr_pool_t *p, char *name) { char *key_name; - service_name = ap_palloc(p, strlen(name) + 1); - ap_collapse_spaces(service_name, name); - key_name = ap_psprintf(p, SERVICECONFIG, service_name); + service_name = apr_palloc(p, strlen(name) + 1); + apr_collapse_spaces(service_name, name); + key_name = apr_psprintf(p, SERVICECONFIG, service_name); if (ap_registry_get_value(p, key_name, "DisplayName", &display_name) == APR_SUCCESS) return APR_SUCCESS; /* Take the given literal name if there is no service entry */ - display_name = ap_pstrdup(p, name); + display_name = apr_pstrdup(p, name); return APR_ENOFILE; } -ap_status_t mpm_merge_service_args(ap_pool_t *p, - ap_array_header_t *args, +apr_status_t mpm_merge_service_args(apr_pool_t *p, + apr_array_header_t *args, int fixed_args) { - ap_array_header_t *svc_args = NULL; + apr_array_header_t *svc_args = NULL; char conf_key[MAX_PATH]; char **cmb_data; - ap_status_t rv; + apr_status_t rv; - ap_snprintf(conf_key, sizeof(conf_key), SERVICEPARAMS, service_name); + apr_snprintf(conf_key, sizeof(conf_key), SERVICEPARAMS, service_name); rv = ap_registry_get_array(p, conf_key, "ConfigArgs", &svc_args); if (rv != APR_SUCCESS) { // TODO: More message? @@ -686,7 +686,7 @@ ap_status_t mpm_merge_service_args(ap_pool_t *p, * time to _prepend_ the default arguments for the server from * the service's default arguments (all others override them)... */ - cmb_data = ap_palloc(p, (args->nelts + svc_args->nelts) * sizeof(char *)); + cmb_data = apr_palloc(p, (args->nelts + svc_args->nelts) * sizeof(char *)); /* First three args (argv[0], -f, path) remain first */ memcpy (cmb_data, args->elts, args->elt_size * fixed_args); @@ -733,7 +733,7 @@ void service_stopped(void) } -ap_status_t mpm_service_to_start(void) +apr_status_t mpm_service_to_start(void) { HANDLE waitfor[2]; @@ -782,7 +782,7 @@ ap_status_t mpm_service_to_start(void) } -ap_status_t mpm_service_started(void) +apr_status_t mpm_service_started(void) { if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) { @@ -803,19 +803,19 @@ void mpm_service_stopping(void) } -ap_status_t mpm_service_install(ap_pool_t *ptemp, int argc, +apr_status_t mpm_service_install(apr_pool_t *ptemp, int argc, char const* const* argv) { char key_name[MAX_PATH]; char exe_path[MAX_PATH]; char *launch_cmd; - ap_status_t(rv); + apr_status_t(rv); printf("Installing the %s service\n", display_name); if (GetModuleFileName(NULL, exe_path, sizeof(exe_path)) == 0) { - ap_status_t rv = GetLastError(); + apr_status_t rv = GetLastError(); ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, "GetModuleFileName failed"); return rv; @@ -836,7 +836,7 @@ ap_status_t mpm_service_install(ap_pool_t *ptemp, int argc, return (rv); } - launch_cmd = ap_psprintf(ptemp, "\"%s\" -k runservice", exe_path); + launch_cmd = apr_psprintf(ptemp, "\"%s\" -k runservice", exe_path); /* RPCSS is the Remote Procedure Call (RPC) Locator required for DCOM * communication pipes. I am far from convinced we should add this to @@ -872,7 +872,7 @@ ap_status_t mpm_service_install(ap_pool_t *ptemp, int argc, else /* osver.dwPlatformId != VER_PLATFORM_WIN32_NT */ { /* Store the launch command in the registry */ - launch_cmd = ap_psprintf(ptemp, "\"%s\" -n %s -k runservice", + launch_cmd = apr_psprintf(ptemp, "\"%s\" -n %s -k runservice", exe_path, service_name); rv = ap_registry_store_value(SERVICECONFIG9X, service_name, launch_cmd); if (rv != APR_SUCCESS) { @@ -882,7 +882,7 @@ ap_status_t mpm_service_install(ap_pool_t *ptemp, int argc, return (rv); } - ap_snprintf(key_name, sizeof(key_name), SERVICECONFIG, service_name); + apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, service_name); rv = ap_registry_store_value(key_name, "DisplayName", display_name); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, @@ -894,7 +894,7 @@ ap_status_t mpm_service_install(ap_pool_t *ptemp, int argc, /* For both WinNT & Win9x store the service ConfigArgs in the registry... */ - ap_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, service_name); + apr_snprintf(key_name, sizeof(key_name), SERVICEPARAMS, service_name); rv = ap_registry_store_array(ptemp, key_name, "ConfigArgs", argc, argv); if (rv != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, @@ -906,10 +906,10 @@ ap_status_t mpm_service_install(ap_pool_t *ptemp, int argc, } -ap_status_t mpm_service_uninstall(void) +apr_status_t mpm_service_uninstall(void) { char key_name[MAX_PATH]; - ap_status_t rv; + apr_status_t rv; if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT) { @@ -972,7 +972,7 @@ ap_status_t mpm_service_uninstall(void) } /* we blast Services/us, not just the Services/us/Parameters branch */ - ap_snprintf(key_name, sizeof(key_name), SERVICECONFIG, service_name); + apr_snprintf(key_name, sizeof(key_name), SERVICECONFIG, service_name); if (ap_registry_delete_key(key_name)) { rv = GetLastError(); @@ -1009,10 +1009,10 @@ static int signal_service_transition(SC_HANDLE schService, DWORD signal, DWORD p } -ap_status_t mpm_service_start(ap_pool_t *ptemp, int argc, +apr_status_t mpm_service_start(apr_pool_t *ptemp, int argc, char const* const* argv) { - ap_status_t rv; + apr_status_t rv; printf("Starting the %s service\n", display_name); @@ -1052,7 +1052,7 @@ ap_status_t mpm_service_start(ap_pool_t *ptemp, int argc, } argc += 1; - start_argv = ap_palloc(ptemp, argc * sizeof(char**)); + start_argv = apr_palloc(ptemp, argc * sizeof(char**)); start_argv[0] = service_name; if (argc > 1) memcpy(start_argv + 1, argv, (argc - 1) * sizeof(char**)); @@ -1096,16 +1096,16 @@ ap_status_t mpm_service_start(ap_pool_t *ptemp, int argc, if (GetModuleFileName(NULL, exe_path, sizeof(exe_path)) == 0) { - ap_status_t rv = GetLastError(); + apr_status_t rv = GetLastError(); ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_STARTUP, rv, NULL, "GetModuleFileName failed"); return rv; } - pCommand = ap_psprintf(ptemp, "\"%s\" -n %s -k runservice", + pCommand = apr_psprintf(ptemp, "\"%s\" -n %s -k runservice", exe_path, service_name); for (i = 0; i < argc; ++i) { - pCommand = ap_pstrcat(ptemp, pCommand, " \"", argv[i], "\"", NULL); + pCommand = apr_pstrcat(ptemp, pCommand, " \"", argv[i], "\"", NULL); } memset(&si, 0, sizeof(si)); @@ -1149,7 +1149,7 @@ ap_status_t mpm_service_start(ap_pool_t *ptemp, int argc, /* signal is zero to stop, non-zero for restart */ -void mpm_signal_service(ap_pool_t *ptemp, int signal) +void mpm_signal_service(apr_pool_t *ptemp, int signal) { int success = FALSE; @@ -1239,7 +1239,7 @@ void mpm_signal_service(ap_pool_t *ptemp, int signal) printf("The %s service is %s.\n", display_name, signal ? "restarting" : "stopping"); - ap_snprintf(prefix, sizeof(prefix), "ap%ld", (long)service_pid); + apr_snprintf(prefix, sizeof(prefix), "ap%ld", (long)service_pid); setup_signal_names(prefix); if (!signal) |