diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2005-03-19 12:38:37 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2005-03-19 12:38:37 +0000 |
| commit | c15717285d2157a603bb1b130b26d7baa549be7e (patch) | |
| tree | 56dc8346b22bb2660eecd3bc086d263ac6d67326 /src/event | |
| parent | e12fbfe82a176cd386cdcecfeabf43ac8fd870a4 (diff) | |
| download | nginx-release-0.1.25.tar.gz nginx-release-0.1.25.tar.bz2 | |
nginx-0.1.25-RELEASE importrelease-0.1.25
*) Bugfix: nginx did run on Linux parisc.
*) Feature: nginx now does not start under FreeBSD if the sysctl
kern.ipc.somaxconn value is too big.
*) Bugfix: if a request was internally redirected by the
ngx_http_index_module module to the ngx_http_proxy_module or
ngx_http_fastcgi_module modules, then the index file was not closed
after request completion.
*) Feature: the "proxy_pass" can be used in location with regular
expression.
*) Feature: the ngx_http_rewrite_filter_module module supports the
condition like "if ($HTTP_USER_AGENT ~ MSIE)".
*) Bugfix: nginx started too slow if the large number of addresses and
text values were used in the "geo" directive.
*) Change: a variable name must be declared as "$name" in the "geo"
directive. The previous variant without "$" is still supported, but
will be removed soon.
*) Feature: the "%{VARIABLE}v" logging parameter.
*) Feature: the "set $name value" directive.
*) Bugfix: gcc 4.0 compatibility.
*) Feature: the --with-openssl-opt=OPTIONS autoconfiguration directive.
Diffstat (limited to 'src/event')
| -rw-r--r-- | src/event/modules/ngx_devpoll_module.c | 37 | ||||
| -rw-r--r-- | src/event/modules/ngx_epoll_module.c | 8 | ||||
| -rw-r--r-- | src/event/modules/ngx_iocp_module.c | 27 | ||||
| -rw-r--r-- | src/event/modules/ngx_kqueue_module.c | 12 | ||||
| -rw-r--r-- | src/event/modules/ngx_poll_module.c | 18 | ||||
| -rw-r--r-- | src/event/modules/ngx_rtsig_module.c | 9 | ||||
| -rw-r--r-- | src/event/modules/ngx_select_module.c | 37 | ||||
| -rw-r--r-- | src/event/ngx_event.c | 103 | ||||
| -rw-r--r-- | src/event/ngx_event_accept.c | 20 | ||||
| -rw-r--r-- | src/event/ngx_event_acceptex.c | 12 | ||||
| -rw-r--r-- | src/event/ngx_event_openssl.c | 10 | ||||
| -rw-r--r-- | src/event/ngx_event_pipe.c | 40 | ||||
| -rw-r--r-- | src/event/ngx_event_posted.c | 2 | ||||
| -rw-r--r-- | src/event/ngx_event_timer.c | 3 | ||||
| -rw-r--r-- | src/event/ngx_event_timer.h | 4 |
15 files changed, 220 insertions, 122 deletions
diff --git a/src/event/modules/ngx_devpoll_module.c b/src/event/modules/ngx_devpoll_module.c index 2d94ba477..57b6b1239 100644 --- a/src/event/modules/ngx_devpoll_module.c +++ b/src/event/modules/ngx_devpoll_module.c @@ -134,19 +134,21 @@ ngx_devpoll_init(ngx_cycle_t *cycle) ngx_free(change_list); } - ngx_test_null(change_list, - ngx_alloc(sizeof(struct pollfd) * dpcf->changes, - cycle->log), - NGX_ERROR); + change_list = ngx_alloc(sizeof(struct pollfd) * dpcf->changes, + cycle->log); + if (change_list == NULL) { + return NGX_ERROR; + } if (change_index) { ngx_free(change_index); } - ngx_test_null(change_index, - ngx_alloc(sizeof(ngx_event_t *) * dpcf->changes, - cycle->log), - NGX_ERROR); + change_index = ngx_alloc(sizeof(ngx_event_t *) * dpcf->changes, + cycle->log); + if (change_index == NULL) { + return NGX_ERROR; + } } max_changes = dpcf->changes; @@ -156,10 +158,11 @@ ngx_devpoll_init(ngx_cycle_t *cycle) ngx_free(event_list); } - ngx_test_null(event_list, - ngx_alloc(sizeof(struct pollfd) * dpcf->events, - cycle->log), - NGX_ERROR); + event_list = ngx_alloc(sizeof(struct pollfd) * dpcf->events, + cycle->log); + if (event_list == NULL) { + return NGX_ERROR; + } } nevents = dpcf->events; @@ -318,11 +321,13 @@ ngx_devpoll_process_events(ngx_cycle_t *cycle) { int events, revents; ngx_int_t i; - ngx_uint_t j, lock, accept_lock, expire; + ngx_uint_t lock, accept_lock, expire; size_t n; ngx_msec_t timer; ngx_err_t err; +#if 0 ngx_cycle_t **old_cycle; +#endif ngx_event_t *rev, *wev; ngx_connection_t *c; ngx_epoch_msec_t delta; @@ -580,8 +585,10 @@ ngx_devpoll_create_conf(ngx_cycle_t *cycle) { ngx_devpoll_conf_t *dpcf; - ngx_test_null(dpcf, ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t)), - NGX_CONF_ERROR); + dpcf = ngx_palloc(cycle->pool, sizeof(ngx_devpoll_conf_t)); + if (dpcf == NULL) { + return NGX_CONF_ERROR; + } dpcf->changes = NGX_CONF_UNSET; dpcf->events = NGX_CONF_UNSET; diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c index f2c973f24..14b77508c 100644 --- a/src/event/modules/ngx_epoll_module.c +++ b/src/event/modules/ngx_epoll_module.c @@ -133,7 +133,6 @@ ngx_module_t ngx_epoll_module = { static ngx_int_t ngx_epoll_init(ngx_cycle_t *cycle) { - size_t n; ngx_event_conf_t *ecf; ngx_epoll_conf_t *epcf; @@ -380,7 +379,6 @@ static ngx_int_t ngx_epoll_process_events(ngx_cycle_t *cycle) { int events; - size_t n; uint32_t revents; ngx_int_t instance, i; ngx_uint_t lock, accept_lock, expire; @@ -663,8 +661,10 @@ ngx_epoll_create_conf(ngx_cycle_t *cycle) { ngx_epoll_conf_t *epcf; - ngx_test_null(epcf, ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t)), - NGX_CONF_ERROR); + epcf = ngx_palloc(cycle->pool, sizeof(ngx_epoll_conf_t)); + if (epcf == NULL) { + return NGX_CONF_ERROR; + } epcf->events = NGX_CONF_UNSET; diff --git a/src/event/modules/ngx_iocp_module.c b/src/event/modules/ngx_iocp_module.c index 4a3cd9fe9..0a04a209a 100644 --- a/src/event/modules/ngx_iocp_module.c +++ b/src/event/modules/ngx_iocp_module.c @@ -90,7 +90,8 @@ ngx_os_io_t ngx_iocp_io = { static HANDLE iocp; -static ngx_int_t ngx_iocp_init(ngx_cycle_t *cycle) +static ngx_int_t +ngx_iocp_init(ngx_cycle_t *cycle) { ngx_iocp_conf_t *cf; @@ -117,7 +118,8 @@ static ngx_int_t ngx_iocp_init(ngx_cycle_t *cycle) } -static void ngx_iocp_done(ngx_cycle_t *cycle) +static void +ngx_iocp_done(ngx_cycle_t *cycle) { if (CloseHandle(iocp) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, @@ -128,7 +130,8 @@ static void ngx_iocp_done(ngx_cycle_t *cycle) } -static ngx_int_t ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key) +static ngx_int_t +ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key) { ngx_connection_t *c; @@ -150,7 +153,8 @@ static ngx_int_t ngx_iocp_add_event(ngx_event_t *ev, int event, u_int key) } -static ngx_int_t ngx_iocp_del_connection(ngx_connection_t *c, u_int flags) +static ngx_int_t +ngx_iocp_del_connection(ngx_connection_t *c, u_int flags) { #if 0 if (flags & NGX_CLOSE_EVENT) { @@ -167,7 +171,8 @@ static ngx_int_t ngx_iocp_del_connection(ngx_connection_t *c, u_int flags) } -static ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle) +static +ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle) { int rc; u_int key; @@ -301,12 +306,15 @@ static ngx_int_t ngx_iocp_process_events(ngx_cycle_t *cycle) } -static void *ngx_iocp_create_conf(ngx_cycle_t *cycle) +static void * +ngx_iocp_create_conf(ngx_cycle_t *cycle) { ngx_iocp_conf_t *cf; - ngx_test_null(cf, ngx_palloc(cycle->pool, sizeof(ngx_iocp_conf_t)), - NGX_CONF_ERROR); + cf = ngx_palloc(cycle->pool, sizeof(ngx_iocp_conf_t)); + if (cf == NULL) { + return NGX_CONF_ERROR; + } cf->threads = NGX_CONF_UNSET; cf->post_acceptex = NGX_CONF_UNSET; @@ -316,7 +324,8 @@ static void *ngx_iocp_create_conf(ngx_cycle_t *cycle) } -static char *ngx_iocp_init_conf(ngx_cycle_t *cycle, void *conf) +static char * +ngx_iocp_init_conf(ngx_cycle_t *cycle, void *conf) { ngx_iocp_conf_t *cf = conf; diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c index b4555d983..14bbfaf27 100644 --- a/src/event/modules/ngx_kqueue_module.c +++ b/src/event/modules/ngx_kqueue_module.c @@ -123,11 +123,13 @@ ngx_kqueue_init(ngx_cycle_t *cycle) #if (NGX_THREADS) - if (!(list_mutex = ngx_mutex_init(cycle->log, 0))) { + list_mutex = ngx_mutex_init(cycle->log, 0); + if (list_mutex == NULL) { return NGX_ERROR; } - if (!(kevent_mutex = ngx_mutex_init(cycle->log, 0))) { + kevent_mutex = ngx_mutex_init(cycle->log, 0); + if (kevent_mutex == NULL) { return NGX_ERROR; } @@ -797,8 +799,10 @@ ngx_kqueue_create_conf(ngx_cycle_t *cycle) { ngx_kqueue_conf_t *kcf; - ngx_test_null(kcf, ngx_palloc(cycle->pool, sizeof(ngx_kqueue_conf_t)), - NGX_CONF_ERROR); + kcf = ngx_palloc(cycle->pool, sizeof(ngx_kqueue_conf_t)); + if (kcf == NULL) { + return NGX_CONF_ERROR; + } kcf->changes = NGX_CONF_UNSET; kcf->events = NGX_CONF_UNSET; diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c index 6ea3af4e4..c25a5611c 100644 --- a/src/event/modules/ngx_poll_module.c +++ b/src/event/modules/ngx_poll_module.c @@ -73,10 +73,11 @@ ngx_poll_init(ngx_cycle_t *cycle) || cycle->old_cycle == NULL || cycle->old_cycle->connection_n < cycle->connection_n) { - ngx_test_null(list, - ngx_alloc(sizeof(struct pollfd) * cycle->connection_n, - cycle->log), - NGX_ERROR); + list = ngx_alloc(sizeof(struct pollfd) * cycle->connection_n, + cycle->log); + if (list == NULL) { + return NGX_ERROR; + } if (event_list) { ngx_memcpy(list, event_list, sizeof(ngx_event_t *) * nevents); @@ -90,10 +91,11 @@ ngx_poll_init(ngx_cycle_t *cycle) ngx_free(ready_index); } - ngx_test_null(ready_index, - ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n, - cycle->log), - NGX_ERROR); + ready_index = ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n, + cycle->log); + if (ready_index == NULL) { + return NGX_ERROR; + } #endif } diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c index 07b8bd9d6..6c94977db 100644 --- a/src/event/modules/ngx_rtsig_module.c +++ b/src/event/modules/ngx_rtsig_module.c @@ -274,9 +274,8 @@ static ngx_int_t ngx_rtsig_process_events(ngx_cycle_t *cycle) { int signo; - ngx_int_t instance, i; + ngx_int_t instance; ngx_uint_t expire; - size_t n; ngx_msec_t timer; ngx_err_t err; siginfo_t si; @@ -777,8 +776,10 @@ ngx_rtsig_create_conf(ngx_cycle_t *cycle) { ngx_rtsig_conf_t *rtscf; - ngx_test_null(rtscf, ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t)), - NGX_CONF_ERROR); + rtscf = ngx_palloc(cycle->pool, sizeof(ngx_rtsig_conf_t)); + if (rtscf == NULL) { + return NGX_CONF_ERROR; + } rtscf->signo = NGX_CONF_UNSET; rtscf->overflow_events = NGX_CONF_UNSET; diff --git a/src/event/modules/ngx_select_module.c b/src/event/modules/ngx_select_module.c index 623e13c16..6edc2840a 100644 --- a/src/event/modules/ngx_select_module.c +++ b/src/event/modules/ngx_select_module.c @@ -72,7 +72,8 @@ ngx_module_t ngx_select_module = { }; -static ngx_int_t ngx_select_init(ngx_cycle_t *cycle) +static ngx_int_t +ngx_select_init(ngx_cycle_t *cycle) { ngx_event_t **index; @@ -86,10 +87,11 @@ static ngx_int_t ngx_select_init(ngx_cycle_t *cycle) || cycle->old_cycle == NULL || cycle->old_cycle->connection_n < cycle->connection_n) { - ngx_test_null(index, - ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n, - cycle->log), - NGX_ERROR); + index = ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n, + cycle->log); + if (index == NULL) { + return NGX_ERROR; + } if (event_index) { ngx_memcpy(index, event_index, sizeof(ngx_event_t *) * nevents); @@ -101,10 +103,12 @@ static ngx_int_t ngx_select_init(ngx_cycle_t *cycle) if (ready_index) { ngx_free(ready_index); } - ngx_test_null(ready_index, - ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n, - cycle->log), - NGX_ERROR); + + ready_index = ngx_alloc(sizeof(ngx_event_t *) * 2 * cycle->connection_n, + cycle->log); + if (ready_index == NULL) { + return NGX_ERROR; + } #endif } @@ -124,7 +128,8 @@ static ngx_int_t ngx_select_init(ngx_cycle_t *cycle) } -static void ngx_select_done(ngx_cycle_t *cycle) +static void +ngx_select_done(ngx_cycle_t *cycle) { ngx_free(event_index); #if 0 @@ -135,7 +140,8 @@ static void ngx_select_done(ngx_cycle_t *cycle) } -static ngx_int_t ngx_select_add_event(ngx_event_t *ev, int event, u_int flags) +static ngx_int_t +ngx_select_add_event(ngx_event_t *ev, int event, u_int flags) { ngx_connection_t *c; @@ -196,7 +202,8 @@ static ngx_int_t ngx_select_add_event(ngx_event_t *ev, int event, u_int flags) } -static ngx_int_t ngx_select_del_event(ngx_event_t *ev, int event, u_int flags) +static ngx_int_t +ngx_select_del_event(ngx_event_t *ev, int event, u_int flags) { ngx_connection_t *c; @@ -248,7 +255,8 @@ static ngx_int_t ngx_select_del_event(ngx_event_t *ev, int event, u_int flags) } -static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle) +static ngx_int_t +ngx_select_process_events(ngx_cycle_t *cycle) { int ready, nready; ngx_uint_t i, found, lock, expire; @@ -592,7 +600,8 @@ static ngx_int_t ngx_select_process_events(ngx_cycle_t *cycle) } -static char *ngx_select_init_conf(ngx_cycle_t *cycle, void *conf) +static char * +ngx_select_init_conf(ngx_cycle_t *cycle, void *conf) { ngx_event_conf_t *ecf; diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c index 5a002c001..371c5c706 100644 --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -219,7 +219,8 @@ static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle) #endif - if (!(shared = ngx_create_shared_memory(size, cycle->log))) { + shared = ngx_create_shared_memory(size, cycle->log); + if (shared == NULL) { return NGX_ERROR; } @@ -272,7 +273,8 @@ static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle) } #if (NGX_THREADS) - if (!(ngx_posted_events_mutex = ngx_mutex_init(cycle->log, 0))) { + ngx_posted_events_mutex = ngx_mutex_init(cycle->log, 0); + if (ngx_posted_events_mutex == NULL) { return NGX_ERROR; } #endif @@ -497,42 +499,47 @@ ngx_int_t ngx_send_lowat(ngx_connection_t *c, size_t lowat) static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { - int m; - char *rv; + char *rv; void ***ctx; + ngx_uint_t i; ngx_conf_t pcf; - ngx_event_module_t *module; + ngx_event_module_t *m; /* count the number of the event modules and set up their indices */ ngx_event_max_module = 0; - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE) { + for (i = 0; ngx_modules[i]; i++) { + if (ngx_modules[i]->type != NGX_EVENT_MODULE) { continue; } - ngx_modules[m]->ctx_index = ngx_event_max_module++; + ngx_modules[i]->ctx_index = ngx_event_max_module++; } - ngx_test_null(ctx, ngx_pcalloc(cf->pool, sizeof(void *)), NGX_CONF_ERROR); + ctx = ngx_pcalloc(cf->pool, sizeof(void *)); + if (ctx == NULL) { + return NGX_CONF_ERROR; + } - ngx_test_null(*ctx, - ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *)), - NGX_CONF_ERROR); + *ctx = ngx_pcalloc(cf->pool, ngx_event_max_module * sizeof(void *)); + if (*ctx == NULL) { + return NGX_CONF_ERROR; + } *(void **) conf = ctx; - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE) { + for (i = 0; ngx_modules[i]; i++) { + if (ngx_modules[i]->type != NGX_EVENT_MODULE) { continue; } - module = ngx_modules[m]->ctx; + m = ngx_modules[i]->ctx; - if (module->create_conf) { - ngx_test_null((*ctx)[ngx_modules[m]->ctx_index], - module->create_conf(cf->cycle), - NGX_CONF_ERROR); + if (m->create_conf) { + (*ctx)[ngx_modules[i]->ctx_index] = m->create_conf(cf->cycle); + if ((*ctx)[ngx_modules[i]->ctx_index] == NULL) { + return NGX_CONF_ERROR; + } } } @@ -540,22 +547,23 @@ static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) cf->ctx = ctx; cf->module_type = NGX_EVENT_MODULE; cf->cmd_type = NGX_EVENT_CONF; + rv = ngx_conf_parse(cf, NULL); + *cf = pcf; if (rv != NGX_CONF_OK) return rv; - for (m = 0; ngx_modules[m]; m++) { - if (ngx_modules[m]->type != NGX_EVENT_MODULE) { + for (i = 0; ngx_modules[i]; i++) { + if (ngx_modules[i]->type != NGX_EVENT_MODULE) { continue; } - module = ngx_modules[m]->ctx; + m = ngx_modules[i]->ctx; - if (module->init_conf) { - rv = module->init_conf(cf->cycle, - (*ctx)[ngx_modules[m]->ctx_index]); + if (m->init_conf) { + rv = m->init_conf(cf->cycle, (*ctx)[ngx_modules[i]->ctx_index]); if (rv != NGX_CONF_OK) { return rv; } @@ -668,7 +676,8 @@ static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, /* AF_INET only */ - if (!(addr = ngx_push_array(&ecf->debug_connection))) { + addr = ngx_array_push(&ecf->debug_connection); + if (addr == NULL) { return NGX_CONF_ERROR; } @@ -704,8 +713,10 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle) { ngx_event_conf_t *ecf; - ngx_test_null(ecf, ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)), - NGX_CONF_ERROR); + ecf = ngx_palloc(cycle->pool, sizeof(ngx_event_conf_t)); + if (ecf == NULL) { + return NGX_CONF_ERROR; + } ecf->connections = NGX_CONF_UNSET_UINT; ecf->use = NGX_CONF_UNSET_UINT; @@ -715,8 +726,13 @@ static void *ngx_event_create_conf(ngx_cycle_t *cycle) ecf->name = (void *) NGX_CONF_UNSET; #if (NGX_DEBUG) - ngx_init_array(ecf->debug_connection, cycle->pool, 4, sizeof(in_addr_t), - NGX_CONF_ERROR); + + if (ngx_array_init(&ecf->debug_connection, cycle->pool, 4, + sizeof(in_addr_t)) == NGX_ERROR) + { + return NGX_CONF_ERROR; + } + #endif return ecf; @@ -727,7 +743,12 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) { ngx_event_conf_t *ecf = conf; - int fd, rtsig; +#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) + int fd; +#endif +#if (NGX_HAVE_RTSIG) + ngx_uint_t rtsig; +#endif ngx_int_t i, connections; ngx_module_t *module; ngx_core_conf_t *ccf; @@ -735,8 +756,6 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) connections = NGX_CONF_UNSET_UINT; module = NULL; - rtsig = 0; - fd = 0; #if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL) @@ -760,6 +779,9 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) connections = DEFAULT_CONNECTIONS; module = &ngx_rtsig_module; rtsig = 1; + + } else { + rtsig = 0; } #endif @@ -782,11 +804,10 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) if (module == NULL) { -#if (NGX_WIN32) +#if (NGX_WIN32 || FD_SETSIZE >= DEFAULT_CONNECTIONS) connections = DEFAULT_CONNECTIONS; #else - connections = FD_SETSIZE < DEFAULT_CONNECTIONS ? FD_SETSIZE: - DEFAULT_CONNECTIONS; + connections = FD_SETSIZE; #endif module = &ngx_select_module; } @@ -828,7 +849,15 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) ngx_conf_init_msec_value(ecf->accept_mutex_delay, 500); - if (!rtsig || ecf->accept_mutex) { +#if (NGX_HAVE_RTSIG) + + if (!rtsig) { + return NGX_CONF_OK; + } + +#endif + + if (ecf->accept_mutex) { return NGX_CONF_OK; } diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c index f30e1fcc3..8e2a1ea9a 100644 --- a/src/event/ngx_event_accept.c +++ b/src/event/ngx_event_accept.c @@ -16,7 +16,10 @@ static u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len); void ngx_event_accept(ngx_event_t *ev) { - ngx_uint_t instance, accepted; + ngx_uint_t instance; +#if 0 + ngx_uint_t accepted; +#endif socklen_t len; struct sockaddr *sa; ngx_err_t err; @@ -43,8 +46,10 @@ ngx_event_accept(ngx_event_t *ev) &ls->listening->addr_text, ev->available); ev->ready = 0; - accepted = 0; pool = NULL; +#if 0 + accepted = 0; +#endif do { @@ -56,17 +61,20 @@ ngx_event_accept(ngx_event_t *ev) * case and besides the pool can be got from the free pool list. */ - if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) { + pool = ngx_create_pool(ls->listening->pool_size, ev->log); + if (pool == NULL) { return; } } - if (!(sa = ngx_palloc(pool, ls->listening->socklen))) { + sa = ngx_palloc(pool, ls->listening->socklen); + if (sa == NULL) { ngx_destroy_pool(pool); return; } - if (!(log = ngx_palloc(pool, sizeof(ngx_log_t)))) { + log = ngx_palloc(pool, sizeof(ngx_log_t)); + if (log == NULL) { ngx_destroy_pool(pool); return; } @@ -331,7 +339,9 @@ ngx_event_accept(ngx_event_t *ev) ev->available--; } +#if 0 accepted++; +#endif } while (ev->available); } diff --git a/src/event/ngx_event_acceptex.c b/src/event/ngx_event_acceptex.c index d01dbf122..b02dfd0d5 100644 --- a/src/event/ngx_event_acceptex.c +++ b/src/event/ngx_event_acceptex.c @@ -153,7 +153,8 @@ int ngx_event_post_acceptex(ngx_listening_t *ls, int n) c->recv = ngx_recv; c->send_chain = ngx_send_chain; - if (!(c->pool = ngx_create_pool(ls->pool_size, ls->log))) { + c->pool = ngx_create_pool(ls->pool_size, ls->log); + if (c->pool == NULL) { return NGX_ERROR; } @@ -164,15 +165,18 @@ int ngx_event_post_acceptex(ngx_listening_t *ls, int n) return NGX_ERROR; } - if (!(c->local_sockaddr = ngx_palloc(c->pool, ls->socklen))) { + c->local_sockaddr = ngx_palloc(c->pool, ls->socklen); + if (c->local_sockaddr == NULL) { return NGX_ERROR; } - if (!(c->sockaddr = ngx_palloc(c->pool, ls->socklen))) { + c->sockaddr = ngx_palloc(c->pool, ls->socklen); + if (c->sockaddr == NULL) { return NGX_ERROR; } - if (!(c->log = ngx_palloc(c->pool, sizeof(ngx_log_t)))) { + c->log = ngx_palloc(c->pool, sizeof(ngx_log_t)); + if (c->log == NULL) { return NGX_ERROR; } diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c index b65779088..d213eb158 100644 --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -20,8 +20,6 @@ static void ngx_ssl_read_handler(ngx_event_t *rev); ngx_int_t ngx_ssl_init(ngx_log_t *log) { - ENGINE *engine; - SSL_library_init(); SSL_load_error_strings(); ENGINE_load_builtin_engines(); @@ -36,11 +34,13 @@ ngx_ssl_create_session(ngx_ssl_ctx_t *ssl_ctx, ngx_connection_t *c, { ngx_ssl_t *ssl; - if (!(ssl = ngx_pcalloc(c->pool, sizeof(ngx_ssl_t)))) { + ssl = ngx_pcalloc(c->pool, sizeof(ngx_ssl_t)); + if (ssl == NULL) { return NGX_ERROR; } - if (!(ssl->buf = ngx_create_temp_buf(c->pool, NGX_SSL_BUFSIZE))) { + ssl->buf = ngx_create_temp_buf(c->pool, NGX_SSL_BUFSIZE); + if (ssl->buf == NULL) { return NGX_ERROR; } @@ -586,7 +586,7 @@ ngx_ssl_error(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, char *fmt, ...) p = ngx_vsnprintf(errstr, sizeof(errstr) - 1, fmt, args); va_end(args); - p = ngx_cpystrn(p, " (SSL: ", last - p); + p = ngx_cpystrn(p, (u_char *) " (SSL: ", last - p); ERR_error_string_n(ERR_get_error(), (char *) p, last - p); diff --git a/src/event/ngx_event_pipe.c b/src/event/ngx_event_pipe.c index 0206bf8fe..b5488ba7d 100644 --- a/src/event/ngx_event_pipe.c +++ b/src/event/ngx_event_pipe.c @@ -165,13 +165,15 @@ static ngx_int_t ngx_event_pipe_read_upstream(ngx_event_pipe_t *p) /* allocate a new buf if it's still allowed */ - if (!(b = ngx_create_temp_buf(p->pool, p->bufs.size))) { + b = ngx_create_temp_buf(p->pool, p->bufs.size); + if (b == NULL) { return NGX_ABORT; } p->allocated++; - if (!(chain = ngx_alloc_chain_link(p->pool))) { + chain = ngx_alloc_chain_link(p->pool); + if (chain == NULL) { return NGX_ABORT; } @@ -495,7 +497,13 @@ static ngx_int_t ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p) } cl->next = NULL; - ngx_chain_add_link(out, ll, cl); + + if (out) { + *ll = cl; + } else { + out = cl; + } + ll = &cl->next; } ngx_log_debug2(NGX_LOG_DEBUG_EVENT, p->log, 0, @@ -635,11 +643,17 @@ static ngx_int_t ngx_event_pipe_write_chain_to_temp_file(ngx_event_pipe_t *p) b->in_file = 1; b->temp_file = 1; - ngx_chain_add_link(p->out, p->last_out, cl); + if (p->out) { + *p->last_out = cl; + } else { + p->out = cl; + } + p->last_out = &cl->next; if (b->last_shadow) { - if (!(tl = ngx_alloc_chain_link(p->pool))) { + tl = ngx_alloc_chain_link(p->pool); + if (tl == NULL) { return NGX_ABORT; } @@ -676,7 +690,8 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) p->free = p->free->next; } else { - if (!(b = ngx_alloc_buf(p->pool))) { + b = ngx_alloc_buf(p->pool); + if (b == NULL) { return NGX_ERROR; } } @@ -688,7 +703,8 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) b->recycled = 1; buf->shadow = b; - if (!(cl = ngx_alloc_chain_link(p->pool))) { + cl = ngx_alloc_chain_link(p->pool); + if (cl == NULL) { return NGX_ERROR; } @@ -697,7 +713,12 @@ ngx_int_t ngx_event_pipe_copy_input_filter(ngx_event_pipe_t *p, ngx_buf_t *buf) ngx_log_debug1(NGX_LOG_DEBUG_EVENT, p->log, 0, "input buf #%d", b->num); - ngx_chain_add_link(p->in, p->last_in, cl); + if (p->in) { + *p->last_in = cl; + } else { + p->in = cl; + } + p->last_in = &cl->next; return NGX_OK; } @@ -766,7 +787,8 @@ ngx_int_t ngx_event_pipe_add_free_buf(ngx_event_pipe_t *p, ngx_buf_t *b) { ngx_chain_t *cl; - if (!(cl = ngx_alloc_chain_link(p->pool))) { + cl = ngx_alloc_chain_link(p->pool); + if (cl == NULL) { return NGX_ERROR; } diff --git a/src/event/ngx_event_posted.c b/src/event/ngx_event_posted.c index a99a434cb..8050c326f 100644 --- a/src/event/ngx_event_posted.c +++ b/src/event/ngx_event_posted.c @@ -43,10 +43,10 @@ void ngx_event_process_posted(ngx_cycle_t *cycle) void ngx_wakeup_worker_thread(ngx_cycle_t *cycle) { ngx_int_t i; +#if 0 ngx_uint_t busy; ngx_event_t *ev; -#if 0 busy = 1; if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { diff --git a/src/event/ngx_event_timer.c b/src/event/ngx_event_timer.c index 4b9865650..7655c4fd8 100644 --- a/src/event/ngx_event_timer.c +++ b/src/event/ngx_event_timer.c @@ -31,7 +31,8 @@ ngx_event_timer_init(ngx_log_t *log) ngx_event_timer_rbtree = &ngx_event_timer_sentinel; #if (NGX_THREADS) - if (!(ngx_event_timer_mutex = ngx_mutex_init(log, 0))) { + ngx_event_timer_mutex = ngx_mutex_init(log, 0); + if (ngx_event_timer_mutex == NULL) { return NGX_ERROR; } #endif diff --git a/src/event/ngx_event_timer.h b/src/event/ngx_event_timer.h index edbfcf604..4954809e7 100644 --- a/src/event/ngx_event_timer.h +++ b/src/event/ngx_event_timer.h @@ -13,8 +13,8 @@ #include <ngx_event.h> -#define NGX_TIMER_INFINITE -1 -#define NGX_TIMER_ERROR -2 +#define NGX_TIMER_INFINITE (ngx_msec_t) -1 +#define NGX_TIMER_ERROR (ngx_msec_t) -2 /* |
