nginx-0.0.2-2004-03-04-19:34:23 import
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 3210819..d49ba32 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_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 @@
"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_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 @@
}
-#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 62c6b90..7ec558a 100644
--- a/src/os/unix/ngx_process.h
+++ b/src/os/unix/ngx_process.h
@@ -42,7 +42,7 @@
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 8e8bec6..6ee6c9a 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -95,7 +95,7 @@
if (ngx_modules[i]->init_process) {
if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
/* fatal */
- exit(1);
+ exit(2);
}
}
}
@@ -418,7 +418,7 @@
if (ngx_modules[i]->init_process) {
if (ngx_modules[i]->init_process(cycle) == NGX_ERROR) {
/* fatal */
- exit(1);
+ exit(2);
}
}
}
@@ -429,7 +429,7 @@
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 @@
cycle, cycle->log) != 0)
{
/* fatal */
- exit(1);
+ exit(2);
}
}
@@ -494,8 +494,23 @@
{
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 a85750d..841636a 100644
--- a/src/os/unix/ngx_thread.h
+++ b/src/os/unix/ngx_thread.h
@@ -36,6 +36,12 @@
} 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 @@
#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
diff --git a/src/os/win32/ngx_process.h b/src/os/win32/ngx_process.h
index 35d9bb9..c858768 100644
--- a/src/os/win32/ngx_process.h
+++ b/src/os/win32/ngx_process.h
@@ -21,7 +21,7 @@
#define NGX_PROCESS_WORKER 2
-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);
extern ngx_pid_t ngx_pid;
diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h
index 00f6426..2af600d 100644
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -40,10 +40,9 @@
#define ngx_inline __inline
-#if 1
+#ifdef _MSC_VER
typedef unsigned __int32 uint32_t;
-#else
-/* OWC has not __int32 */
+#else /* __WATCOMC__ */
typedef unsigned int uint32_t;
#endif