diff options
Diffstat (limited to '')
| -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 |
7 files changed, 90 insertions, 58 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; |
