aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
Diffstat (limited to 'src/os')
-rw-r--r--src/os/unix/ngx_aio_read_chain.c1
-rw-r--r--src/os/unix/ngx_aio_write_chain.c1
-rw-r--r--src/os/unix/ngx_alloc.c18
-rw-r--r--src/os/unix/ngx_errno.c3
-rw-r--r--src/os/unix/ngx_errno.h6
-rw-r--r--src/os/unix/ngx_files.c4
-rw-r--r--src/os/unix/ngx_freebsd_init.c19
-rw-r--r--src/os/unix/ngx_freebsd_rfork_thread.c19
-rw-r--r--src/os/unix/ngx_freebsd_rfork_thread.h2
-rw-r--r--src/os/unix/ngx_freebsd_sendfile_chain.c18
-rw-r--r--src/os/unix/ngx_linux_sendfile_chain.c3
-rw-r--r--src/os/unix/ngx_posix_init.c2
-rw-r--r--src/os/unix/ngx_process.c1
-rw-r--r--src/os/unix/ngx_process_cycle.c66
-rw-r--r--src/os/unix/ngx_pthread_thread.c6
-rw-r--r--src/os/unix/ngx_readv_chain.c49
-rw-r--r--src/os/unix/ngx_setproctitle.c3
-rw-r--r--src/os/unix/ngx_socket.c28
-rw-r--r--src/os/unix/ngx_solaris_sendfilev_chain.c8
-rw-r--r--src/os/unix/ngx_writev_chain.c6
-rw-r--r--src/os/win32/ngx_alloc.c3
-rw-r--r--src/os/win32/ngx_files.c17
-rw-r--r--src/os/win32/ngx_files.h7
-rw-r--r--src/os/win32/ngx_process_cycle.c2
-rw-r--r--src/os/win32/ngx_socket.c13
-rw-r--r--src/os/win32/ngx_socket.h5
-rw-r--r--src/os/win32/ngx_thread.c16
-rw-r--r--src/os/win32/ngx_thread.h11
-rw-r--r--src/os/win32/ngx_win32_config.h24
-rw-r--r--src/os/win32/ngx_wsarecv_chain.c27
-rw-r--r--src/os/win32/ngx_wsasend_chain.c18
31 files changed, 266 insertions, 140 deletions
diff --git a/src/os/unix/ngx_aio_read_chain.c b/src/os/unix/ngx_aio_read_chain.c
index 31793d5a4..c6f9aea84 100644
--- a/src/os/unix/ngx_aio_read_chain.c
+++ b/src/os/unix/ngx_aio_read_chain.c
@@ -16,7 +16,6 @@ ssize_t ngx_aio_read_chain(ngx_connection_t *c, ngx_chain_t *cl)
u_char *buf, *prev;
size_t size;
ssize_t total;
- ngx_err_t err;
if (c->read->pending_eof) {
c->read->ready = 0;
diff --git a/src/os/unix/ngx_aio_write_chain.c b/src/os/unix/ngx_aio_write_chain.c
index 88b2474c9..b90f8bba1 100644
--- a/src/os/unix/ngx_aio_write_chain.c
+++ b/src/os/unix/ngx_aio_write_chain.c
@@ -17,7 +17,6 @@ ngx_chain_t *ngx_aio_write_chain(ngx_connection_t *c, ngx_chain_t *in,
off_t send, sent;
size_t len;
ssize_t n, size;
- ngx_err_t err;
ngx_chain_t *cl;
/* the maximum limit size is the maximum size_t value - the page size */
diff --git a/src/os/unix/ngx_alloc.c b/src/os/unix/ngx_alloc.c
index 258a10fa9..72cf4e42e 100644
--- a/src/os/unix/ngx_alloc.c
+++ b/src/os/unix/ngx_alloc.c
@@ -11,11 +11,13 @@
int ngx_pagesize;
-void *ngx_alloc(size_t size, ngx_log_t *log)
+void *
+ngx_alloc(size_t size, ngx_log_t *log)
{
void *p;
- if (!(p = malloc(size))) {
+ p = malloc(size);
+ if (p == NULL) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"malloc() %uz bytes failed", size);
}
@@ -26,7 +28,8 @@ void *ngx_alloc(size_t size, ngx_log_t *log)
}
-void *ngx_calloc(size_t size, ngx_log_t *log)
+void *
+ngx_calloc(size_t size, ngx_log_t *log)
{
void *p;
@@ -42,7 +45,8 @@ void *ngx_calloc(size_t size, ngx_log_t *log)
#if (NGX_HAVE_POSIX_MEMALIGN)
-void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
+void *
+ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
{
void *p;
@@ -60,11 +64,13 @@ void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
#elif (NGX_HAVE_MEMALIGN)
-void *ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
+void *
+ngx_memalign(size_t alignment, size_t size, ngx_log_t *log)
{
void *p;
- if (!(p = memalign(alignment, size))) {
+ p = memalign(alignment, size);
+ if (p == NULL) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"memalign() %uz bytes aligned to %uz failed",
size, alignment);
diff --git a/src/os/unix/ngx_errno.c b/src/os/unix/ngx_errno.c
index 607b361d9..a3addf00c 100644
--- a/src/os/unix/ngx_errno.c
+++ b/src/os/unix/ngx_errno.c
@@ -34,8 +34,7 @@ u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
u_char *ngx_strerror_r(int err, u_char *errstr, size_t size)
{
- char *str;
- size_t len;
+ char *str;
if (size == 0) {
return 0;
diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h
index c1c5801d3..51d608bf4 100644
--- a/src/os/unix/ngx_errno.h
+++ b/src/os/unix/ngx_errno.h
@@ -25,7 +25,7 @@ typedef int ngx_err_t;
#define NGX_ENOTDIR ENOTDIR
#define NGX_EINVAL EINVAL
#define NGX_EPIPE EPIPE
-#define NGX_EAGAIN EWOULDBLOCK
+#define NGX_EAGAIN EAGAIN
#define NGX_EINPROGRESS EINPROGRESS
#define NGX_EADDRINUSE EADDRINUSE
#define NGX_ECONNABORTED ECONNABORTED
@@ -52,10 +52,10 @@ u_char *ngx_strerror_r(int err, u_char *errstr, size_t size);
#else
-/* Solaris has threads-safe strerror() */
+/* Solaris has thread-safe strerror() */
#define ngx_strerror_r(err, errstr, size) \
- ngx_cpystrn(errstr, (u_char *) strerror(err), size)
+ ngx_cpystrn(errstr, (u_char *) strerror(err), size)
#endif
diff --git a/src/os/unix/ngx_files.c b/src/os/unix/ngx_files.c
index e67b2cac7..f8f98c7fe 100644
--- a/src/os/unix/ngx_files.c
+++ b/src/os/unix/ngx_files.c
@@ -131,7 +131,6 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
u_char *prev;
size_t size;
ssize_t n;
- ngx_err_t err;
ngx_array_t vec;
struct iovec *iov, iovs[NGX_IOVS];
@@ -162,7 +161,8 @@ ssize_t ngx_write_chain_to_file(ngx_file_t *file, ngx_chain_t *cl,
iov->iov_len += cl->buf->last - cl->buf->pos;
} else {
- if (!(iov = ngx_array_push(&vec))) {
+ iov = ngx_array_push(&vec);
+ if (iov == NULL) {
return NGX_ERROR;
}
diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c
index 044d9d5c9..7defb4676 100644
--- a/src/os/unix/ngx_freebsd_init.c
+++ b/src/os/unix/ngx_freebsd_init.c
@@ -14,6 +14,7 @@ char ngx_freebsd_kern_osrelease[128];
int ngx_freebsd_kern_osreldate;
int ngx_freebsd_hw_ncpu;
int ngx_freebsd_net_inet_tcp_sendspace;
+int ngx_freebsd_kern_ipc_somaxconn;
/* FreeBSD 4.9 */
int ngx_freebsd_machdep_hlt_logical_cpus;
@@ -61,6 +62,10 @@ sysctl_t sysctls[] = {
&ngx_freebsd_net_inet_tcp_sendspace,
sizeof(int), 0 },
+ { "kern.ipc.somaxconn",
+ &ngx_freebsd_kern_ipc_somaxconn,
+ sizeof(int), 0 },
+
{ "kern.ipc.zero_copy.send",
&ngx_freebsd_kern_ipc_zero_copy_send,
sizeof(int), 0 },
@@ -85,7 +90,7 @@ void ngx_debug_init()
ngx_int_t ngx_os_init(ngx_log_t *log)
{
- int version;
+ int version, somaxconn;
size_t size;
ngx_err_t err;
ngx_uint_t i;
@@ -203,6 +208,18 @@ ngx_int_t ngx_os_init(ngx_log_t *log)
ngx_ncpu = ngx_freebsd_hw_ncpu;
}
+ if (version < 600008) {
+ somaxconn = 32767;
+ } else {
+ somaxconn = 65535;
+ }
+
+ if (ngx_freebsd_kern_ipc_somaxconn > somaxconn) {
+ ngx_log_error(NGX_LOG_ALERT, log, 0,
+ "sysctl kern.ipc.somaxconn must be no more than %d",
+ somaxconn);
+ return NGX_ERROR;
+ }
ngx_tcp_nodelay_and_tcp_nopush = 1;
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.c b/src/os/unix/ngx_freebsd_rfork_thread.c
index 5dfd46807..b7e803b3c 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.c
+++ b/src/os/unix/ngx_freebsd_rfork_thread.c
@@ -227,13 +227,15 @@ ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
/* create the thread errno' array */
- if (!(errnos = ngx_calloc(n * sizeof(int), cycle->log))) {
+ errnos = ngx_calloc(n * sizeof(int), cycle->log);
+ if (errnos == NULL) {
return NGX_ERROR;
}
/* create the thread tids array */
- if (!(tids = ngx_calloc((n + 1) * sizeof(ngx_tid_t), cycle->log))) {
+ tids = ngx_calloc((n + 1) * sizeof(ngx_tid_t), cycle->log);
+ if (tids == NULL) {
return NGX_ERROR;
}
@@ -264,8 +266,7 @@ ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
ngx_tid_t ngx_thread_self()
{
- int tid;
- ngx_tid_t pid;
+ ngx_int_t tid;
tid = ngx_gettid();
@@ -305,7 +306,8 @@ ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
ngx_mutex_t *m;
union semun op;
- if (!(m = ngx_alloc(sizeof(ngx_mutex_t), log))) {
+ m = ngx_alloc(sizeof(ngx_mutex_t), log);
+ if (m == NULL) {
return NULL;
}
@@ -353,7 +355,7 @@ void ngx_mutex_destroy(ngx_mutex_t *m)
ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try)
{
- uint32_t lock, new, old;
+ uint32_t lock, old;
ngx_uint_t tries;
struct sembuf op;
@@ -483,7 +485,7 @@ ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try)
ngx_int_t ngx_mutex_unlock(ngx_mutex_t *m)
{
- uint32_t lock, new, old;
+ uint32_t lock, old;
struct sembuf op;
if (!ngx_threaded) {
@@ -576,7 +578,8 @@ ngx_cond_t *ngx_cond_init(ngx_log_t *log)
{
ngx_cond_t *cv;
- if (!(cv = ngx_alloc(sizeof(ngx_cond_t), log))) {
+ cv = ngx_alloc(sizeof(ngx_cond_t), log);
+ if (cv == NULL) {
return NULL;
}
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.h b/src/os/unix/ngx_freebsd_rfork_thread.h
index 2af0adb80..215d2dc86 100644
--- a/src/os/unix/ngx_freebsd_rfork_thread.h
+++ b/src/os/unix/ngx_freebsd_rfork_thread.h
@@ -56,7 +56,7 @@ extern char *ngx_freebsd_kern_usrstack;
extern size_t ngx_thread_stack_size;
-static inline int ngx_gettid()
+static ngx_inline ngx_int_t ngx_gettid()
{
char *sp;
diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c
index 50cad3090..a29aaf3c9 100644
--- a/src/os/unix/ngx_freebsd_sendfile_chain.c
+++ b/src/os/unix/ngx_freebsd_sendfile_chain.c
@@ -21,19 +21,19 @@
* to postpone the sending - it not only sends a header and the first part of
* the file in one packet, but also sends the file pages in the full packets.
*
- * But until FreeBSD 4.5 the turning TCP_NOPUSH off does not flush a pending
- * data that less than MSS so that data may be sent with 5 second delay.
- * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5 although it can be used
+ * But until FreeBSD 4.5 turning TCP_NOPUSH off does not flush a pending
+ * data that less than MSS, so that data may be sent with 5 second delay.
+ * So we do not use TCP_NOPUSH on FreeBSD prior to 4.5, although it can be used
* for non-keepalive HTTP connections.
*/
#define NGX_HEADERS 8
-#define NGX_TRAILERS 4
+#define NGX_TRAILERS 8
-ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
- off_t limit)
+ngx_chain_t *
+ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
{
int rc;
u_char *prev;
@@ -123,7 +123,8 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
iov->iov_len += (size_t) size;
} else {
- if (!(iov = ngx_array_push(&header))) {
+ iov = ngx_array_push(&header);
+ if (iov == NULL) {
return NGX_CHAIN_ERROR;
}
@@ -197,7 +198,8 @@ ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
iov->iov_len += (size_t) size;
} else {
- if (!(iov = ngx_array_push(&trailer))) {
+ iov = ngx_array_push(&trailer);
+ if (iov == NULL) {
return NGX_CHAIN_ERROR;
}
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c
index ac8c303eb..9ddac673a 100644
--- a/src/os/unix/ngx_linux_sendfile_chain.c
+++ b/src/os/unix/ngx_linux_sendfile_chain.c
@@ -121,7 +121,8 @@ ngx_chain_t *ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
iov->iov_len += (size_t) size;
} else {
- if (!(iov = ngx_array_push(&header))) {
+ iov = ngx_array_push(&header);
+ if (iov == NULL) {
return NGX_CHAIN_ERROR;
}
diff --git a/src/os/unix/ngx_posix_init.c b/src/os/unix/ngx_posix_init.c
index 4fb512665..d48343b30 100644
--- a/src/os/unix/ngx_posix_init.c
+++ b/src/os/unix/ngx_posix_init.c
@@ -182,7 +182,7 @@ void ngx_signal_handler(int signo)
case ngx_signal_value(NGX_NOACCEPT_SIGNAL):
ngx_noaccept = 1;
- action = ", stop the accepting connections";
+ action = ", stop accepting connections";
break;
case ngx_signal_value(NGX_RECONFIGURE_SIGNAL):
diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c
index 0825c5f3a..0562a4644 100644
--- a/src/os/unix/ngx_process.c
+++ b/src/os/unix/ngx_process.c
@@ -214,7 +214,6 @@ void ngx_process_get_status()
ngx_err_t err;
ngx_int_t i;
ngx_uint_t one;
- struct timeval tv;
one = 0;
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c
index a48880914..9c5a7ee15 100644
--- a/src/os/unix/ngx_process_cycle.c
+++ b/src/os/unix/ngx_process_cycle.c
@@ -11,7 +11,7 @@
static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
- ngx_int_t type);
+ ngx_int_t type);
static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type);
static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo);
static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle);
@@ -23,7 +23,9 @@ static void ngx_channel_handler(ngx_event_t *ev);
static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle);
static void *ngx_worker_thread_cycle(void *data);
#endif
+#if 0
static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data);
+#endif
ngx_uint_t ngx_process;
@@ -59,7 +61,8 @@ ngx_int_t ngx_threads_n;
u_char master_process[] = "master process";
-void ngx_master_process_cycle(ngx_cycle_t *cycle)
+void
+ngx_master_process_cycle(ngx_cycle_t *cycle)
{
char *title;
u_char *p;
@@ -254,7 +257,8 @@ void ngx_master_process_cycle(ngx_cycle_t *cycle)
}
-void ngx_single_process_cycle(ngx_cycle_t *cycle)
+void
+ngx_single_process_cycle(ngx_cycle_t *cycle)
{
ngx_uint_t i;
@@ -300,8 +304,8 @@ void 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)
+static void
+ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type)
{
ngx_int_t i;
ngx_channel_t ch;
@@ -359,12 +363,12 @@ static void ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n,
}
-static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
+static void
+ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
{
- ngx_int_t i;
- ngx_channel_t ch;
-
- return;
+#if 0
+ ngx_int_t i;
+ ngx_channel_t ch;
ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start garbage collector");
@@ -397,16 +401,17 @@ static void ngx_start_garbage_collector(ngx_cycle_t *cycle, ngx_int_t type)
ngx_write_channel(ngx_processes[i].channel[0],
&ch, sizeof(ngx_channel_t), cycle->log);
}
+#endif
}
-static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
+static void
+ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
{
ngx_int_t i;
ngx_err_t err;
ngx_channel_t ch;
-
switch (signo) {
case ngx_signal_value(NGX_SHUTDOWN_SIGNAL):
@@ -492,7 +497,8 @@ static void ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo)
}
-static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle)
+static ngx_uint_t
+ngx_reap_childs(ngx_cycle_t *cycle)
{
ngx_int_t i, n;
ngx_uint_t live;
@@ -619,7 +625,8 @@ static ngx_uint_t ngx_reap_childs(ngx_cycle_t *cycle)
}
-static void ngx_master_exit(ngx_cycle_t *cycle)
+static void
+ngx_master_exit(ngx_cycle_t *cycle)
{
ngx_delete_pidfile(cycle);
@@ -631,11 +638,14 @@ static void ngx_master_exit(ngx_cycle_t *cycle)
}
-static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
+static void
+ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
{
+#if (NGX_THREADS)
ngx_int_t n;
ngx_err_t err;
ngx_core_conf_t *ccf;
+#endif
ngx_worker_process_init(cycle, 1);
@@ -668,7 +678,9 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
for (n = 0; n < ngx_threads_n; n++) {
- if (!(ngx_threads[n].cv = ngx_cond_init(cycle->log))) {
+ ngx_threads[n].cv = ngx_cond_init(cycle->log);
+
+ if (ngx_threads[n].cv == NULL) {
/* fatal */
exit(2);
}
@@ -748,7 +760,8 @@ 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_uint_t priority)
{
sigset_t set;
ngx_int_t n;
@@ -873,7 +886,8 @@ static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_uint_t priority)
}
-static void ngx_channel_handler(ngx_event_t *ev)
+static void
+ngx_channel_handler(ngx_event_t *ev)
{
ngx_int_t n;
ngx_channel_t ch;
@@ -952,7 +966,8 @@ static void ngx_channel_handler(ngx_event_t *ev)
#if (NGX_THREADS)
-static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle)
+static void
+ngx_wakeup_worker_threads(ngx_cycle_t *cycle)
{
ngx_int_t i;
ngx_uint_t live;
@@ -994,7 +1009,8 @@ static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle)
}
-static void *ngx_worker_thread_cycle(void *data)
+static void *
+ngx_worker_thread_cycle(void *data)
{
ngx_thread_t *thr = data;
@@ -1022,7 +1038,8 @@ static void *ngx_worker_thread_cycle(void *data)
ngx_setthrtitle("worker thread");
- if (!(tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log))) {
+ tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log);
+ if (tls == NULL) {
return (void *) 1;
}
@@ -1077,7 +1094,10 @@ static void *ngx_worker_thread_cycle(void *data)
#endif
-static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
+#if 0
+
+static void
+ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
{
ngx_uint_t i;
ngx_gc_t ctx;
@@ -1123,3 +1143,5 @@ static void ngx_garbage_collector_cycle(ngx_cycle_t *cycle, void *data)
ngx_process_events(cycle);
}
}
+
+#endif
diff --git a/src/os/unix/ngx_pthread_thread.c b/src/os/unix/ngx_pthread_thread.c
index 4903d5e50..0b55c7192 100644
--- a/src/os/unix/ngx_pthread_thread.c
+++ b/src/os/unix/ngx_pthread_thread.c
@@ -75,7 +75,8 @@ ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
int err;
ngx_mutex_t *m;
- if (!(m = ngx_alloc(sizeof(ngx_mutex_t), log))) {
+ m = ngx_alloc(sizeof(ngx_mutex_t), log);
+ if (m == NULL) {
return NULL;
}
@@ -189,7 +190,8 @@ ngx_cond_t *ngx_cond_init(ngx_log_t *log)
int err;
ngx_cond_t *cv;
- if (!(cv = ngx_alloc(sizeof(ngx_cond_t), log))) {
+ cv = ngx_alloc(sizeof(ngx_cond_t), log);
+ if (cv == NULL) {
return NULL;
}
diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c
index 7c57b7abe..47d8f3b7c 100644
--- a/src/os/unix/ngx_readv_chain.c
+++ b/src/os/unix/ngx_readv_chain.c
@@ -9,16 +9,20 @@
#include <ngx_event.h>
+#define NGX_IOVS 16
+
+
#if (NGX_HAVE_KQUEUE)
-ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+ssize_t
+ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
{
u_char *prev;
ssize_t n, size;
ngx_err_t err;
- ngx_array_t io;
+ ngx_array_t vec;
ngx_event_t *rev;
- struct iovec *iov;
+ struct iovec *iov, iovs[NGX_IOVS];
rev = c->read;
@@ -53,7 +57,11 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
iov = NULL;
size = 0;
- ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
+ vec.elts = iovs;
+ vec.nelts = 0;
+ vec.size = sizeof(struct iovec);
+ vec.nalloc = NGX_IOVS;
+ vec.pool = c->pool;
/* coalesce the neighbouring bufs */
@@ -62,7 +70,11 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
iov->iov_len += chain->buf->end - chain->buf->last;
} else {
- ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+ iov = ngx_array_push(&vec);
+ if (iov == NULL) {
+ return NGX_ERROR;
+ }
+
iov->iov_base = (void *) chain->buf->last;
iov->iov_len = chain->buf->end - chain->buf->last;
}
@@ -73,12 +85,12 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "readv: %d, last:%d", io.nelts, iov->iov_len);
+ "readv: %d, last:%d", vec.nelts, iov->iov_len);
rev = c->read;
do {
- n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
+ n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
if (n >= 0) {
if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
@@ -138,20 +150,25 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
#else /* ! NGX_HAVE_KQUEUE */
-ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+ssize_t
+ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
{
u_char *prev;
ssize_t n, size;
ngx_err_t err;
- ngx_array_t io;
+ ngx_array_t vec;
ngx_event_t *rev;
- struct iovec *iov;
+ struct iovec *iov, iovs[NGX_IOVS];
prev = NULL;
iov = NULL;
size = 0;
- ngx_init_array(io, c->pool, 10, sizeof(struct iovec), NGX_ERROR);
+ vec.elts = iovs;
+ vec.nelts = 0;
+ vec.size = sizeof(struct iovec);
+ vec.nalloc = NGX_IOVS;
+ vec.pool = c->pool;
/* coalesce the neighbouring bufs */
@@ -160,7 +177,11 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
iov->iov_len += chain->buf->end - chain->buf->last;
} else {
- ngx_test_null(iov, ngx_push_array(&io), NGX_ERROR);
+ iov = ngx_array_push(&vec);
+ if (iov == NULL) {
+ return NGX_ERROR;
+ }
+
iov->iov_base = chain->buf->last;
iov->iov_len = chain->buf->end - chain->buf->last;
}
@@ -171,12 +192,12 @@ ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "readv: %d:%d", io.nelts, iov->iov_len);
+ "readv: %d:%d", vec.nelts, iov->iov_len);
rev = c->read;
do {
- n = readv(c->fd, (struct iovec *) io.elts, io.nelts);
+ n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
if (n == 0) {
rev->ready = 0;
diff --git a/src/os/unix/ngx_setproctitle.c b/src/os/unix/ngx_setproctitle.c
index 6c95cdf4e..25bbc9b1e 100644
--- a/src/os/unix/ngx_setproctitle.c
+++ b/src/os/unix/ngx_setproctitle.c
@@ -43,7 +43,8 @@ ngx_init_setproctitle(ngx_log_t *log)
size += ngx_strlen(environ[i]) + 1;
}
- if (!(p = ngx_alloc(size, log))) {
+ p = ngx_alloc(size, log);
+ if (p == NULL) {
return NGX_ERROR;
}
diff --git a/src/os/unix/ngx_socket.c b/src/os/unix/ngx_socket.c
index 523f1f4ce..121958977 100644
--- a/src/os/unix/ngx_socket.c
+++ b/src/os/unix/ngx_socket.c
@@ -22,7 +22,8 @@
#if (NGX_HAVE_FIONBIO)
-int ngx_nonblocking(ngx_socket_t s)
+int
+ngx_nonblocking(ngx_socket_t s)
{
u_long nb;
@@ -32,7 +33,8 @@ int ngx_nonblocking(ngx_socket_t s)
}
-int ngx_blocking(ngx_socket_t s)
+int
+ngx_blocking(ngx_socket_t s)
{
u_long nb;
@@ -46,7 +48,8 @@ int ngx_blocking(ngx_socket_t s)
#if (NGX_FREEBSD)
-int ngx_tcp_nopush(ngx_socket_t s)
+int
+ngx_tcp_nopush(ngx_socket_t s)
{
int tcp_nopush;
@@ -57,7 +60,8 @@ int ngx_tcp_nopush(ngx_socket_t s)
}
-int ngx_tcp_push(ngx_socket_t s)
+int
+ngx_tcp_push(ngx_socket_t s)
{
int tcp_nopush;
@@ -69,7 +73,8 @@ int ngx_tcp_push(ngx_socket_t s)
#elif (NGX_LINUX)
-int ngx_tcp_nopush(ngx_socket_t s)
+int
+ngx_tcp_nopush(ngx_socket_t s)
{
int cork;
@@ -79,7 +84,8 @@ int ngx_tcp_nopush(ngx_socket_t s)
(const void *) &cork, sizeof(int));
}
-int ngx_tcp_push(ngx_socket_t s)
+int
+ngx_tcp_push(ngx_socket_t s)
{
int cork;
@@ -91,14 +97,16 @@ int ngx_tcp_push(ngx_socket_t s)
#else
-int ngx_tcp_nopush(ngx_socket_t s)
+int
+ngx_tcp_nopush(ngx_socket_t s)
{
- return NGX_OK;
+ return 0;
}
-int ngx_tcp_push(ngx_socket_t s)
+int
+ngx_tcp_push(ngx_socket_t s)
{
- return NGX_OK;
+ return 0;
}
#endif
diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c
index c5b812091..4345385e3 100644
--- a/src/os/unix/ngx_solaris_sendfilev_chain.c
+++ b/src/os/unix/ngx_solaris_sendfilev_chain.c
@@ -47,7 +47,7 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS];
ngx_array_t vec;
ngx_event_t *wev;
- ngx_chain_t *cl, *tail;
+ ngx_chain_t *cl;
wev = c->write;
@@ -107,7 +107,8 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_len += (size_t) size;
} else {
- if (!(sfv = ngx_array_push(&vec))) {
+ sfv = ngx_array_push(&vec);
+ if (sfv == NULL) {
return NGX_CHAIN_ERROR;
}
@@ -140,7 +141,8 @@ ngx_chain_t *ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in,
sfv->sfv_len += (size_t) size;
} else {
- if (!(sfv = ngx_array_push(&vec))) {
+ sfv = ngx_array_push(&vec);
+ if (sfv == NULL) {
return NGX_CHAIN_ERROR;
}
diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c
index 9cbcd864d..ed3ad7158 100644
--- a/src/os/unix/ngx_writev_chain.c
+++ b/src/os/unix/ngx_writev_chain.c
@@ -12,7 +12,8 @@
#define NGX_IOVS 16
-ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
+ngx_chain_t *
+ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
{
u_char *prev;
ssize_t n, size, sent;
@@ -88,7 +89,8 @@ ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
iov->iov_len += size;
} else {
- if (!(iov = ngx_array_push(&vec))) {
+ iov = ngx_array_push(&vec);
+ if (iov == NULL) {
return NGX_CHAIN_ERROR;
}
diff --git a/src/os/win32/ngx_alloc.c b/src/os/win32/ngx_alloc.c
index e73aa32af..a3bca02a9 100644
--- a/src/os/win32/ngx_alloc.c
+++ b/src/os/win32/ngx_alloc.c
@@ -15,7 +15,8 @@ void *ngx_alloc(size_t size, ngx_log_t *log)
{
void *p;
- if (!(p = malloc(size))) {
+ p = malloc(size);
+ if (p == NULL) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
"malloc() %uz bytes failed", size);
}
diff --git a/src/os/win32/ngx_files.c b/src/os/win32/ngx_files.c
index ce0fdc966..bea580b24 100644
--- a/src/os/win32/ngx_files.c
+++ b/src/os/win32/ngx_files.c
@@ -179,7 +179,8 @@ ngx_int_t ngx_win32_rename_file(ngx_str_t *from, ngx_str_t *to,
ngx_uint_t collision;
ngx_atomic_uint_t num;
- if (!(name = ngx_palloc(pool, to->len + 1 + 10 + 1 + sizeof("DELETE")))) {
+ name = ngx_palloc(pool, to->len + 1 + 10 + 1 + sizeof("DELETE"));
+ if (name == NULL) {
return NGX_ERROR;
}
@@ -301,6 +302,20 @@ ngx_int_t ngx_read_dir(ngx_dir_t *dir)
}
+ngx_int_t
+ngx_de_info(u_char *name, ngx_dir_t *dir)
+{
+ return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_de_link_info(u_char *name, ngx_dir_t *dir)
+{
+ return NGX_OK;
+}
+
+
ngx_int_t ngx_file_append_mode(ngx_fd_t fd)
{
#if 0
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index 48b54b38a..a91743132 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -132,10 +132,13 @@ ngx_int_t ngx_read_dir(ngx_dir_t *dir);
#define ngx_de_name(dir) ((u_char *) (dir)->fd.cFileName)
#define ngx_de_namelen(dir) ngx_strlen((dir)->fd.cFileName)
-#define ngx_de_info(name, dir) NGX_OK
+
+ngx_int_t ngx_de_info(u_char *name, ngx_dir_t *dir);
#define ngx_de_info_n "dummy()"
-#define ngx_de_link_info(name, dir) NGX_OK
+
+ngx_int_t ngx_de_link_info(u_char *name, ngx_dir_t *dir);
#define ngx_de_link_info_n "dummy()"
+
#define ngx_de_is_dir(dir) \
((dir)->fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
#define ngx_de_is_file(dir) \
diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c
index e0635a5eb..2251ff2df 100644
--- a/src/os/win32/ngx_process_cycle.c
+++ b/src/os/win32/ngx_process_cycle.c
@@ -206,7 +206,7 @@ static void *ngx_worker_thread_cycle(void *data)
cycle = (ngx_cycle_t *) ngx_cycle;
- for ( ;; ) {
+ while (!ngx_quit) {
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "worker cycle");
ngx_process_events(cycle);
diff --git a/src/os/win32/ngx_socket.c b/src/os/win32/ngx_socket.c
index fc7743356..7590c3376 100644
--- a/src/os/win32/ngx_socket.c
+++ b/src/os/win32/ngx_socket.c
@@ -8,7 +8,8 @@
#include <ngx_core.h>
-int ngx_nonblocking(ngx_socket_t s)
+int
+ngx_nonblocking(ngx_socket_t s)
{
unsigned long nb = 1;
@@ -16,9 +17,17 @@ int ngx_nonblocking(ngx_socket_t s)
}
-int ngx_blocking(ngx_socket_t s)
+int
+ngx_blocking(ngx_socket_t s)
{
unsigned long nb = 0;
return ioctlsocket(s, FIONBIO, &nb);
}
+
+
+int
+ngx_tcp_push(ngx_socket_t s)
+{
+ return 0;
+}
diff --git a/src/os/win32/ngx_socket.h b/src/os/win32/ngx_socket.h
index 88752889a..95ecbe8cd 100644
--- a/src/os/win32/ngx_socket.h
+++ b/src/os/win32/ngx_socket.h
@@ -98,10 +98,7 @@ extern LPFN_GETACCEPTEXSOCKADDRS getacceptexsockaddrs;
extern LPFN_TRANSMITFILE transmitfile;
-static ngx_inline int ngx_tcp_push(ngx_socket_t s) {
- return 0;
-}
-
+int ngx_tcp_push(ngx_socket_t s);
#define ngx_tcp_push_n "tcp_push()"
diff --git a/src/os/win32/ngx_thread.c b/src/os/win32/ngx_thread.c
index 8fae0e379..0703ac7d4 100644
--- a/src/os/win32/ngx_thread.c
+++ b/src/os/win32/ngx_thread.c
@@ -66,3 +66,19 @@ ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
{
return (ngx_mutex_t *) 1;
}
+
+
+/* STUB */
+
+ngx_int_t
+ngx_mutex_lock(ngx_mutex_t *m) {
+ return NGX_OK;
+}
+
+
+ngx_int_t
+ngx_mutex_trylock(ngx_mutex_t *m) {
+ return NGX_OK;
+}
+
+/**/
diff --git a/src/os/win32/ngx_thread.h b/src/os/win32/ngx_thread.h
index 5b3c4da98..b55dcca4d 100644
--- a/src/os/win32/ngx_thread.h
+++ b/src/os/win32/ngx_thread.h
@@ -22,8 +22,8 @@ typedef struct {
} ngx_mutex_t;
-ngx_err_t ngx_create_thread(ngx_tid_t *tid, void* (*func)(void *arg), void *arg,
- ngx_log_t *log);
+ngx_err_t ngx_create_thread(ngx_tid_t *tid, void* (*func)(void *arg),
+ void *arg, ngx_log_t *log);
ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle);
ngx_err_t ngx_thread_key_create(ngx_tls_key_t *key);
@@ -41,14 +41,15 @@ ngx_err_t ngx_thread_set_tls(ngx_tls_key_t *key, void *data);
ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags);
+ngx_int_t ngx_mutex_lock(ngx_mutex_t *m);
+ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m);
+
/* STUB */
#define NGX_MUTEX_LIGHT 0
-#define ngx_mutex_lock(m) NGX_OK
-#define ngx_mutex_trylock(m) NGX_OK
#define ngx_mutex_unlock(m)
-/* */
+/**/
extern ngx_int_t ngx_threads_n;
diff --git a/src/os/win32/ngx_win32_config.h b/src/os/win32/ngx_win32_config.h
index 36af23906..02d4db5c6 100644
--- a/src/os/win32/ngx_win32_config.h
+++ b/src/os/win32/ngx_win32_config.h
@@ -37,7 +37,6 @@
#pragma warning(default:4201)
-
/* disable some "-W4" level warnings */
/* 'type cast': from function pointer to data pointer */
@@ -49,14 +48,13 @@
/* unreferenced formal parameter */
#pragma warning(disable:4100)
-/* conditional expression is constant */
+/* FD_SET() and FD_CLR(): conditional expression is constant */
#pragma warning(disable:4127)
-/* unreachable code */
-#pragma warning(disable:4702)
-
+#if 0
/* assignment within conditional expression */
#pragma warning(disable:4706)
+#endif
/* function 'ngx_handle_write_event' not inlined */
#pragma warning(disable:4710)
@@ -66,9 +64,6 @@
#ifdef __WATCOMC__
-/* unreachable code */
-#pragma disable_message(201)
-
/* symbol 'ngx_rbtree_min' has been defined, but not referenced */
#pragma disable_message(202)
@@ -80,25 +75,16 @@
/* the end of the precompiled headers */
#pragma hdrstop
-/*
- * 'fd' is assigned a value that is never used in function ngx_event_init_conf
- */
-#pragma warn -8004
-
-/* condition is always false */
-#pragma warn -8008
-
/* functions containing (for|while|some if) are not expanded inline */
#pragma warn -8027
/* unreferenced formal parameter */
#pragma warn -8057
+#if 0
/* assignment within conditional expression */
#pragma warn -8060
-
-/* unreachable code */
-#pragma warn -8066
+#endif
#endif
diff --git a/src/os/win32/ngx_wsarecv_chain.c b/src/os/win32/ngx_wsarecv_chain.c
index 2e2f7cc92..c22a08df7 100644
--- a/src/os/win32/ngx_wsarecv_chain.c
+++ b/src/os/win32/ngx_wsarecv_chain.c
@@ -9,16 +9,21 @@
#include <ngx_event.h>
-ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
+#define NGX_WSABUFS 8
+
+
+ssize_t
+ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
{
int rc;
u_char *prev;
u_long bytes, flags;
size_t size;
- WSABUF *wsabuf;
ngx_err_t err;
- ngx_array_t io;
+ ngx_array_t vec;
ngx_event_t *rev;
+ LPWSABUF wsabuf;
+ WSABUF wsabufs[NGX_WSABUFS];
prev = NULL;
wsabuf = NULL;
@@ -26,7 +31,11 @@ ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
size = 0;
bytes = 0;
- ngx_init_array(io, c->pool, 10, sizeof(WSABUF), NGX_ERROR);
+ vec.elts = wsabufs;
+ vec.nelts = 0;
+ vec.size = sizeof(WSABUF);
+ vec.nalloc = NGX_WSABUFS;
+ vec.pool = c->pool;
/* coalesce the neighbouring bufs */
@@ -35,7 +44,11 @@ ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
wsabuf->len += chain->buf->end - chain->buf->last;
} else {
- ngx_test_null(wsabuf, ngx_push_array(&io), NGX_ERROR);
+ wsabuf = ngx_array_push(&vec);
+ if (wsabuf == NULL) {
+ return NGX_ERROR;
+ }
+
wsabuf->buf = (char *) chain->buf->last;
wsabuf->len = chain->buf->end - chain->buf->last;
}
@@ -46,10 +59,10 @@ ssize_t ngx_wsarecv_chain(ngx_connection_t *c, ngx_chain_t *chain)
}
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "WSARecv: %d:%d", io.nelts, wsabuf->len);
+ "WSARecv: %d:%d", vec.nelts, wsabuf->len);
- rc = WSARecv(c->fd, io.elts, io.nelts, &bytes, &flags, NULL, NULL);
+ rc = WSARecv(c->fd, vec.elts, vec.nelts, &bytes, &flags, NULL, NULL);
rev = c->read;
diff --git a/src/os/win32/ngx_wsasend_chain.c b/src/os/win32/ngx_wsasend_chain.c
index d5b1334a1..bc3b01574 100644
--- a/src/os/win32/ngx_wsasend_chain.c
+++ b/src/os/win32/ngx_wsasend_chain.c
@@ -12,8 +12,8 @@
#define NGX_WSABUFS 8
-ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
- off_t limit)
+ngx_chain_t *
+ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
{
int rc;
u_char *prev;
@@ -22,9 +22,9 @@ ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
ngx_err_t err;
ngx_event_t *wev;
ngx_array_t vec;
+ ngx_chain_t *cl;
LPWSABUF wsabuf;
WSABUF wsabufs[NGX_WSABUFS];
- ngx_chain_t *cl;
wev = c->write;
@@ -78,7 +78,8 @@ ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
wsabuf->len += cl->buf->last - cl->buf->pos;
} else {
- if (!(wsabuf = ngx_array_push(&vec))) {
+ wsabuf = ngx_array_push(&vec);
+ if (wsabuf == NULL) {
return NGX_CHAIN_ERROR;
}
@@ -154,18 +155,18 @@ ngx_chain_t *ngx_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
}
-ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
- off_t limit)
+ngx_chain_t *
+ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
{
int rc;
u_char *prev;
u_long size, send, sent;
- LPWSABUF wsabuf;
ngx_err_t err;
ngx_event_t *wev;
ngx_array_t vec;
ngx_chain_t *cl;
LPWSAOVERLAPPED ovlp;
+ LPWSABUF wsabuf;
WSABUF wsabufs[NGX_WSABUFS];
wev = c->write;
@@ -222,7 +223,8 @@ ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in,
wsabuf->len += cl->buf->last - cl->buf->pos;
} else {
- if (!(wsabuf = ngx_array_push(&vec))) {
+ wsabuf = ngx_array_push(&vec);
+ if (wsabuf == NULL) {
return NGX_CHAIN_ERROR;
}