mirror of
https://github.com/darlinghq/darling-libkqueue.git
synced 2024-11-26 21:20:38 +00:00
* Ensure that calling close() on a file descriptor will remove any
kevents that reference the descriptor. [merged from ^/branches/stable@551] git-svn-id: svn://svn.code.sf.net/p/libkqueue/code/trunk@590 fb4e3144-bc1c-4b72-a658-5bcd248dd7f7
This commit is contained in:
parent
c769f3fa04
commit
e41cc259a0
@ -1,6 +1,9 @@
|
||||
HEAD
|
||||
------------------------------------------------------------------------
|
||||
|
||||
* Ensure that calling close() on a file descriptor will remove any
|
||||
kevents that reference the descriptor. [merged from ^/branches/stable@551]
|
||||
|
||||
* Remove the SERIALIZE_KEVENT macro, and always protect kevent_copyin()
|
||||
and kevent_copyout() with a mutex.
|
||||
|
||||
|
@ -100,7 +100,7 @@ add_watch(struct filter *filt, struct knote *kn)
|
||||
return (-1);
|
||||
|
||||
/* Convert the fflags to the inotify mask */
|
||||
mask = 0;
|
||||
mask = IN_CLOSE;
|
||||
if (kn->kev.fflags & NOTE_DELETE)
|
||||
mask |= IN_ATTRIB | IN_DELETE_SELF;
|
||||
if (kn->kev.fflags & NOTE_WRITE)
|
||||
@ -179,6 +179,17 @@ evfilt_vnode_copyout(struct kevent *dst, struct knote *src, void *ptr UNUSED)
|
||||
dbg_printf("inotify event: %s", inotify_event_dump(&evt));
|
||||
if (evt.mask & IN_IGNORED) {
|
||||
/* TODO: possibly return error when fs is unmounted */
|
||||
dst->filter = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Check if the watched file has been closed, and
|
||||
XXX-this may not exactly match the kevent() behavior if multiple file de
|
||||
scriptors reference the same file.
|
||||
*/
|
||||
if (evt.mask & IN_CLOSE_WRITE || evt.mask & IN_CLOSE_NOWRITE) {
|
||||
src->kn_flags |= EV_ONESHOT; /* KLUDGE: causes the knote to be deleted */
|
||||
dst->filter = 0; /* KLUDGE: causes the event to be discarded */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -258,5 +258,7 @@ test_evfilt_vnode(struct test_context *ctx)
|
||||
test(kevent_vnode_note_attrib, ctx);
|
||||
test(kevent_vnode_note_rename, ctx);
|
||||
test(kevent_vnode_note_delete, ctx);
|
||||
/* TODO: test r590 corner case where a descriptor is closed and
|
||||
the associated knote is automatically freed. */
|
||||
unlink(ctx->testfile);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user