NGX_USE_VNODE_EVENT and NGX_FLUSH_EVENT

This commit is contained in:
Igor Sysoev 2007-09-01 11:59:36 +00:00
parent 954e7e0739
commit a2883a66df
2 changed files with 40 additions and 10 deletions

View File

@ -200,7 +200,9 @@ ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer)
}
}
ngx_event_flags = 0;
ngx_event_flags = NGX_USE_ONESHOT_EVENT
|NGX_USE_KQUEUE_EVENT
|NGX_USE_VNODE_EVENT;
#if (NGX_HAVE_TIMER_EVENT)
@ -226,8 +228,6 @@ ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer)
#endif
ngx_event_flags |= NGX_USE_ONESHOT_EVENT|NGX_USE_KQUEUE_EVENT;
#if (NGX_HAVE_CLEAR_EVENT)
ngx_event_flags |= NGX_USE_CLEAR_EVENT;
#else
@ -389,10 +389,12 @@ ngx_kqueue_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
if (flags & NGX_DISABLE_EVENT) {
ev->disabled = 1;
} else {
flags |= EV_DELETE;
}
rc = ngx_kqueue_set_event(ev, event,
flags & NGX_DISABLE_EVENT ? EV_DISABLE : EV_DELETE);
rc = ngx_kqueue_set_event(ev, event, flags);
ngx_mutex_unlock(list_mutex);
@ -466,6 +468,22 @@ ngx_kqueue_set_event(ngx_event_t *ev, ngx_int_t filter, ngx_uint_t flags)
ev->index = nchanges;
nchanges++;
if (flags & NGX_FLUSH_EVENT) {
ts.tv_sec = 0;
ts.tv_nsec = 0;
ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, 0, "kevent flush");
if (kevent(ngx_kqueue, change_list, (int) nchanges, NULL, 0, &ts)
== -1)
{
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno, "kevent() failed");
return NGX_ERROR;
}
nchanges = 0;
}
return NGX_OK;
}

View File

@ -291,6 +291,10 @@ extern ngx_event_actions_t ngx_event_actions;
*/
#define NGX_USE_EVENTPORT_EVENT 0x00001000
/*
* The event filter support vnode notifications: kqueue.
*/
#define NGX_USE_VNODE_EVENT 0x00002000
/*
@ -311,6 +315,11 @@ extern ngx_event_actions_t ngx_event_actions;
*/
#define NGX_DISABLE_EVENT 2
/*
* event must be passed to kernel right now, do not wait until batch processing.
*/
#define NGX_FLUSH_EVENT 4
/* these flags have a meaning only for kqueue */
#define NGX_LOWAT_EVENT 0
@ -326,11 +335,11 @@ extern ngx_event_actions_t ngx_event_actions;
#define NGX_VNODE_EVENT EVFILT_VNODE
/*
* NGX_CLOSE_EVENT and NGX_LOWAT_EVENT are the module flags and they would
* not go into a kernel so we need to choose the value that would not interfere
* with any existent and future kqueue flags. kqueue has such values -
* EV_FLAG1, EV_EOF and EV_ERROR. They are reserved and cleared on a kernel
* entrance.
* NGX_CLOSE_EVENT, NGX_LOWAT_EVENT, and NGX_FLUSH_EVENT are the module flags
* and they must not go into a kernel so we need to choose the value
* that must not interfere with any existent and future kqueue flags.
* kqueue has such values - EV_FLAG1, EV_EOF, and EV_ERROR:
* they are reserved and cleared on a kernel entrance.
*/
#undef NGX_CLOSE_EVENT
#define NGX_CLOSE_EVENT EV_EOF
@ -338,6 +347,9 @@ extern ngx_event_actions_t ngx_event_actions;
#undef NGX_LOWAT_EVENT
#define NGX_LOWAT_EVENT EV_FLAG1
#undef NGX_FLUSH_EVENT
#define NGX_FLUSH_EVENT EV_ERROR
#define NGX_LEVEL_EVENT 0
#define NGX_ONESHOT_EVENT EV_ONESHOT
#define NGX_CLEAR_EVENT EV_CLEAR