Calling the callback when event registration fails

Andrew Martin andrew.thaddeus at gmail.com
Wed Feb 6 22:44:54 UTC 2019


In the event manager's registerFd_, we find:

    registerFd_ :: EventManager -> IOCallback -> Fd -> Event -> Lifetime
                -> IO (FdKey, Bool)
    registerFd_ mgr@(EventManager{..}) cb !fd !evs lt = do
      ... <- ...
      (modify,ok) <- withMVar (callbackTableVar mgr fd) $ \tbl -> do
        ... <- ...
      -- this simulates behavior of old IO manager:
      -- i.e. just call the callback if the registration fails.
      when (not ok) (cb reg evs)
      return (reg,modify)

A comment and a question. Comment: registerFd_ is only ever called in
contexts where exceptions are masked, so withMVar is doing some needless
mask/restore. Question: why do we immidiately call the callback if event
registration fails? This means that if event registration fails during
something like `threadWaitRead`, the end result would be that
`threadWaitRead` would just return immidiately. That doesn't seem good.

-- 
-Andrew Thaddeus Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20190206/20d547c6/attachment.html>


More information about the Libraries mailing list