nginx-0.0.3-2004-03-31-00:31:58 import
diff --git a/src/core/nginx.c b/src/core/nginx.c
index a19695c..8dc6102 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -36,6 +36,13 @@
offsetof(ngx_core_conf_t, master),
NULL },
+ { ngx_string("worker_processes"),
+ NGX_MAIN_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_core_num_slot,
+ 0,
+ offsetof(ngx_core_conf_t, worker_processes),
+ NULL },
+
{ ngx_string("pid"),
NGX_MAIN_CONF|NGX_CONF_TAKE1,
ngx_conf_set_core_str_slot,
@@ -43,13 +50,6 @@
offsetof(ngx_core_conf_t, pid),
NULL },
- { ngx_string("worker_reopen"),
- NGX_MAIN_CONF|NGX_CONF_TAKE1,
- ngx_conf_set_core_flag_slot,
- 0,
- offsetof(ngx_core_conf_t, worker_reopen),
- NULL },
-
ngx_null_command
};
@@ -174,6 +174,10 @@
}
}
+ if (ccf->worker_processes == NGX_CONF_UNSET) {
+ ccf->worker_processes = 1;
+ }
+
if (ccf->pid.len == 0) {
ccf->pid.len = sizeof(NGINX_PID) - 1;
ccf->pid.data = NGINX_PID;
@@ -361,7 +365,7 @@
*/
ccf->daemon = NGX_CONF_UNSET;
ccf->master = NGX_CONF_UNSET;
- ccf->worker_reopen = NGX_CONF_UNSET;
+ ccf->worker_processes = NGX_CONF_UNSET;
ccf->user = (ngx_uid_t) NGX_CONF_UNSET;
ccf->group = (ngx_gid_t) NGX_CONF_UNSET;
diff --git a/src/core/ngx_atomic.h b/src/core/ngx_atomic.h
index 31bf94c..b95e4cc 100644
--- a/src/core/ngx_atomic.h
+++ b/src/core/ngx_atomic.h
@@ -11,7 +11,7 @@
typedef volatile uint32_t ngx_atomic_t;
#if (NGX_SMP)
-#define NGX_SMP_LOCK "lock"
+#define NGX_SMP_LOCK "lock;"
#else
#define NGX_SMP_LOCK
#endif
@@ -21,14 +21,12 @@
{
uint32_t old;
- old = 1;
-
__asm__ volatile (
NGX_SMP_LOCK
- " xaddl %0, %1; "
+ " xaddl %0, %2; "
- : "+q" (old) : "m" (*value));
+ : "=q" (old) : "0" (1), "m" (*value));
return old;
}
@@ -38,14 +36,12 @@
{
uint32_t old;
- old = (uint32_t) -1;
-
__asm__ volatile (
NGX_SMP_LOCK
" xaddl %0, %1; "
- : "+q" (old) : "m" (*value));
+ : "=q" (old) : "0" (-1), "m" (*value));
return old;
}
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index 6391867..8f409ea 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -571,6 +571,13 @@
}
+char *ngx_conf_set_core_num_slot(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf)
+{
+ return ngx_conf_set_num_slot(cf, cmd, *(void **)conf);
+}
+
+
char *ngx_conf_set_core_str_slot(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf)
{
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index ee90855..ed73803 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -256,6 +256,8 @@
char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
+char *ngx_conf_set_core_num_slot(ngx_conf_t *cf, ngx_command_t *cmd,
+ void *conf);
char *ngx_conf_set_core_str_slot(ngx_conf_t *cf, ngx_command_t *cmd,
void *conf);
diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h
index 2ea229e..df1f390 100644
--- a/src/core/ngx_cycle.h
+++ b/src/core/ngx_cycle.h
@@ -28,9 +28,12 @@
typedef struct {
ngx_flag_t daemon;
ngx_flag_t master;
- ngx_flag_t worker_reopen;
+
+ ngx_int_t worker_processes;
+
ngx_uid_t user;
ngx_gid_t group;
+
ngx_str_t pid;
ngx_str_t newpid;
} ngx_core_conf_t;
diff --git a/src/event/ngx_event_connect.c b/src/event/ngx_event_connect.c
index 586f560..a433e1d 100644
--- a/src/event/ngx_event_connect.c
+++ b/src/event/ngx_event_connect.c
@@ -193,7 +193,7 @@
* or protection by critical section or mutex
*/
- c->number = ngx_connection_counter++;
+ c->number = ngx_atomic_inc(&ngx_connection_counter);
if (ngx_add_conn) {
if (ngx_add_conn(c) == NGX_ERROR) {
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
index 48b7ba4..1f449e2 100644
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -1405,7 +1405,10 @@
alias = (cmd->name.len == sizeof("alias") - 1) ? 1 : 0;
if (lcf->root.data) {
- if (lcf->alias == alias) {
+
+ /* the (ngx_uint_t) cast is required by gcc 2.7.2.3 */
+
+ if ((ngx_uint_t) lcf->alias == alias) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"%s\" directive is duplicate",
cmd->name.data);
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index e4d95ad..cc3d8a4 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -68,9 +68,14 @@
for ( ;; ) {
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "new cycle");
+ ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
+ ngx_core_module);
+
if (ngx_process == NGX_PROCESS_MASTER) {
- ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
- "worker process", NGX_PROCESS_RESPAWN);
+ for (i = 0; i < (ngx_uint_t) ccf->worker_processes; i++) {
+ ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
+ "worker process", NGX_PROCESS_RESPAWN);
+ }
/*
* we have to limit the maximum life time of the worker processes
@@ -103,8 +108,6 @@
}
}
- ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx,
- ngx_core_module);
/* a cycle with the same configuration because a new one is invalid */
@@ -253,16 +256,8 @@
if (ngx_reopen) {
if (ngx_process == NGX_PROCESS_MASTER) {
- if (ccf->worker_reopen != 0) {
- signo = ngx_signal_value(NGX_REOPEN_SIGNAL);
- ngx_reopen = 0;
-
- } else if (ngx_noaccept) {
- ngx_reopen = 0;
-
- } else {
- signo = ngx_signal_value(NGX_SHUTDOWN_SIGNAL);
- }
+ signo = ngx_signal_value(NGX_REOPEN_SIGNAL);
+ ngx_reopen = 0;
} else { /* NGX_PROCESS_SINGLE */
ngx_reopen = 0;
@@ -270,8 +265,7 @@
ngx_log_error(NGX_LOG_INFO, cycle->log, 0,
"reopening logs");
- ngx_reopen_files(cycle,
- ccf->worker_reopen != 0 ? ccf->user : (uid_t) -1);
+ ngx_reopen_files(cycle, ccf->user);
}
}