Add EV_RECEIPT to kevents.

EV_RECEIPT is useful to disambiguating error conditions when multiple
events structures are passed to kevent(2).  The error code is returned
in the data field and EV_ERROR is set.

Approved by:	rwatson (co-mentor)
This commit is contained in:
Stacey Son 2009-09-16 03:49:54 +00:00
parent 1a921c410a
commit fdc1a1131e
3 changed files with 11 additions and 2 deletions

View File

@ -211,6 +211,15 @@ Removes the event from the kqueue.
Events which are attached to
file descriptors are automatically deleted on the last close of
the descriptor.
.It EV_RECEIPT
This flag is useful for making bulk changes to a kqueue without draining
any pending events.
When passed as input, it forces
.Dv EV_ERROR
to always be returned.
When a filter is successfully added the
.Va data
field will be zero.
.It EV_ONESHOT
Causes the event to return only the first occurrence of the filter
being triggered.

View File

@ -832,7 +832,7 @@ kern_kevent(struct thread *td, int fd, int nchanges, int nevents,
continue;
kevp->flags &= ~EV_SYSFLAGS;
error = kqueue_register(kq, kevp, td, 1);
if (error) {
if (error || (kevp->flags & EV_RECEIPT)) {
if (nevents != 0) {
kevp->flags = EV_ERROR;
kevp->data = error;

View File

@ -72,7 +72,7 @@ struct kevent {
/* flags */
#define EV_ONESHOT 0x0010 /* only report one occurrence */
#define EV_CLEAR 0x0020 /* clear event state after reporting */
/* 0x0040 reserved for EV_RECEIPT */
#define EV_RECEIPT 0x0040 /* force EV_ERROR on success, data=0 */
#define EV_DISPATCH 0x0080 /* disable event after reporting */
#define EV_SYSFLAGS 0xF000 /* reserved by system */