Mercurial > hg > nginx-vendor-0-8
diff src/event/modules/ngx_devpoll_module.c @ 112:408f195b3482 NGINX_0_3_3
nginx 0.3.3
*) Change: the "bl" and "af" parameters of the "listen" directive was
renamed to the "backlog" and "accept_filter".
*) Feature: the "rcvbuf" and "sndbuf" parameters of the "listen"
directive.
*) Change: the "$msec" log parameter does not require now the
additional the gettimeofday() system call.
*) Feature: the -t switch now tests the "listen" directives.
*) Bugfix: if the invalid address was specified in the "listen"
directive, then after the -HUP signal nginx left an open socket in
the CLOSED state.
*) Bugfix: the mime type may be incorrectly set to default value for
index file with variable in the name; bug appeared in 0.3.0.
*) Feature: the "timer_resolution" directive.
*) Feature: the millisecond "$upstream_response_time" log parameter.
*) Bugfix: a temporary file with client request body now is removed
just after the response header was transferred to a client.
*) Bugfix: OpenSSL 0.9.6 compatibility.
*) Bugfix: the SSL certificate and key file paths could not be relative.
*) Bugfix: the "ssl_prefer_server_ciphers" directive did not work in
the ngx_imap_ssl_module.
*) Bugfix: the "ssl_protocols" directive allowed to specify the single
protocol only.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Wed, 19 Oct 2005 00:00:00 +0400 |
parents | 45f7329b4bd0 |
children | e38f51cd0905 |
line wrap: on
line diff
--- a/src/event/modules/ngx_devpoll_module.c +++ b/src/event/modules/ngx_devpoll_module.c @@ -31,12 +31,13 @@ typedef struct { } ngx_devpoll_conf_t; -static ngx_int_t ngx_devpoll_init(ngx_cycle_t *cycle); +static ngx_int_t ngx_devpoll_init(ngx_cycle_t *cycle, ngx_msec_t timer); static void ngx_devpoll_done(ngx_cycle_t *cycle); static ngx_int_t ngx_devpoll_add_event(ngx_event_t *ev, int event, u_int flags); static ngx_int_t ngx_devpoll_del_event(ngx_event_t *ev, int event, u_int flags); static ngx_int_t ngx_devpoll_set_event(ngx_event_t *ev, int event, u_int flags); -static ngx_int_t ngx_devpoll_process_events(ngx_cycle_t *cycle); +static ngx_int_t ngx_devpoll_process_events(ngx_cycle_t *cycle, + ngx_msec_t timer, ngx_uint_t flags); static void *ngx_devpoll_create_conf(ngx_cycle_t *cycle); static char *ngx_devpoll_init_conf(ngx_cycle_t *cycle, void *conf); @@ -107,7 +108,7 @@ ngx_module_t ngx_devpoll_module = { static ngx_int_t -ngx_devpoll_init(ngx_cycle_t *cycle) +ngx_devpoll_init(ngx_cycle_t *cycle, ngx_msec_t timer) { size_t n; ngx_devpoll_conf_t *dpcf; @@ -323,48 +324,21 @@ ngx_devpoll_set_event(ngx_event_t *ev, i ngx_int_t -ngx_devpoll_process_events(ngx_cycle_t *cycle) +ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, + ngx_uint_t flags) { int events, revents; size_t n; ngx_err_t err; ngx_int_t i; - ngx_uint_t lock, accept_lock; - ngx_msec_t timer, delta; -#if 0 - ngx_cycle_t **old_cycle; -#endif - ngx_event_t *rev, *wev; + ngx_uint_t level; + ngx_msec_t delta; + ngx_event_t *rev, *wev, **queue; ngx_connection_t *c; struct dvpoll dvp; - struct timeval tv; - - timer = ngx_event_find_timer(); /* NGX_TIMER_INFINITE == INFTIM */ - accept_lock = 0; - - if (ngx_accept_mutex) { - if (ngx_accept_disabled > 0) { - ngx_accept_disabled--; - - } else { - if (ngx_trylock_accept_mutex(cycle) == NGX_ERROR) { - return NGX_ERROR; - } - - if (ngx_accept_mutex_held) { - accept_lock = 1; - - } else if (timer == NGX_TIMER_INFINITE - || timer > ngx_accept_mutex_delay) - { - timer = ngx_accept_mutex_delay; - } - } - } - ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "devpoll timer: %M", timer); @@ -373,7 +347,6 @@ ngx_devpoll_process_events(ngx_cycle_t * if (write(dp, change_list, n) != (ssize_t) n) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, "write(/dev/poll) failed"); - ngx_accept_mutex_unlock(); return NGX_ERROR; } } @@ -391,21 +364,32 @@ ngx_devpoll_process_events(ngx_cycle_t * nchanges = 0; - ngx_gettimeofday(&tv); - ngx_time_update(tv.tv_sec); - - delta = ngx_current_time; - ngx_current_time = (ngx_msec_t) tv.tv_sec * 1000 + tv.tv_usec / 1000; + delta = ngx_current_msec; + + if (flags & NGX_UPDATE_TIME) { + ngx_time_update(0, 0); + } if (err) { - ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT, - cycle->log, err, "ioctl(DP_POLL) failed"); - ngx_accept_mutex_unlock(); + if (err == NGX_EINTR) { + + if (ngx_event_timer_alarm) { + ngx_event_timer_alarm = 0; + return NGX_OK; + } + + level = NGX_LOG_INFO; + + } else { + level = NGX_LOG_ALERT; + } + + ngx_log_error(level, cycle->log, err, "ioctl(DP_POLL) failed"); return NGX_ERROR; } if (timer != NGX_TIMER_INFINITE) { - delta = ngx_current_time - delta; + delta = ngx_current_msec - delta; ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0, "devpoll timer: %M, delta: %M", timer, delta); @@ -413,17 +397,15 @@ ngx_devpoll_process_events(ngx_cycle_t * if (events == 0) { ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, "ioctl(DP_POLL) returned no events without timeout"); - ngx_accept_mutex_unlock(); return NGX_ERROR; } } - if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { - ngx_accept_mutex_unlock(); - return NGX_ERROR; + if (events == 0) { + return NGX_OK; } - lock = 1; + ngx_mutex_lock(ngx_posted_events_mutex); for (i = 0; i < events; i++) { c = ngx_cycle->files[event_list[i].fd]; @@ -468,74 +450,49 @@ ngx_devpoll_process_events(ngx_cycle_t * revents |= POLLIN|POLLOUT; } - wev = c->write; - - if ((revents & POLLOUT) && wev->active) { - wev->ready = 1; - - if (!ngx_threaded && !ngx_accept_mutex_held) { - wev->handler(wev); - - } else { - ngx_post_event(wev); - } - } - - /* - * POLLIN must be handled after POLLOUT because we use - * the optimization to avoid the unnecessary mutex locking/unlocking - * if the accept event is the last one. - */ - rev = c->read; if ((revents & POLLIN) && rev->active) { - rev->ready = 1; - if (!ngx_threaded && !ngx_accept_mutex_held) { - rev->handler(rev); + if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) { + rev->posted_ready = 1; - } else if (!rev->accept) { - ngx_post_event(rev); + } else { + rev->ready = 1; + } - } else if (ngx_accept_disabled <= 0) { - ngx_mutex_unlock(ngx_posted_events_mutex); + if (flags & NGX_POST_EVENTS) { + queue = (ngx_event_t **) (rev->accept ? + &ngx_posted_accept_events : &ngx_posted_events); - c->read->handler(rev); + ngx_locked_post_event(rev, queue); - if (ngx_accept_disabled > 0) { - ngx_accept_mutex_unlock(); - accept_lock = 0; - } + } else { + rev->handler(rev); + } + } + + wev = c->write; + + if ((revents & POLLOUT) && wev->active) { - if (i + 1 == events) { - lock = 0; - break; - } + if (flags & NGX_POST_THREAD_EVENTS) { + wev->posted_ready = 1; - if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_ERROR) { - if (accept_lock) { - ngx_accept_mutex_unlock(); - } - return NGX_ERROR; - } + } else { + wev->ready = 1; + } + + if (flags & NGX_POST_EVENTS) { + ngx_locked_post_event(wev, &ngx_posted_events); + + } else { + wev->handler(wev); } } } - if (accept_lock) { - ngx_accept_mutex_unlock(); - } - - if (lock) { - ngx_mutex_unlock(ngx_posted_events_mutex); - } - - ngx_event_expire_timers(); - - if (!ngx_threaded) { - ngx_event_process_posted(cycle); - } + ngx_mutex_unlock(ngx_posted_events_mutex); return NGX_OK; }