One-shot semantics in GHC event manager

Ben Gamari bgamari.foss at
Sat Oct 11 04:17:12 UTC 2014

In ba2555ef and a6f52b19 one-shot semantics were added to event manager
in `base`. If my understanding of this code is correct, in this mode the
event manager will use only notify the user of the first event on a
registered fd after which point the fd will need to be re-registered to
get another notification. It appears this was done to optimize the
common case of file I/O where only a single event is needed

This change lead to a regression[1] in Bas van Dijk's usb library under
GHC 7.8. usb's use of the event manager requires that all events on an
fd are reported until the fd is registered or else hardware events are

I'm a bit perplexed as to why the change was made in the way that it
was.  Making one-shot a event-manager-wide attribute seems to add a fair
bit of complexity to the subsystem while breaking backwards
compatibility with library code. Going forward library authors now need
to worry about whether the system event manager is one-shot or not. Not
only is this platform dependent but it seems that there is no way for a
user to determine which semantics the system event handler uses.

Is there a reason why one-shot wasn't exported as a per-fd attribute
instead of per-manager? Might it be possible to back out this change and
instead add a variant of `registerFd` which exposes one-shot semantics?


- Ben

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <>

More information about the ghc-devs mailing list