mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 06:03:31 -06:00
nginx-0.0.3-2004-03-31-00:31:58 import
This commit is contained in:
parent
6707ba9072
commit
a741f8d021
@ -36,6 +36,13 @@ static ngx_command_t ngx_core_commands[] = {
|
||||
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 @@ static ngx_command_t ngx_core_commands[] = {
|
||||
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 @@ 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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -193,7 +193,7 @@ int ngx_event_connect_peer(ngx_peer_connection_t *pc)
|
||||
* 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) {
|
||||
|
@ -1405,7 +1405,10 @@ static char *ngx_set_root(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
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);
|
||||
|
@ -68,9 +68,14 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
||||
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 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
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 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
||||
|
||||
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 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle, ngx_master_ctx_t *ctx)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user