summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES11
-rw-r--r--CHANGES.ru11
-rw-r--r--src/core/nginx.h4
-rw-r--r--src/core/ngx_connection.c2
-rw-r--r--src/core/ngx_cycle.c4
-rw-r--r--src/core/ngx_shmtx.c6
-rw-r--r--src/http/modules/ngx_http_dav_module.c5
-rw-r--r--src/http/modules/perl/nginx.pm2
-rw-r--r--src/http/ngx_http_header_filter_module.c2
-rw-r--r--src/http/ngx_http_request_body.c93
-rw-r--r--src/http/ngx_http_special_response.c5
-rw-r--r--src/http/ngx_http_upstream.c11
-rw-r--r--src/http/ngx_http_upstream_round_robin.c4
-rw-r--r--src/http/ngx_http_variables.c81
-rw-r--r--src/os/unix/ngx_files.c4
-rw-r--r--src/os/unix/ngx_process_cycle.c41
16 files changed, 210 insertions, 76 deletions
diff --git a/CHANGES b/CHANGES
index a48f343b7..ca47aeedf 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,15 @@
+Changes with nginx 1.2.6 11 Dec 2012
+
+ *) Feature: the $request_time and $msec variables can now be used not
+ only in the "log_format" directive.
+
+ *) Bugfix: cache manager and cache loader processes might not be able to
+ start if more than 512 listen sockets were used.
+
+ *) Bugfix: in the ngx_http_dav_module.
+
+
Changes with nginx 1.2.5 13 Nov 2012
*) Feature: the "optional_no_ca" parameter of the "ssl_verify_client"
diff --git a/CHANGES.ru b/CHANGES.ru
index cf17e673a..d6c774e5e 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,15 @@
+Изменения в nginx 1.2.6 11.12.2012
+
+ *) Добавление: переменные $request_time и $msec теперь можно
+ использовать не только в директиве log_format.
+
+ *) Исправление: cache manager и cache loader могли не запускаться, если
+ использовалось более 512 listen-сокетов.
+
+ *) Исправление: в модуле ngx_http_dav_module.
+
+
Изменения в nginx 1.2.5 13.11.2012
*) Добавление: параметр optional_no_ca директивы ssl_verify_client.
diff --git a/src/core/nginx.h b/src/core/nginx.h
index bfb8078a1..4d59895ed 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_
-#define nginx_version 1002005
-#define NGINX_VERSION "1.2.5"
+#define nginx_version 1002006
+#define NGINX_VERSION "1.2.6"
#define NGINX_VER "nginx/" NGINX_VERSION
#define NGINX_VAR "NGINX"
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index ba1b3f9e2..3ba5e7682 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -749,6 +749,8 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle)
ls[i].fd = (ngx_socket_t) -1;
}
+
+ cycle->listening.nelts = 0;
}
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index f15372990..e8b155921 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -447,7 +447,9 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
continue;
}
- if (shm_zone[i].shm.size == oshm_zone[n].shm.size) {
+ if (shm_zone[i].tag == oshm_zone[n].tag
+ && shm_zone[i].shm.size == oshm_zone[n].shm.size)
+ {
shm_zone[i].shm.addr = oshm_zone[n].shm.addr;
if (shm_zone[i].init(&shm_zone[i], oshm_zone[n].data)
diff --git a/src/core/ngx_shmtx.c b/src/core/ngx_shmtx.c
index 6cf7af58a..a62999f33 100644
--- a/src/core/ngx_shmtx.c
+++ b/src/core/ngx_shmtx.c
@@ -117,11 +117,11 @@ ngx_shmtx_lock(ngx_shmtx_t *mtx)
"sem_wait() failed while waiting on shmtx");
break;
}
-
- ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
- "shmtx awoke");
}
+ ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
+ "shmtx awoke");
+
continue;
}
diff --git a/src/http/modules/ngx_http_dav_module.c b/src/http/modules/ngx_http_dav_module.c
index dbb17ac30..a97c60e44 100644
--- a/src/http/modules/ngx_http_dav_module.c
+++ b/src/http/modules/ngx_http_dav_module.c
@@ -209,6 +209,11 @@ ngx_http_dav_put_handler(ngx_http_request_t *r)
ngx_ext_rename_file_t ext;
ngx_http_dav_loc_conf_t *dlcf;
+ if (r->request_body == NULL || r->request_body->temp_file == NULL) {
+ ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
ngx_http_map_uri_to_path(r, &path, &root, 0);
path.len--;
diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm
index 28de1d531..0f720d84d 100644
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -50,7 +50,7 @@ our @EXPORT = qw(
HTTP_INSUFFICIENT_STORAGE
);
-our $VERSION = '1.2.5';
+our $VERSION = '1.2.6';
require XSLoader;
XSLoader::load('nginx', $VERSION);
diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c
index 1e01c857d..e3efbba5b 100644
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -112,7 +112,7 @@ static ngx_str_t ngx_http_status_lines[] = {
#define NGX_HTTP_OFF_5XX (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)
ngx_string("500 Internal Server Error"),
- ngx_string("501 Method Not Implemented"),
+ ngx_string("501 Not Implemented"),
ngx_string("502 Bad Gateway"),
ngx_string("503 Service Temporarily Unavailable"),
ngx_string("504 Gateway Time-out"),
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index bddd7c580..3c69d052c 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -31,9 +31,9 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
{
size_t preread;
ssize_t size;
+ ngx_int_t rc;
ngx_buf_t *b;
ngx_chain_t *cl, **next;
- ngx_temp_file_t *tf;
ngx_http_request_body_t *rb;
ngx_http_core_loc_conf_t *clcf;
@@ -45,12 +45,14 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
}
if (ngx_http_test_expect(r) != NGX_OK) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
if (rb == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
r->request_body = rb;
@@ -65,31 +67,9 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
if (r->headers_in.content_length_n == 0) {
if (r->request_body_in_file_only) {
- tf = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
- if (tf == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
- }
-
- tf->file.fd = NGX_INVALID_FILE;
- tf->file.log = r->connection->log;
- tf->path = clcf->client_body_temp_path;
- tf->pool = r->pool;
- tf->warn = "a client request body is buffered to a temporary file";
- tf->log_level = r->request_body_file_log_level;
- tf->persistent = r->request_body_in_persistent_file;
- tf->clean = r->request_body_in_clean_file;
-
- if (r->request_body_file_group_access) {
- tf->access = 0660;
- }
-
- rb->temp_file = tf;
-
- if (ngx_create_temp_file(&tf->file, tf->path, tf->pool,
- tf->persistent, tf->clean, tf->access)
- != NGX_OK)
- {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ if (ngx_http_write_request_body(r, NULL) != NGX_OK) {
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
}
@@ -119,7 +99,8 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
b = ngx_calloc_buf(r->pool);
if (b == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
b->temporary = 1;
@@ -130,7 +111,8 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
rb->bufs = ngx_alloc_chain_link(r->pool);
if (rb->bufs == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
rb->bufs->buf = b;
@@ -148,7 +130,8 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
if (r->request_body_in_file_only) {
if (ngx_http_write_request_body(r, rb->bufs) != NGX_OK) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
}
@@ -175,7 +158,8 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
r->read_event_handler = ngx_http_read_client_request_body_handler;
- return ngx_http_do_read_client_request_body(r);
+ rc = ngx_http_do_read_client_request_body(r);
+ goto done;
}
next = &rb->bufs->next;
@@ -205,12 +189,14 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
rb->buf = ngx_create_temp_buf(r->pool, size);
if (rb->buf == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
cl = ngx_alloc_chain_link(r->pool);
if (cl == NULL) {
- return NGX_HTTP_INTERNAL_SERVER_ERROR;
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
}
cl->buf = rb->buf;
@@ -235,7 +221,15 @@ ngx_http_read_client_request_body(ngx_http_request_t *r,
r->read_event_handler = ngx_http_read_client_request_body_handler;
- return ngx_http_do_read_client_request_body(r);
+ rc = ngx_http_do_read_client_request_body(r);
+
+done:
+
+ if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
+ r->main->count--;
+ }
+
+ return rc;
}
@@ -419,6 +413,19 @@ ngx_http_write_request_body(ngx_http_request_t *r, ngx_chain_t *body)
}
rb->temp_file = tf;
+
+ if (body == NULL) {
+ /* empty body with r->request_body_in_file_only */
+
+ if (ngx_create_temp_file(&tf->file, tf->path, tf->pool,
+ tf->persistent, tf->clean, tf->access)
+ != NGX_OK)
+ {
+ return NGX_ERROR;
+ }
+
+ return NGX_OK;
+ }
}
n = ngx_write_chain_to_temp_file(rb->temp_file, body);
@@ -475,19 +482,21 @@ ngx_http_discard_request_body(ngx_http_request_t *r)
}
}
+ if (ngx_http_read_discarded_request_body(r) == NGX_OK) {
+ r->lingering_close = 0;
+ return NGX_OK;
+ }
+
+ /* == NGX_AGAIN */
+
r->read_event_handler = ngx_http_discarded_request_body_handler;
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}
- if (ngx_http_read_discarded_request_body(r) == NGX_OK) {
- r->lingering_close = 0;
-
- } else {
- r->count++;
- r->discard_body = 1;
- }
+ r->count++;
+ r->discard_body = 1;
return NGX_OK;
}
diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c
index 77b3dd13f..be495f909 100644
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -260,9 +260,9 @@ static char ngx_http_error_500_page[] =
static char ngx_http_error_501_page[] =
"<html>" CRLF
-"<head><title>501 Method Not Implemented</title></head>" CRLF
+"<head><title>501 Not Implemented</title></head>" CRLF
"<body bgcolor=\"white\">" CRLF
-"<center><h1>501 Method Not Implemented</h1></center>" CRLF
+"<center><h1>501 Not Implemented</h1></center>" CRLF
;
@@ -384,6 +384,7 @@ ngx_http_special_response_handler(ngx_http_request_t *r, ngx_int_t error)
case NGX_HTTPS_CERT_ERROR:
case NGX_HTTPS_NO_CERT:
case NGX_HTTP_INTERNAL_SERVER_ERROR:
+ case NGX_HTTP_NOT_IMPLEMENTED:
r->keepalive = 0;
}
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 75ef64e55..703017f54 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -1809,9 +1809,16 @@ ngx_http_upstream_test_connect(ngx_connection_t *c)
#if (NGX_HAVE_KQUEUE)
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
- if (c->write->pending_eof) {
+ if (c->write->pending_eof || c->read->pending_eof) {
+ if (c->write->pending_eof) {
+ err = c->write->kq_errno;
+
+ } else {
+ err = c->read->kq_errno;
+ }
+
c->log->action = "connecting to upstream";
- (void) ngx_connection_error(c, c->write->kq_errno,
+ (void) ngx_connection_error(c, err,
"kevent() reported that connect() failed");
return NGX_ERROR;
}
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index c4998fca5..4b78cffd8 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -430,6 +430,10 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
if (rrp->peers->single) {
peer = &rrp->peers->peer[0];
+ if (peer->down) {
+ goto failed;
+ }
+
} else {
/* there are several peers */
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index b0949c7f1..298064a81 100644
--- a/src/http/ngx_http_variables.c
+++ b/src/http/ngx_http_variables.c
@@ -79,6 +79,8 @@ static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_request_time(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_status(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
@@ -108,6 +110,8 @@ static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_msec(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
/*
* TODO:
@@ -237,6 +241,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
ngx_http_variable_request_body_file,
0, 0, 0 },
+ { ngx_string("request_time"), NULL, ngx_http_variable_request_time,
+ 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
{ ngx_string("status"), NULL,
ngx_http_variable_status, 0,
NGX_HTTP_VAR_NOCACHEABLE, 0 },
@@ -285,6 +292,9 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
{ ngx_string("pid"), NULL, ngx_http_variable_pid,
0, 0, 0 },
+ { ngx_string("msec"), NULL, ngx_http_variable_msec,
+ 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
+
#if (NGX_HAVE_TCP_INFO)
{ ngx_string("tcpinfo_rtt"), NULL, ngx_http_variable_tcpinfo,
0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
@@ -1757,7 +1767,7 @@ ngx_http_variable_request_body(ngx_http_request_t *r,
{
u_char *p;
size_t len;
- ngx_buf_t *buf, *next;
+ ngx_buf_t *buf;
ngx_chain_t *cl;
if (r->request_body == NULL
@@ -1782,8 +1792,13 @@ ngx_http_variable_request_body(ngx_http_request_t *r,
return NGX_OK;
}
- next = cl->next->buf;
- len = (buf->last - buf->pos) + (next->last - next->pos);
+ len = buf->last - buf->pos;
+ cl = cl->next;
+
+ for ( /* void */ ; cl; cl = cl->next) {
+ buf = cl->buf;
+ len += buf->last - buf->pos;
+ }
p = ngx_pnalloc(r->pool, len);
if (p == NULL) {
@@ -1791,9 +1806,12 @@ ngx_http_variable_request_body(ngx_http_request_t *r,
}
v->data = p;
+ cl = r->request_body->bufs;
- p = ngx_cpymem(p, buf->pos, buf->last - buf->pos);
- ngx_memcpy(p, next->pos, next->last - next->pos);
+ for ( /* void */ ; cl; cl = cl->next) {
+ buf = cl->buf;
+ p = ngx_cpymem(p, buf->pos, buf->last - buf->pos);
+ }
v->len = len;
v->valid = 1;
@@ -1825,6 +1843,35 @@ ngx_http_variable_request_body_file(ngx_http_request_t *r,
static ngx_int_t
+ngx_http_variable_request_time(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+ ngx_time_t *tp;
+ ngx_msec_int_t ms;
+
+ p = ngx_pnalloc(r->pool, NGX_TIME_T_LEN + 4);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ tp = ngx_timeofday();
+
+ ms = (ngx_msec_int_t)
+ ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec));
+ ms = ngx_max(ms, 0);
+
+ v->len = ngx_sprintf(p, "%T.%03M", ms / 1000, ms % 1000) - p;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = p;
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_variable_connection(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data)
{
@@ -1915,6 +1962,30 @@ ngx_http_variable_pid(ngx_http_request_t *r,
}
+static ngx_int_t
+ngx_http_variable_msec(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data)
+{
+ u_char *p;
+ ngx_time_t *tp;
+
+ p = ngx_pnalloc(r->pool, NGX_TIME_T_LEN + 4);
+ if (p == NULL) {
+ return NGX_ERROR;
+ }
+
+ tp = ngx_timeofday();
+
+ v->len = ngx_sprintf(p, "%T.%03M", tp->sec, tp->msec) - p;
+ v->valid = 1;
+ v->no_cacheable = 0;
+ v->not_found = 0;
+ v->data = p;
+
+ return NGX_OK;
+}
+
+
void *
ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map, ngx_str_t *match)
{
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index d71aec316..4fdf884fc 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -241,8 +241,12 @@ ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset,
return NGX_ERROR;
}
+ ngx_log_debug2(NGX_LOG_DEBUG_CORE, file->log, 0,
+ "writev: %d, %z", file->fd, n);
+
file->sys_offset += n;
file->offset += n;
+ offset += n;
total += n;
} while (cl);
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index 73fb44c8d..c9b0266ed 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -20,7 +20,7 @@ static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
static ngx_uint_t ngx_reap_children(ngx_cycle_t *cycle);
static void ngx_master_process_exit(ngx_cycle_t *cycle);
static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data);
-static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority);
+static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker);
static void ngx_worker_process_exit(ngx_cycle_t *cycle);
static void ngx_channel_handler(ngx_event_t *ev);
#if (NGX_THREADS)
@@ -62,7 +62,6 @@ ngx_int_t ngx_threads_n;
#endif
-uint64_t cpu_affinity;
static u_char master_process[] = "master process";
@@ -360,10 +359,8 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
for (i = 0; i < n; i++) {
- cpu_affinity = ngx_get_cpu_affinity(i);
-
- ngx_spawn_process(cycle, ngx_worker_process_cycle, NULL,
- "worker process", type);
+ ngx_spawn_process(cycle, ngx_worker_process_cycle,
+ (void *) (intptr_t) i, "worker process", type);
ch.pid = ngx_processes[ngx_process_slot].pid;
ch.slot = ngx_process_slot;
@@ -371,8 +368,6 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
ngx_pass_open_channel(cycle, &ch);
}
-
- cpu_affinity = 0;
}
@@ -726,12 +721,14 @@ ngx_master_process_exit(ngx_cycle_t *cycle)
static void
ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
+ ngx_int_t worker = (intptr_t) data;
+
ngx_uint_t i;
ngx_connection_t *c;
ngx_process = NGX_PROCESS_WORKER;
- ngx_worker_process_init(cycle, 1);
+ ngx_worker_process_init(cycle, worker);
ngx_setproctitle("worker process");
@@ -837,9 +834,10 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
static void
-ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
+ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker)
{
sigset_t set;
+ uint64_t cpu_affinity;
ngx_int_t n;
ngx_uint_t i;
struct rlimit rlmt;
@@ -853,7 +851,7 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module);
- if (priority && ccf->priority != 0) {
+ if (worker >= 0 && ccf->priority != 0) {
if (setpriority(PRIO_PROCESS, 0, ccf->priority) == -1) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
"setpriority(%d) failed", ccf->priority);
@@ -917,8 +915,12 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
}
}
- if (cpu_affinity) {
- ngx_setaffinity(cpu_affinity, cycle->log);
+ if (worker >= 0) {
+ cpu_affinity = ngx_get_cpu_affinity(worker);
+
+ if (cpu_affinity) {
+ ngx_setaffinity(cpu_affinity, cycle->log);
+ }
}
#if (NGX_HAVE_PR_SET_DUMPABLE)
@@ -1294,14 +1296,19 @@ ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data)
void *ident[4];
ngx_event_t ev;
- cycle->connection_n = 512;
-
+ /*
+ * Set correct process type since closing listening Unix domain socket
+ * in a master process also removes the Unix domain socket file.
+ */
ngx_process = NGX_PROCESS_HELPER;
- ngx_worker_process_init(cycle, 0);
-
ngx_close_listening_sockets(cycle);
+ /* Set a moderate number of connections for a helper process. */
+ cycle->connection_n = 512;
+
+ ngx_worker_process_init(cycle, -1);
+
ngx_memzero(&ev, sizeof(ngx_event_t));
ev.handler = ctx->handler;
ev.data = ident;