Commit graph

21 commits

Author SHA1 Message Date
Joey Hess
da4c506d61 use safe FFI imports
This avoids blocking all threads when calling waitchange_kqueue,
which blocks.
2012-07-20 15:03:24 -04:00
Joey Hess
fb85d8e563 cleanup 2012-07-17 18:36:51 -04:00
Joey Hess
62a35162a0 bugfix 2012-07-17 18:35:56 -04:00
Joey Hess
32ac773934 kqueue: properly call delHook for file deletion, not delDirHook 2012-07-17 18:32:55 -04:00
Joey Hess
30ac6d7be0 robustness fix
Don't fall over symlinks, and avoid crashing if the file goes away.
2012-07-17 16:29:49 -04:00
Joey Hess
7d89cf0eb9 cleanup 2012-07-17 16:02:29 -04:00
Joey Hess
e816776a62 add inodes to kqueue's directory cache
This is necessary to generate events when a file is deleted and immediately
replaced. Otherwise, the cache will have the old file, and so no event
would be generated.

Use of getFileStatus is suboptimal, it would be faster to use
the inode returned by readdir -- but getDirectoryContents does not expose
it, so I'd have to copy and modify a lot of low-level code.
2012-07-17 15:57:49 -04:00
Joey Hess
e68b3c99f4 kqueue synthetic add events on startup 2012-06-19 10:08:06 -04:00
Joey Hess
2a61df23e7 kqueue recursive directory adding 2012-06-19 09:56:03 -04:00
Joey Hess
03b9341356 fix scheduling
Handle kevent interruptions in the haskell code, so it can yield to other threads
2012-06-19 04:52:55 +00:00
Joey Hess
02e9fdb0a5 kqueue build fix
new event dispatch seems a bit broken though
2012-06-19 04:07:48 +00:00
Joey Hess
7a09d74319 lifted out the kqueue and inotify to a generic DirWatcher interface
Kqueue code for dispatching events is not tested and probably doesn't
build.
2012-06-18 23:49:07 -04:00
Joey Hess
e164553272 robustness fixes 2012-06-19 02:13:26 +00:00
Joey Hess
5e9fdac92f update kqueue when new directories are added 2012-06-18 21:46:04 -04:00
Joey Hess
2bfcc0b09c kqueue: add directory content tracking, and change determination
This *may* now return Add or Delete Changes as appropriate. All I know
for sure is that it compiles.

I had hoped to avoid maintaining my own state about the content of the
directory tree, and rely on git to check what was changed. But I can't;
I need to know about new and deleted subdirectories to add them to the
watch list, and git doesn't deal with (empty) directories.

So, wrote all the code to scan directories, remember their past contents,
compare with current contents, generate appropriate Change events, and
update bookkeeping info appropriately.
2012-06-18 21:29:30 -04:00
Joey Hess
ae7d07ddcb close fds 2012-06-18 19:14:58 -04:00
Joey Hess
d680ff7ef0 kqueue code compiles on debian kfreebsd 2012-06-18 16:34:08 -04:00
Joey Hess
90d565149a flesh out kqueue library
Have not tried to build this yet. But barring minor mistakes, I think it's
good.
2012-06-18 16:18:59 -04:00
Joey Hess
89fcee03d0 add some utility functions for later
Will need to update the DirMap to add or remove subdirs.
2012-06-18 13:22:36 -04:00
Joey Hess
a39b73d118 recurse dirTree and open the directories for kqueue to watch 2012-06-18 13:01:58 -04:00
Joey Hess
3c8a9043b6 skeleton C library for calling kqueue 2012-06-18 12:25:20 -04:00