git.iko.soy/distributed-process
on master help sign in
C.D.P.Internal.Primtives.mask does not work correctly if unmask is

called by a process other than the one that called mask. An example of this behavior is in callLocal below. The expected behavior of test is this: Wed May 8 22:50:01 UTC 2013 pid://127.0.0.1:8080:0:3: hi Wed May 8 22:50:01 UTC 2013 pid://127.0.0.1:8080:0:4: hi Wed May 8 22:50:01 UTC 2013 pid://127.0.0.1:8080:0:5: hi Each say is emitted by a distinct process. However, the observed behavior is given here: Wed May 8 22:38:57 UTC 2013 pid://127.0.0.1:8080:0:3: hi Wed May 8 22:38:57 UTC 2013 pid://127.0.0.1:8080:0:4: hi Wed May 8 22:38:57 UTC 2013 pid://127.0.0.1:8080:0:3: hi Note that the say called within callLocal thinks it is running in the same process as its parent, even though there is a spawnLocal between them. This commit fixes this behavior.

commit878446adc1c6100f2dd5e3ddfe86f6428d690ecd authorJeff Epstein <jepst79@gmail.com> dateWed 8 May 2013, 18:56 (13 years ago) parent7e5163d
1 file changed+5−3
src/Control/Distributed/Process/Internal/Primitives.hs+5−3
src/Control/Distributed/Process/Internal/Primitives.hs+5−3
@@ -716,10 +716,12 @@ mask :: ((forall a. Process a -> Process a) -> Process b) -> Process b
716716mask p = do
717717 lproc <- ask
718718 liftIO $ Ex.mask $ \restore ->
719− runLocalProcess lproc (p (liftRestore lproc restore))
719+ runLocalProcess lproc (p (liftRestore restore))
720720 where
721− liftRestore :: LocalProcess -> (forall a. IO a -> IO a) -> (forall a. Process a -> Process a)
722− liftRestore lproc restoreIO = liftIO . restoreIO . runLocalProcess lproc
721+ liftRestore :: (forall a. IO a -> IO a) -> (forall a. Process a -> Process a)
722+ liftRestore restoreIO = \p2 -> do
723+ llproc <- ask
724+ liftIO $ restoreIO $ runLocalProcess llproc p2
723725
724726-- | Lift 'Control.Exception.onException'
725727onException :: Process a -> Process b -> Process a