RFR: 8293067: (fs) Implement WatchService using system library (macOS) [v7]

Michael Hall mik3hall at gmail.com
Mon Oct 3 12:37:20 UTC 2022



> On Oct 3, 2022, at 6:46 AM, Vladimir Kempik <vkempik at openjdk.org> wrote:
> 
> 2) this modifier StandardWatchEventKinds.ENTRY_MODIFY says to monitor changes of individual files in the dir, but kevent on the dir only reports changes to the dir itself

Seems somewhat off-topic to FSEvents implementation but it got me to look at some of my old attempt.

You could just add all the files in the directory.

[self addChildren:[NSURL fileURLWithPath:path] notifyingAbout:fflags withWatchKey:watchKey];

This of course does nothing for the possible file descriptor issues. As near as I can tell on a quick look the only time I freed up a descriptor was if the file was deleted.

My implementation however, usually did no polling. I only added some polling when I ran into what seemed like deadlock issues to make sure the thread wasn’t itself deadlocked somehow. As an ‘alive’ test.

I did a lot of googling on this but never hit on mention of descriptors. I don’t think I’ll go over the code too much more though.

The current FSEvents implementation looks fine to me. Based on a officially Apple supported API and extension I think to kqueue? If I remember right they had a couple different file monitoring extensions that differed in granularity. One less granular I think could watch for any file changes on the machine. 

Callbacks are fairly common in Apple OS/X code aren’t they? 
 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/nio-dev/attachments/20221003/8bd5d2c7/attachment.htm>


More information about the nio-dev mailing list