diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.c | 18 | ||||
| -rw-r--r-- | src/core/ngx_atomic.h | 12 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.c | 7 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.h | 2 | ||||
| -rw-r--r-- | src/core/ngx_cycle.h | 5 |
5 files changed, 28 insertions, 16 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index a19695ccf..8dc610240 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -36,18 +36,18 @@ static ngx_command_t ngx_core_commands[] = { offsetof(ngx_core_conf_t, master), NULL }, - { ngx_string("pid"), + { ngx_string("worker_processes"), NGX_MAIN_CONF|NGX_CONF_TAKE1, - ngx_conf_set_core_str_slot, + ngx_conf_set_core_num_slot, 0, - offsetof(ngx_core_conf_t, pid), + offsetof(ngx_core_conf_t, worker_processes), NULL }, - { ngx_string("worker_reopen"), + { ngx_string("pid"), NGX_MAIN_CONF|NGX_CONF_TAKE1, - ngx_conf_set_core_flag_slot, + ngx_conf_set_core_str_slot, 0, - offsetof(ngx_core_conf_t, worker_reopen), + offsetof(ngx_core_conf_t, pid), NULL }, ngx_null_command @@ -174,6 +174,10 @@ int main(int argc, char *const *argv) } } + 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 @@ static ngx_int_t ngx_core_module_init(ngx_cycle_t *cycle) */ 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 31bf94c45..b95e4cc46 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 @@ static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value) { 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 @@ static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value) { 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 63918673c..8f409eae5 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -571,6 +571,13 @@ char *ngx_conf_set_core_flag_slot(ngx_conf_t *cf, ngx_command_t *cmd, } +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 ee90855e7..ed73803a9 100644 --- a/src/core/ngx_conf_file.h +++ b/src/core/ngx_conf_file.h @@ -256,6 +256,8 @@ char *ngx_conf_set_bitmask_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); 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 2ea229ea4..df1f39033 100644 --- a/src/core/ngx_cycle.h +++ b/src/core/ngx_cycle.h @@ -28,9 +28,12 @@ struct ngx_cycle_s { 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; |
