git.iko.soy/distributed-process
on master help sign in
Fix unbounded message box growth in call
commit0c1f38442b3f59d9533ab70b33f1f3d4d3c5b0c6 authorEdsko de Vries <edsko@edsko.net> dateTue 14 Aug 2012, 15:21 (14 years ago) parent7a31815
1 file changed+9−2
distributed-process/src/Control/Distributed/Process.hs+9−2
distributed-process/src/Control/Distributed/Process.hs+9−2
@@ -345,8 +345,15 @@ call dict nid proc = do
345345 (\(ProcessMonitorNotification _ _ reason) -> return (Left reason))
346346 ]
347347 case mResult of
348− Right a -> unmonitor mRef >> return a
349− Left err -> fail $ "call: remote process died: " ++ show err
348+ Right a -> do
349+ -- Wait for the monitor message so that we the mailbox doesn't grow
350+ receiveWait
351+ [ matchIf (\(ProcessMonitorNotification ref _ _) -> ref == mRef)
352+ (\(ProcessMonitorNotification {}) -> return ())
353+ ]
354+ return a
355+ Left err ->
356+ fail $ "call: remote process died: " ++ show err
350357
351358-- | Spawn a child process, have the child link to the parent and the parent
352359-- monitor the child