Mercurial > hg > nginx-quic
diff src/event/ngx_event_posted.c @ 306:6b91bfbc4123
nginx-0.0.3-2004-04-05-00:32:09 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 04 Apr 2004 20:32:09 +0000 |
parents | |
children | 98f1a8028067 |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/src/event/ngx_event_posted.c @@ -0,0 +1,76 @@ + +#include <ngx_config.h> +#include <ngx_core.h> +#include <ngx_event.h> + + +ngx_thread_volatile ngx_event_t *ngx_posted_events; +#if (NGX_THREADS) +ngx_mutex_t *ngx_posted_events_mutex; +#endif + + +void ngx_event_process_posted(ngx_cycle_t *cycle) +{ + ngx_event_t *ev; + + for ( ;; ) { + + ev = (ngx_event_t *) ngx_posted_events; + + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, + "posted event " PTR_FMT, ev); + + if (ev == NULL) { + return; + } + + ngx_posted_events = ev->next; + + if ((!ev->posted && !ev->active) + || (ev->use_instance && ev->instance != ev->returned_instance)) + { + /* + * the stale event from a file descriptor + * that was just closed in this iteration + */ + + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, + "stale posted event " PTR_FMT, ev); + continue; + } + + if (ev->posted) { + ev->posted = 0; + } + + ev->event_handler(ev); + } +} + + +#if (NGX_THREADS) + +void ngx_event_thread_handler(ngx_event_t *ev) +{ + if ((!ev->posted && !ev->active) + || (ev->use_instance && ev->instance != ev->returned_instance)) + { + /* + * the stale event from a file descriptor + * that was just closed in this iteration + */ + + ngx_log_debug1(NGX_LOG_DEBUG_EVENT, ev->log, 0, + "kevent: stale event " PTR_FMT, ev); + return; + } + + if (ev->posted) { + ev->posted = 0; + } + + ev->event_handler(ev); +} + +#endif