You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, a WatchDescriptor can exist pretty much independently of the actual inotify watch it represents. This means the user has to manually remove any watches (by calling Inotify::rm_watch) that they no longer need. If the user doesn't do this, this can result in lots of useless events being fired.
I'm not sure if this is something we can solve, or if this is one of those issues that has to be left to a higher-level library. Some thoughts:
Currently WatchDescriptor implements Clone and Copy. This would probably no longer be desirable, if we wanted it to implement Drop.
The Clone implementation could be kept, if WatchDescriptor did reference counting, for example using Rc. This would require a heap allocation per watch. As an application might watch thousands of files and directories, this seems like excessive overhead for a low-level wrapper.
If we allow only one WatchDescriptor instance per watch, then Event could no longer contain a WatchDescriptor. Maybe the current WatchDescriptor could be renamed to Watch, implement Drop, and Event would carry a WatchDescriptor whose sole purpose it was to be compared to a Watch.
What would happen if the user called Inotify::add_watch to modify an already existing watch? This can happen by calling add_watch for an already watched path, or even for a different path that refers to an already watched inode. If we naively created a new Watch in that case, then dropping that Watch would also remove the watch for the first Watch, if that was still around.
Of course all problems could be solved if Inotify did extensive internal bookkeeping on what watch descriptors are being used. That kind of overhead seems out of the question, especially since any higher-level library would probably want to duplicate all that work in a different way on top.
If this issue is going to be closed without a solution, the problem should be properly documented.
The text was updated successfully, but these errors were encountered:
Currently, a
WatchDescriptor
can exist pretty much independently of the actual inotify watch it represents. This means the user has to manually remove any watches (by callingInotify::rm_watch
) that they no longer need. If the user doesn't do this, this can result in lots of useless events being fired.I'm not sure if this is something we can solve, or if this is one of those issues that has to be left to a higher-level library. Some thoughts:
WatchDescriptor
implementsClone
andCopy
. This would probably no longer be desirable, if we wanted it to implementDrop
.Clone
implementation could be kept, ifWatchDescriptor
did reference counting, for example usingRc
. This would require a heap allocation per watch. As an application might watch thousands of files and directories, this seems like excessive overhead for a low-level wrapper.WatchDescriptor
instance per watch, thenEvent
could no longer contain aWatchDescriptor
. Maybe the currentWatchDescriptor
could be renamed toWatch
, implementDrop
, andEvent
would carry aWatchDescriptor
whose sole purpose it was to be compared to aWatch
.Inotify::add_watch
to modify an already existing watch? This can happen by callingadd_watch
for an already watched path, or even for a different path that refers to an already watched inode. If we naively created a newWatch
in that case, then dropping thatWatch
would also remove the watch for the firstWatch
, if that was still around.Of course all problems could be solved if
Inotify
did extensive internal bookkeeping on what watch descriptors are being used. That kind of overhead seems out of the question, especially since any higher-level library would probably want to duplicate all that work in a different way on top.If this issue is going to be closed without a solution, the problem should be properly documented.
The text was updated successfully, but these errors were encountered: