/* each worker thread is in control of it's own destiny...*/
int this_worker_should_exit = 0;
free(ti);
-
+
/* block the signals for this thread */
sigfillset(&sig_mask);
sigprocmask(SIG_BLOCK, &sig_mask, NULL);
* a seperate pool of it's own to use.
*/
apr_pool_create(&pchild, pconf);
- ap_run_child_init(pchild, ap_server_conf);
/* Now that we have the child pool (pchild) we can allocate
* the listenfds and creat the pollset...
listening_sockets[i]=lr->sd;
/* we assume all goes OK...hmm might want to check that! */
- if (!is_graceful) {
+ /* if we're in one_process mode we don't want to start threads
+ * do we??
+ */
+ if (!is_graceful && !one_process) {
startup_threads(remaining_threads_to_start);
remaining_threads_to_start = 0;
}
/*
* main_loop until it's all over
*/
- server_main_loop(remaining_threads_to_start);
+ if (!one_process) {
+ server_main_loop(remaining_threads_to_start);
- tell_workers_to_exit(); /* if we get here we're exiting... */
- sleep(1); /* give them a brief chance to exit */
-
+ tell_workers_to_exit(); /* if we get here we're exiting... */
+ sleep(1); /* give them a brief chance to exit */
+ } else {
+ proc_info *my_info = (proc_info *)malloc(sizeof(proc_info));
+ my_info->slot = 0;
+ apr_pool_create(&my_info->tpool, pchild);
+ worker_thread(my_info);
+ }
+
/* close the UDP socket we've been using... */
apr_socket_close(listening_sockets[0]);
+
+ if (one_process || shutdown_pending) {
+ const char *pidfile = NULL;
+ pidfile = ap_server_root_relative (pconf, ap_pid_fname);
+ if ( pidfile != NULL && unlink(pidfile) == 0)
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, ap_server_conf,
+ "removed PID file %s (pid=%ld)", pidfile,
+ (long)getpid());
+ }
+
+ if (one_process) {
+ return 1;
+ }
/*
* If we get here we're shutting down...
if (beosd_killpg(getpgrp(), SIGTERM) < 0)
ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf,
"killpg SIGTERM");
-
- /* cleanup pid file on normal shutdown */
- {
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO,
- 0, ap_server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- }
-
+
/* use ap_reclaim_child_processes starting with SIGTERM */
ap_reclaim_child_processes(1);
/* we've been told to restart */
signal(SIGHUP, SIG_IGN);
- if (one_process) {
- return 1;
- }
-
if (is_graceful) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, ap_server_conf,
"SIGWINCH received. Doing graceful restart");
ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
ap_pid_fname = DEFAULT_PIDLOG;
ap_scoreboard_fname = DEFAULT_SCOREBOARD;
- ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
+ if (!one_process)
+ ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
}