diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2004-03-04 16:34:23 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2004-03-04 16:34:23 +0000 |
| commit | 6a9304522227d4b4df873d3716cf06093d497700 (patch) | |
| tree | bc6a3eb7d26df2048714235ce96b98471b813979 /src/os/unix | |
| parent | a536298c7bd1f525db97facab814a2906214ee7f (diff) | |
| download | nginx-6a9304522227d4b4df873d3716cf06093d497700.tar.gz nginx-6a9304522227d4b4df873d3716cf06093d497700.tar.bz2 | |
nginx-0.0.2-2004-03-04-19:34:23 import
Diffstat (limited to 'src/os/unix')
| -rw-r--r-- | src/os/unix/ngx_process.c | 82 | ||||
| -rw-r--r-- | src/os/unix/ngx_process.h | 2 | ||||
| -rw-r--r-- | src/os/unix/ngx_process_cycle.c | 23 | ||||
| -rw-r--r-- | src/os/unix/ngx_thread.h | 9 |
4 files changed, 33 insertions, 83 deletions
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c index 3210819f7..d49ba3258 100644 --- a/src/os/unix/ngx_process.c +++ b/src/os/unix/ngx_process.c @@ -3,7 +3,7 @@ #include <ngx_core.h> -static void ngx_exec_proc(ngx_cycle_t *cycle, void *data); +static void ngx_execute_proc(ngx_cycle_t *cycle, void *data); ngx_uint_t ngx_last_process; ngx_process_t ngx_processes[NGX_MAX_PROCESSES]; @@ -13,23 +13,8 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data, char *name, ngx_int_t respawn) { -#if 0 - sigset_t set, oset; -#endif ngx_pid_t pid; -#if 0 - if (respawn < 0) { - sigemptyset(&set); - sigaddset(&set, SIGCHLD); - if (sigprocmask(SIG_BLOCK, &set, &oset) == -1) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, - "sigprocmask() failed while spawning %s", name); - return NGX_ERROR; - } - } -#endif - pid = fork(); if (pid == -1) { @@ -37,16 +22,6 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, "fork() failed while spawning \"%s\"", name); } - if (pid == -1 || pid == 0) { -#if 0 - if (sigprocmask(SIG_SETMASK, &oset, &set) == -1) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, - "sigprocmask() failed while spawning %s", name); - return NGX_ERROR; - } -#endif - } - switch (pid) { case -1: return NGX_ERROR; @@ -81,26 +56,18 @@ ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, ngx_processes[ngx_last_process].exiting = 0; ngx_last_process++; -#if 0 - if (sigprocmask(SIG_SETMASK, &oset, &set) == -1) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, - "sigprocmask() failed while spawning %s", name); - return NGX_ERROR; - } -#endif - return pid; } -ngx_pid_t ngx_exec(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx) +ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx) { - return ngx_spawn_process(cycle, ngx_exec_proc, ctx, ctx->name, + return ngx_spawn_process(cycle, ngx_execute_proc, ctx, ctx->name, NGX_PROCESS_DETACHED); } -static void ngx_exec_proc(ngx_cycle_t *cycle, void *data) +static void ngx_execute_proc(ngx_cycle_t *cycle, void *data) { ngx_exec_ctx_t *ctx = data; @@ -114,47 +81,6 @@ static void ngx_exec_proc(ngx_cycle_t *cycle, void *data) } -#if 0 - -void ngx_signal_processes(ngx_cycle_t *cycle) -{ - ngx_uint_t i; - - for (i = 0; i < ngx_last_process; i++) { - - if (ngx_processes[i].signal0 == 0) { - continue; - } - -#if 0 - if (ngx_processes[i].exited) { - if (i != --ngx_last_process) { - ngx_processes[i--] = ngx_processes[ngx_last_process]; - } - continue; - } -#endif - - ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0, - "kill (" PID_T_FMT ", %d)" , - ngx_processes[i].pid, ngx_processes[i].signal0); - - if (kill(ngx_processes[i].pid, ngx_processes[i].signal0) == -1) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, - "kill(%d, %d) failed", - ngx_processes[i].pid, ngx_processes[i].signal0); - continue; - } - - if (ngx_processes[i].signal0 != ngx_signal_value(NGX_REOPEN_SIGNAL)) { - ngx_processes[i].exiting = 1; - } - } -} - -#endif - - void ngx_respawn_processes(ngx_cycle_t *cycle) { ngx_uint_t i; diff --git a/src/os/unix/ngx_process.h b/src/os/unix/ngx_process.h index 62c6b90c0..7ec558a90 100644 --- a/src/os/unix/ngx_process.h +++ b/src/os/unix/ngx_process.h @@ -42,7 +42,7 @@ typedef struct { ngx_pid_t ngx_spawn_process(ngx_cycle_t *cycle, ngx_spawn_proc_pt proc, void *data, char *name, ngx_int_t respawn); -ngx_pid_t ngx_exec(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); +ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); void ngx_respawn_processes(ngx_cycle_t *cycle); void ngx_process_get_status(void); diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index 8e8bec66e..6ee6c9a24 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -95,7 +95,7 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx) if (ngx_modules[i]->init_process) { if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) { /* fatal */ - exit(1); + exit(2); } } } @@ -418,7 +418,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) if (ngx_modules[i]->init_process) { if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) { /* fatal */ - exit(1); + exit(2); } } } @@ -429,7 +429,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) if (ngx_init_threads(5, 128 * 1024 * 1024, cycle) == NGX_ERROR) { /* fatal */ - exit(1); + exit(2); } for (i = 0; i < 1; i++) { @@ -437,7 +437,7 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) cycle, cycle->log) != 0) { /* fatal */ - exit(1); + exit(2); } } @@ -494,8 +494,23 @@ int ngx_worker_thread_cycle(void *data) { ngx_cycle_t *cycle = data; + ngx_err_t err; + sigset_t set; struct timeval tv; + sigfillset(&set); + sigdelset(&set, SIGALRM); + sigdelset(&set, ngx_signal_value(NGX_TERMINATE_SIGNAL)); + sigdelset(&set, ngx_signal_value(NGX_SHUTDOWN_SIGNAL)); + + err = ngx_thread_sigmask(SIG_BLOCK, &set, NULL); + if (err) { + ngx_log_error(NGX_LOG_ALERT, cycle->log, err, + ngx_thread_sigmask_n " failed"); + return 1; + } + + /* STUB */ ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, ngx_errno, diff --git a/src/os/unix/ngx_thread.h b/src/os/unix/ngx_thread.h index a85750d47..841636a04 100644 --- a/src/os/unix/ngx_thread.h +++ b/src/os/unix/ngx_thread.h @@ -36,6 +36,12 @@ typedef volatile struct { } ngx_mutex_t; +#define ngx_thread_sigmask(how, set, oset) \ + (sigprocmask(how, set, oset) == -1) ? ngx_errno : 0 + +#define ngx_thread_sigmask_n "sigprocmask()" + + extern char *ngx_freebsd_kern_usrstack; extern size_t ngx_thread_stack_size; @@ -75,6 +81,9 @@ typedef pthread_t ngx_tid_t; #define ngx_gettid() ((ngx_int_t) pthread_getspecific(0)) #define ngx_log_tid ngx_thread_self() +#define ngx_thread_sigmask pthread_sigmask +#define ngx_thread_sigmask_n "pthread_sigmask()" + #endif |
