aboutsummaryrefslogtreecommitdiff
path: root/src/os/unix
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/unix')
-rw-r--r--src/os/unix/ngx_aio_read.c3
-rw-r--r--src/os/unix/ngx_aio_read_chain.c3
-rw-r--r--src/os/unix/ngx_aio_write.c3
-rw-r--r--src/os/unix/ngx_aio_write_chain.c4
-rw-r--r--src/os/unix/ngx_channel.c12
-rw-r--r--src/os/unix/ngx_files.c2
-rw-r--r--src/os/unix/ngx_freebsd_rfork_thread.h2
-rw-r--r--src/os/unix/ngx_gcc_atomic_amd64.h2
-rw-r--r--src/os/unix/ngx_gcc_atomic_ppc.h2
-rw-r--r--src/os/unix/ngx_gcc_atomic_sparc64.h2
-rw-r--r--src/os/unix/ngx_gcc_atomic_x86.h2
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c12
-rw-r--r--src/os/unix/ngx_posix_init.c2
-rw-r--r--src/os/unix/ngx_process_cycle.c40
-rw-r--r--src/os/unix/ngx_pthread_thread.c6
-rw-r--r--src/os/unix/ngx_readv_chain.c2
-rw-r--r--src/os/unix/ngx_solaris_sendfilev_chain.c2
-rw-r--r--src/os/unix/ngx_sunpro_atomic_sparc64.h2
-rw-r--r--src/os/unix/ngx_sunpro_sparc64.il2
19 files changed, 63 insertions, 42 deletions
diff --git a/src/os/unix/ngx_aio_read.c b/src/os/unix/ngx_aio_read.c
index 2a66eb83c..206f0efb2 100644
--- a/src/os/unix/ngx_aio_read.c
+++ b/src/os/unix/ngx_aio_read.c
@@ -22,7 +22,8 @@
* timeout, aio_cancel(), aio_error()
*/
-ssize_t ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size)
+ssize_t
+ngx_aio_read(ngx_connection_t *c, u_char *buf, size_t size)
{
int n;
ngx_event_t *rev;
diff --git a/src/os/unix/ngx_aio_read_chain.c b/src/os/unix/ngx_aio_read_chain.c
index c6f9aea84..da85ed9ea 100644
--- a/src/os/unix/ngx_aio_read_chain.c
+++ b/src/os/unix/ngx_aio_read_chain.c
@@ -10,7 +10,8 @@
#include <ngx_aio.h>
-ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
+ssize_t
+ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
{
int n;
u_char *buf, *prev;
diff --git a/src/os/unix/ngx_aio_write.c b/src/os/unix/ngx_aio_write.c
index 1d8c1aacd..57e751d10 100644
--- a/src/os/unix/ngx_aio_write.c
+++ b/src/os/unix/ngx_aio_write.c
@@ -22,7 +22,8 @@
* timeout, aio_cancel(), aio_error()
*/
-ssize_t ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size)
+ssize_t
+ngx_aio_write(ngx_connection_t *c, u_char *buf, size_t size)
{
int n;
ngx_event_t *wev;
diff --git a/src/os/unix/ngx_aio_write_chain.c b/src/os/unix/ngx_aio_write_chain.c
index b90f8bba1..e3d663158 100644
--- a/src/os/unix/ngx_aio_write_chain.c
+++ b/src/os/unix/ngx_aio_write_chain.c
@@ -10,8 +10,8 @@
#include <ngx_aio.h>
-ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
- off_t limit)
+ngx_chain_t *
+ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
{
u_char *buf, *prev;
off_t send, sent;
diff --git a/src/os/unix/ngx_channel.c b/src/os/unix/ngx_channel.c
index c7f12937f..62ea7cc30 100644
--- a/src/os/unix/ngx_channel.c
+++ b/src/os/unix/ngx_channel.c
@@ -11,7 +11,7 @@
ngx_int_t
ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size,
- ngx_log_t *log)
+ ngx_log_t *log)
{
ssize_t n;
ngx_err_t err;
@@ -34,7 +34,7 @@ ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size,
msg.msg_controllen = sizeof(cmsg);
cmsg.cm.cmsg_len = sizeof(cmsg);
- cmsg.cm.cmsg_level = SOL_SOCKET;
+ cmsg.cm.cmsg_level = SOL_SOCKET;
cmsg.cm.cmsg_type = SCM_RIGHTS;
*(int *) CMSG_DATA(&cmsg.cm) = ch->fd;
}
@@ -80,7 +80,7 @@ ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size,
ngx_int_t
ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, ngx_log_t *log)
-{
+{
ssize_t n;
ngx_err_t err;
struct iovec iov[1];
@@ -165,7 +165,7 @@ ngx_read_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, ngx_log_t *log)
if (ch->command == NGX_CMD_OPEN_CHANNEL) {
if (msg.msg_accrightslen != sizeof(int)) {
- ngx_log_error(NGX_LOG_ALERT, log, 0,
+ ngx_log_error(NGX_LOG_ALERT, log, 0,
"recvmsg() returned no ancillary data");
return NGX_ERROR;
}
@@ -219,8 +219,8 @@ ngx_add_channel_event(ngx_cycle_t *cycle, ngx_fd_t fd, ngx_int_t event,
ngx_free_connection(c);
return NGX_ERROR;
}
-
- } else {
+
+ } else {
if (ngx_add_event(ev, event, 0) == NGX_ERROR) {
ngx_free_connection(c);
return NGX_ERROR;
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index 67cad1a69..b5a807bb6 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -148,7 +148,7 @@ ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl, off_t offset,
vec.elts = iovs;
vec.size = sizeof(struct iovec);
- vec.nalloc = NGX_IOVS;
+ vec.nalloc = NGX_IOVS;
vec.pool = pool;
do {
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.h b/src/os/unix/ngx_freebsd_rfork_thread.h
index 20957a5ff..6b5c8a9c3 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.h
+++ b/src/os/unix/ngx_freebsd_rfork_thread.h
@@ -100,7 +100,7 @@ ngx_err_t ngx_thread_set_tls(ngx_tls_key_t key, void *value);
static void *
ngx_thread_get_tls(ngx_tls_key_t key)
-{
+{
if (key >= NGX_THREAD_KEYS_MAX) {
return NULL;
}
diff --git a/src/os/unix/ngx_gcc_atomic_amd64.h b/src/os/unix/ngx_gcc_atomic_amd64.h
index 374e3b8ff..2183e738e 100644
--- a/src/os/unix/ngx_gcc_atomic_amd64.h
+++ b/src/os/unix/ngx_gcc_atomic_amd64.h
@@ -32,7 +32,7 @@
static ngx_inline ngx_atomic_uint_t
ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
ngx_atomic_uint_t set)
-{
+{
ngx_atomic_uint_t res;
__asm__ volatile (
diff --git a/src/os/unix/ngx_gcc_atomic_ppc.h b/src/os/unix/ngx_gcc_atomic_ppc.h
index 58b24c31a..a6bbb39d1 100644
--- a/src/os/unix/ngx_gcc_atomic_ppc.h
+++ b/src/os/unix/ngx_gcc_atomic_ppc.h
@@ -10,7 +10,7 @@
* this branch is unlikely to be taken.
* The "1b" means the nearest backward label "1" and the "1f" means
* the nearest forward label "1".
- *
+ *
* The "b" means that the base registers can be used only, i.e.
* any register except r0. The r0 register always has a zero value and
* could not be used in "addi r0, r0, 1".
diff --git a/src/os/unix/ngx_gcc_atomic_sparc64.h b/src/os/unix/ngx_gcc_atomic_sparc64.h
index 8314318e7..fc6bacee2 100644
--- a/src/os/unix/ngx_gcc_atomic_sparc64.h
+++ b/src/os/unix/ngx_gcc_atomic_sparc64.h
@@ -40,7 +40,7 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
: "+r" (set) : "r" (lock), "r" (old) : "memory");
return (set == old);
-}
+}
static ngx_inline ngx_atomic_int_t
diff --git a/src/os/unix/ngx_gcc_atomic_x86.h b/src/os/unix/ngx_gcc_atomic_x86.h
index 3053e72ff..b458032b5 100644
--- a/src/os/unix/ngx_gcc_atomic_x86.h
+++ b/src/os/unix/ngx_gcc_atomic_x86.h
@@ -22,7 +22,7 @@
* eax = [m];
* }
*
- *
+ *
* The "q" is any of the %eax, %ebx, %ecx, or %edx registers.
* The "=a" and "a" are the %eax register. Although we can return result
* in any register, we use %eax because it is used in cmpxchgl anyway.
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index 9ddac673a..115b9911b 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -158,7 +158,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
* and without the TCP_CORK
*/
- if (err != NGX_EINTR) {
+ if (err != NGX_EINTR) {
wev->error = 1;
ngx_connection_error(c, err,
"setsockopt(TCP_NODELAY) failed");
@@ -183,7 +183,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
* we continue a processing without the TCP_CORK
*/
- if (err != NGX_EINTR) {
+ if (err != NGX_EINTR) {
wev->error = 1;
ngx_connection_error(c, err,
ngx_tcp_nopush_n " failed");
@@ -192,7 +192,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
} else {
c->tcp_nopush = NGX_TCP_NOPUSH_SET;
-
+
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0,
"tcp_nopush");
}
@@ -281,7 +281,7 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
} else {
wev->error = 1;
ngx_connection_error(c, err, "writev() failed");
- return NGX_CHAIN_ERROR;
+ return NGX_CHAIN_ERROR;
}
}
@@ -334,10 +334,10 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
}
if (eintr) {
- continue;
+ continue;
}
- if (!complete) {
+ if (!complete) {
wev->ready = 0;
return cl;
}
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 4a2b581be..4968de5b9 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -49,7 +49,7 @@ ngx_os_init(ngx_log_t *log)
"getrlimit(RLIMIT_NOFILE) failed)");
return NGX_ERROR;
}
-
+
ngx_max_sockets = (ngx_int_t) rlmt.rlim_cur;
#if (NGX_HAVE_INHERITED_NONBLOCK)
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index ddc10c8a5..7adcc6ef7 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -58,7 +58,8 @@ ngx_int_t ngx_threads_n;
#endif
-u_char master_process[] = "master process";
+u_long cpu_affinity;
+static u_char master_process[] = "master process";
void
@@ -312,14 +313,17 @@ ngx_single_process_cycle(ngx_cycle_t *cycle)
static void
ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
{
- ngx_int_t i;
+ ngx_int_t i, s;
ngx_channel_t ch;
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes");
ch.command = NGX_CMD_OPEN_CHANNEL;
- while (n--) {
+ 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);
@@ -327,11 +331,11 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
ch.slot = ngx_process_slot;
ch.fd = ngx_processes[ngx_process_slot].channel[0];
- for (i = 0; i < ngx_last_process; i++) {
+ for (s = 0; s < ngx_last_process; s++) {
- if (i == ngx_process_slot
- || ngx_processes[i].pid == -1
- || ngx_processes[i].channel[0] == -1)
+ if (s == ngx_process_slot
+ || ngx_processes[s].pid == -1
+ || ngx_processes[s].channel[0] == -1)
{
continue;
}
@@ -339,12 +343,12 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
ngx_log_debug6(NGX_LOG_DEBUG_CORE, cycle->log, 0,
"pass channel s:%d pid:%P fd:%d to s:%i pid:%P fd:%d",
ch.slot, ch.pid, ch.fd,
- i, ngx_processes[i].pid,
- ngx_processes[i].channel[0]);
+ s, ngx_processes[s].pid,
+ ngx_processes[s].channel[0]);
/* TODO: NGX_AGAIN */
- ngx_write_channel(ngx_processes[i].channel[0],
+ ngx_write_channel(ngx_processes[s].channel[0],
&ch, sizeof(ngx_channel_t), cycle->log);
}
}
@@ -817,6 +821,20 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
}
}
+#if (NGX_HAVE_SCHED_SETAFFINITY)
+
+ if (cpu_affinity) {
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
+ "sched_setaffinity(0x%08Xl)", cpu_affinity);
+
+ if (sched_setaffinity(0, 32, (cpu_set_t *) &cpu_affinity) == -1) {
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
+ "sched_setaffinity(0x%08Xl) failed", cpu_affinity);
+ }
+ }
+
+#endif
+
#if (NGX_HAVE_PR_SET_DUMPABLE)
/* allow coredump after setuid() in Linux 2.4.x */
@@ -849,7 +867,7 @@ ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
/*
* disable deleting previous events for the listening sockets because
* in the worker processes there are no events at all at this point
- */
+ */
ls = cycle->listening.elts;
for (i = 0; i < cycle->listening.nelts; i++) {
ls[i].previous = NULL;
diff --git a/src/os/unix/ngx_pthread_thread.c b/src/os/unix/ngx_pthread_thread.c
index c91e65d58..676c76098 100644
--- a/src/os/unix/ngx_pthread_thread.c
+++ b/src/os/unix/ngx_pthread_thread.c
@@ -45,7 +45,7 @@ ngx_create_thread(ngx_tid_t *tid, ngx_thread_value_t (*func)(void *arg),
ngx_int_t
ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
-{
+{
int err;
max_threads = n;
@@ -82,7 +82,7 @@ ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
if (m == NULL) {
return NULL;
}
-
+
m->log = log;
err = pthread_mutex_init(&m->mutex, NULL);
@@ -202,7 +202,7 @@ ngx_cond_init(ngx_log_t *log)
if (cv == NULL) {
return NULL;
}
-
+
cv->log = log;
err = pthread_cond_init(&cv->cond, NULL);
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index 08b5cc033..9de4cd5ec 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -24,7 +24,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
ngx_event_t *rev;
struct iovec *iov, iovs[NGX_IOVS];
- rev = c->read;
+ rev = c->read;
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c
index 4345385e3..5347cd9d2 100644
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -190,7 +190,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
for (cl = in; cl; cl = cl->next) {
if (ngx_buf_special(cl->buf)) {
- continue;
+ continue;
}
if (sent == 0) {
diff --git a/src/os/unix/ngx_sunpro_atomic_sparc64.h b/src/os/unix/ngx_sunpro_atomic_sparc64.h
index 6b4ce84b9..691e94ee5 100644
--- a/src/os/unix/ngx_sunpro_atomic_sparc64.h
+++ b/src/os/unix/ngx_sunpro_atomic_sparc64.h
@@ -27,7 +27,7 @@ ngx_atomic_cmp_set(ngx_atomic_t *lock, ngx_atomic_uint_t old,
NGX_CASA(set, old, lock);
return (set == old);
-}
+}
static ngx_inline ngx_atomic_int_t
diff --git a/src/os/unix/ngx_sunpro_sparc64.il b/src/os/unix/ngx_sunpro_sparc64.il
index d2708ed9d..2dd83204a 100644
--- a/src/os/unix/ngx_sunpro_sparc64.il
+++ b/src/os/unix/ngx_sunpro_sparc64.il
@@ -5,7 +5,7 @@
/ "casa [%o2] 0x80, %o1, %o0" and
/ "casxa [%o2] 0x80, %o1, %o0" do the following:
-/
+/
/ if ([%o2] == %o1) {
/ swap(%o0, [%o2]);
/ } else {