2004-04-05 04:32:09 +08:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2004-04-13 23:08:48 +08:00
|
|
|
if (ev->accept) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-04-05 04:32:09 +08:00
|
|
|
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,
|
2004-06-10 04:03:54 +08:00
|
|
|
"stale posted event " PTR_FMT, ev);
|
2004-04-05 04:32:09 +08:00
|
|
|
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
|