Add monitoring support via kqueue(2). Based on patch from FreeBSD ports, authored by wg@FreeBSD.org and se@FreeBSD.org. However, this version doesn't create any thread, it uses main event dispatcher.

Some effort was made to unify monitoring via kqueue and via inotify
APIs. Now both provide their implementation of add_watch() function.

I guess there are some logical bugs in vnode_process(). With this commit
it would be better provide code as is, and resolve bugs separately.
This commit is contained in:
Gleb Smirnoff
2017-12-29 02:05:46 -08:00
committed by Justin Maggard
parent 184607cb56
commit 5e320f2798
7 changed files with 300 additions and 42 deletions

11
event.h
View File

@@ -11,6 +11,7 @@ typedef enum {
#ifdef HAVE_KQUEUE
EVENT_READ = EVFILT_READ,
EVENT_WRITE = EVFILT_WRITE,
EVENT_VNODE = EVFILT_VNODE,
#else
EVENT_READ,
EVENT_WRITE,
@@ -20,12 +21,20 @@ typedef enum {
#define EV_FLAG_CLOSING 0x00000001
typedef void event_process_t(struct event *);
#ifdef HAVE_KQUEUE
typedef void event_vnode_process_t(struct event *, u_int);
#endif
struct event {
int fd;
int index;
event_t rdwr;
event_process_t *process;
union {
event_process_t *process;
#ifdef HAVE_KQUEUE
event_vnode_process_t *process_vnode;
#endif
};
void *data;
};