int ap_max_child_assigned = -1;
int ap_max_threads_limit = -1;
char ap_coredump_dir[MAX_STRING_LEN];
-static port_id port_of_death;
+static volatile bool flag_of_death;
/* shared http_main globals... */
}
/* do a graceful restart if graceful == 1 */
-void ap_start_restart(int graceful)
+static void ap_start_restart(int graceful)
{
if (restart_pending == 1) {
static void tell_workers_to_exit(void)
{
- int i, code = 99;
-
- for (i=0;i<ap_max_child_assigned;i++) {
- if (ap_child_table[i].pid)
- write_port(port_of_death, code, NULL, 0);
- }
+ flag_of_death = true;
}
static void push_workers_off_cliff(int sig)
ap_lingering_close(current_conn);
}
-/* call_samaritans checks to see if there's a message waiting on the
- * port_of_death. If there is then it return 1 and the worker thread
- * should consider itself told to die. I use the _etc call to stop this
- * from blocking the calling thread. As we've already checked I just use
- * the basic read_port to actually remove the message from the queue.
- */
-static int call_samaritans(port_id port) {
- if (port_buffer_size_etc(port, B_TIMEOUT, 0) != B_WOULD_BLOCK) {
- int32 code;
- read_port(port, &code, NULL, 0);
- return 1;
- }
- return 0;
-}
-
static int32 worker_thread(void * dummy)
{
proc_info * ti = dummy;
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");
free(ti);
/* block the signals for this thread */
worker_thread_count++;
apr_unlock(worker_thread_count_mutex);
- /* now setup our own pollset...this will use APR woohoo! */
apr_setup_poll(&pollset, num_listening_sockets, tpool);
for(n=0 ; n < num_listening_sockets ; ++n)
apr_add_poll_socket(pollset, listening_sockets[n], APR_POLLIN);
apr_int16_t event;
apr_status_t ret = apr_poll(pollset, &srv, -1);
- if (call_samaritans(chk))
+ if (flag_of_death)
this_worker_should_exit = 1;
if (ret != APR_SUCCESS) {
pconf = _pconf;
ap_server_conf = s;
- if ((port_of_death = create_port(ap_thread_limit, "the_samaritans")) < 0){
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, s,
- "couldn't create a port_of_death, shutting down");
- return 1;
- }
-
if ((num_listening_sockets = ap_setup_listeners(ap_server_conf)) < 1) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
"no listening sockets available, shutting down");
}
ap_log_pid(pconf, ap_pid_fname);
-
+
+ flag_of_death = false;
+
/*
* Create our locks...
*/
* potential leak of semaphores... */
apr_destroy_lock(worker_thread_count_mutex);
apr_destroy_lock(accept_mutex);
- delete_port(port_of_death);
return 0;
}
}
static const command_rec beos_cmds[] = {
-UNIX_DAEMON_COMMANDS
LISTEN_COMMANDS
AP_INIT_TAKE1( "PidFile", set_pidfile, NULL, RSRC_CONF,
"A file for logging the server process ID"),
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
beos_cmds, /* command apr_table_t */
- NULL, /* handlers */
beos_hooks /* register_hooks */
};