Commit 1025c8ff authored by AndreasVoellmy's avatar AndreasVoellmy Committed by tibbe

Change GHC.Event.Manager.closeFd to unregister interest in the file with the backend.

The file must not be closed when unregistering interest in the file with the backend, because otherwise the backend will likely encounter an error (invalid fd). Therefore, the close fd command is executed after the backend is updated.
parent cca34b9c
......@@ -348,11 +348,15 @@ unregisterFd mgr reg = do
closeFd :: EventManager -> (Fd -> IO ()) -> Fd -> IO ()
closeFd mgr close fd = do
fds <- modifyMVar (callbackTableVar mgr fd) $ \oldMap -> do
close fd
case IM.delete (fromIntegral fd) oldMap of
(Nothing, _) -> return (oldMap, [])
(Nothing, _) -> do close fd
return (oldMap, [])
(Just fds, !newMap) -> do
when (eventsOf fds /= mempty) $ wakeManager mgr
let oldEvs = eventsOf fds
when (oldEvs /= mempty) $ do
I.modifyFd (emBackend mgr) fd oldEvs mempty
wakeManager mgr
close fd
return (newMap, fds)
forM_ fds $ \(FdData reg ev cb) -> cb reg (ev `mappend` evtClose)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment