git.iko.soy/distributed-process
on master help sign in
Don't throw exceptions asynchronously.
01ec001Facundo Domínguez
src/Control/Distributed/Process/Node.hs+5−4
@@ -1172,16 +1172,17 @@ throwException :: Exception e => ProcessId -> e -> NC ()
1172throwException pid e = do
1172throwException pid e = do
1173 node <- ask
1173 node <- ask
1174 -- throwTo blocks until the exception is received by the target thread.
1174 -- throwTo blocks until the exception is received by the target thread.
1175− -- We fork a helper thread to avoid blocking the node controller.
1175+ -- We cannot easily make it happen asynchronpusly because then 'unlink'
1176+ -- semantics would break.
1176− liftIO $ withLocalProc node pid $ \p -> void $ forkIO $ throwTo (processThread p) e
1177+ liftIO $ withLocalProc node pid $ \p -> throwTo (processThread p) e
1177
1178
1178withLocalProc :: LocalNode -> ProcessId -> (LocalProcess -> IO ()) -> IO ()
1179withLocalProc :: LocalNode -> ProcessId -> (LocalProcess -> IO ()) -> IO ()
1179withLocalProc node pid p =
1180withLocalProc node pid p =
1180 -- By [Unified: table 6, rule missing_process] messages to dead processes
1181 -- By [Unified: table 6, rule missing_process] messages to dead processes
1181 -- can silently be dropped
1182 -- can silently be dropped
1182 let lpid = processLocalId pid in do
1183 let lpid = processLocalId pid in do
1183− withValidLocalState node $ \vst ->
1184+ join $ withValidLocalState node $ \vst ->
1184− forM_ (vst ^. localProcessWithId lpid) p
1185+ return $ forM_ (vst ^. localProcessWithId lpid) p
1185
1186
1186--------------------------------------------------------------------------------
1187--------------------------------------------------------------------------------
1187-- Accessors --
1188-- Accessors --