git.iko.soy/distributed-process
on master help sign in
Merge pull request #185 from tweag/DP-105

Workaround for throwTo problem that can potentially block.

commit07dbb9b35710354d1bcbbed624e8a1be5628e546 authorAlexander Vershilov <alexander.vershilov@gmail.com> dateWed 17 Jun 2015, 18:07 (11 years ago) parentf5f67ea8055a5f
1 file changed+3−1
src/Control/Distributed/Process/Node.hs+3−1
src/Control/Distributed/Process/Node.hs+3−1
@@ -1136,7 +1136,9 @@ postMessage pid msg = do
11361136throwException :: Exception e => ProcessId -> e -> NC ()
11371137throwException pid e = do
11381138 node <- ask
1139− liftIO $ withLocalProc node pid $ \p -> throwTo (processThread p) e
1139+ -- throwTo blocks until the exception is received by the target thread.
1140+ -- We fork a helper thread to avoid blocking the node controller.
1141+ liftIO $ withLocalProc node pid $ \p -> void $ forkIO $ throwTo (processThread p) e
11401142
11411143withLocalProc :: LocalNode -> ProcessId -> (LocalProcess -> IO ()) -> IO ()
11421144withLocalProc node pid p =