lpsmith / linux-inotify

Haskell binding to inotify.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make it safe to use inotify descriptors after they have been closed.

lpsmith opened this issue · comments

It turns out that the way I thought descriptors were allocated on Linux was completely incorrect, see for example jaspervdj/websockets-snap#10. Since descriptors are in fact likely to be soon reused whenever there is even a modest amount of descriptor churn, I do think it would be a good idea to protect against use-after-close faults.

This could be accomplished by adding an MVar Bool to the Inotify structure representing the descriptor, or by storing the descriptor itself inside a MVar (Maybe Fd). As a side benefit, it would also make it possible to make all the other operators thread-safe.