diff options
Diffstat (limited to 'src/event')
| -rw-r--r-- | src/event/modules/ngx_rtsig_module.c | 10 | ||||
| -rw-r--r-- | src/event/ngx_event.c | 20 | ||||
| -rw-r--r-- | src/event/ngx_event_accept.c | 27 | ||||
| -rw-r--r-- | src/event/ngx_event_timer.c | 9 | ||||
| -rw-r--r-- | src/event/ngx_event_timer.h | 19 |
5 files changed, 50 insertions, 35 deletions
diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c index d017f05bd..f1df54991 100644 --- a/src/event/modules/ngx_rtsig_module.c +++ b/src/event/modules/ngx_rtsig_module.c @@ -701,18 +701,18 @@ static ngx_int_t ngx_rtsig_process_overflow(ngx_cycle_t *cycle) name[0] = CTL_KERN; name[1] = KERN_RTSIGMAX; len = sizeof(rtsig_max); - if (sysctl(name, sizeof(name), &rtsig_max, &len, NULL, 0) == -1) - { + + if (sysctl(name, 2, &rtsig_max, &len, NULL, 0) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, "sysctl(KERN_RTSIGMAX) failed"); return NGX_ERROR; } - name[0] = CTL_KERN; + /* name[0] = CTL_KERN; */ name[1] = KERN_RTSIGNR; len = sizeof(rtsig_nr); - if (sysctl(name, sizeof(name), &rtsig_nr, &len, NULL, 0) == -1) - { + + if (sysctl(name, 2, &rtsig_nr, &len, NULL, 0) == -1) { ngx_log_error(NGX_LOG_ALERT, cycle->log, errno, "sysctl(KERN_RTSIGNR) failed"); return NGX_ERROR; diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c index d79e5ff71..780dbeba5 100644 --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -34,21 +34,21 @@ static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf); static char *ngx_accept_mutex_check(ngx_conf_t *cf, void *post, void *data); -static ngx_uint_t ngx_event_max_module; +static ngx_uint_t ngx_event_max_module; -ngx_uint_t ngx_event_flags; -ngx_event_actions_t ngx_event_actions; +ngx_uint_t ngx_event_flags; +ngx_event_actions_t ngx_event_actions; -ngx_atomic_t connection_counter; -ngx_atomic_t *ngx_connection_counter = &connection_counter; +ngx_atomic_t connection_counter; +ngx_atomic_t *ngx_connection_counter = &connection_counter; -ngx_atomic_t *ngx_accept_mutex_ptr; -ngx_atomic_t *ngx_accept_mutex; -ngx_uint_t ngx_accept_mutex_held; -ngx_msec_t ngx_accept_mutex_delay; -ngx_int_t ngx_accept_disabled; +ngx_atomic_t *ngx_accept_mutex_ptr; +ngx_atomic_t *ngx_accept_mutex; +ngx_uint_t ngx_accept_mutex_held; +ngx_msec_t ngx_accept_mutex_delay; +ngx_int_t ngx_accept_disabled; #if (NGX_STAT_STUB) diff --git a/src/event/ngx_event_accept.c b/src/event/ngx_event_accept.c index c7f759553..fb2d98473 100644 --- a/src/event/ngx_event_accept.c +++ b/src/event/ngx_event_accept.c @@ -7,14 +7,14 @@ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> -#include <nginx.h> static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log); 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) +void +ngx_event_accept(ngx_event_t *ev) { ngx_uint_t instance, accepted; socklen_t len; @@ -53,7 +53,7 @@ void ngx_event_accept(ngx_event_t *ev) /* * Create the pool before accept() to avoid the copying of * the sockaddr. Although accept() can fail it is uncommon - * case and besides the pool can be got from the free pool list + * case and besides the pool can be got from the free pool list. */ if (!(pool = ngx_create_pool(ls->listening->pool_size, ev->log))) { @@ -117,7 +117,7 @@ void ngx_event_accept(ngx_event_t *ev) } #if (NGX_STAT_STUB) - (*ngx_stat_accepted)++; + ngx_atomic_inc(ngx_stat_accepted); #endif ngx_accept_disabled = (ngx_uint_t) s + NGX_ACCEPT_THRESHOLD @@ -139,7 +139,7 @@ void ngx_event_accept(ngx_event_t *ev) } #if (NGX_STAT_STUB) - (*ngx_stat_active)++; + ngx_atomic_inc(ngx_stat_active); #endif /* set a blocking mode for aio and non-blocking mode for others */ @@ -234,7 +234,7 @@ void ngx_event_accept(ngx_event_t *ev) wev->ready = 1; if (ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT)) { - /* epoll, rtsig, aio, iocp */ + /* rtsig, aio, iocp */ rev->ready = 1; } @@ -336,7 +336,8 @@ void ngx_event_accept(ngx_event_t *ev) } -ngx_int_t ngx_trylock_accept_mutex(ngx_cycle_t *cycle) +ngx_int_t +ngx_trylock_accept_mutex(ngx_cycle_t *cycle) { if (*ngx_accept_mutex == 0 && ngx_atomic_cmp_set(ngx_accept_mutex, 0, ngx_pid)) @@ -368,7 +369,8 @@ ngx_int_t ngx_trylock_accept_mutex(ngx_cycle_t *cycle) } -ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle) +ngx_int_t +ngx_enable_accept_events(ngx_cycle_t *cycle) { ngx_uint_t i; ngx_listening_t *s; @@ -400,7 +402,8 @@ ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle) } -ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle) +ngx_int_t +ngx_disable_accept_events(ngx_cycle_t *cycle) { ngx_uint_t i; ngx_listening_t *s; @@ -442,7 +445,8 @@ ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle) } -static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log) +static void +ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log) { if (ngx_close_socket(s) == -1) { ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno, @@ -451,7 +455,8 @@ static void ngx_close_accepted_socket(ngx_socket_t s, ngx_log_t *log) } -static u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len) +static u_char * +ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len) { return ngx_snprintf(buf, len, " while accept() on %V", log->data); } diff --git a/src/event/ngx_event_timer.c b/src/event/ngx_event_timer.c index c1ca12414..4b9865650 100644 --- a/src/event/ngx_event_timer.c +++ b/src/event/ngx_event_timer.c @@ -18,7 +18,8 @@ ngx_thread_volatile ngx_rbtree_t *ngx_event_timer_rbtree; ngx_rbtree_t ngx_event_timer_sentinel; -ngx_int_t ngx_event_timer_init(ngx_log_t *log) +ngx_int_t +ngx_event_timer_init(ngx_log_t *log) { if (ngx_event_timer_rbtree) { #if (NGX_THREADS) @@ -39,7 +40,8 @@ ngx_int_t ngx_event_timer_init(ngx_log_t *log) } -ngx_msec_t ngx_event_find_timer(void) +ngx_msec_t +ngx_event_find_timer(void) { ngx_msec_t timer; ngx_rbtree_t *node; @@ -68,7 +70,8 @@ ngx_msec_t ngx_event_find_timer(void) } -void ngx_event_expire_timers(ngx_msec_t timer) +void +ngx_event_expire_timers(ngx_msec_t timer) { ngx_event_t *ev; ngx_rbtree_t *node; diff --git a/src/event/ngx_event_timer.h b/src/event/ngx_event_timer.h index 090d4046a..edbfcf604 100644 --- a/src/event/ngx_event_timer.h +++ b/src/event/ngx_event_timer.h @@ -16,8 +16,9 @@ #define NGX_TIMER_INFINITE -1 #define NGX_TIMER_ERROR -2 + /* - * 32 bit timer key value resolution + * the 32-bit timer key value resolution * * 1 msec - 24 days * 10 msec - 8 months @@ -27,6 +28,8 @@ #define NGX_TIMER_RESOLUTION 1 +#define NGX_TIMER_LAZY_DELAY 300 + ngx_int_t ngx_event_timer_init(ngx_log_t *log); ngx_msec_t ngx_event_find_timer(void); @@ -42,7 +45,8 @@ extern ngx_thread_volatile ngx_rbtree_t *ngx_event_timer_rbtree; extern ngx_rbtree_t ngx_event_timer_sentinel; -static ngx_inline void ngx_event_del_timer(ngx_event_t *ev) +static ngx_inline void +ngx_event_del_timer(ngx_event_t *ev) { ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0, "event timer del: %d: %d", @@ -68,7 +72,8 @@ static ngx_inline void ngx_event_del_timer(ngx_event_t *ev) } -static ngx_inline void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer) +static ngx_inline void +ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer) { ngx_int_t key; @@ -83,11 +88,13 @@ static ngx_inline void ngx_event_add_timer(ngx_event_t *ev, ngx_msec_t timer) /* * Use the previous timer value if a difference between them is less - * then 100 milliseconds. It allows to minimize the rbtree operations - * for the fast connections. + * then NGX_TIMER_LAZY_DELAY milliseconds. It allows to minimize + * the rbtree operations for the fast connections. */ - if (abs(key - ev->rbtree_key) < 100 / NGX_TIMER_RESOLUTION) { + if (abs(key - ev->rbtree_key) + < NGX_TIMER_LAZY_DELAY / NGX_TIMER_RESOLUTION) + { ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0, "event timer: %d, old: %i, new: %i", ngx_event_ident(ev->data), ev->rbtree_key, key); |
