@@ -18,7 +18,7 @@ import qualified Data.List as List (delete)
1818import Data.Set (Set)
1919import qualified Data.Set as Set (empty, insert, delete, member)
2020import Data.Foldable (forM_)
21−import Data.Maybe (isJust)
21+import Data.Maybe (isJust, fromMaybe)
2222import Data.Typeable (Typeable)
2323import Control.Category ((>>>))
2424import Control.Applicative ((<$>))
@@ -450,15 +450,12 @@ ncEffectProcessDied pid reason = do
450450ncEffectSpawn :: ProcessId -> Closure (Process ()) -> SpawnRef -> NC ()
451451ncEffectSpawn pid cProc ref = do
452452 mProc <- unClosure cProc
453− case mProc of
454− Just proc -> do
455− node <- ncMsg getLocalNode
456− pid' <- liftIO $ forkProcess node proc
457− ncMsg $ sendMessage (ProcessIdentifier pid) (DidSpawn ref pid')
458− Nothing ->
459− -- TODO: what should we do when unClosure returns Nothing?
460− liftIO . putStrLn $ "Error: closure " ++ show cProc ++ " not found"
461−
453+ -- If the closure does not exist, we spawn a process that throws an exception
454+ -- This allows the remote node to find out what's happening
455+ let proc = fromMaybe (fail $ "Error: unknown closure " ++ show cProc) mProc
456+ node <- ncMsg getLocalNode
457+ pid' <- liftIO $ forkProcess node proc
458+ ncMsg $ sendMessage (ProcessIdentifier pid) (DidSpawn ref pid')
462459
463460--------------------------------------------------------------------------------
464461-- Auxiliary --
@@ -494,12 +491,11 @@ destNid (Monitor pid _) =
494491 Just . processNodeId $ pid
495492destNid (Unmonitor ref) =
496493 Just . processNodeId . monitorRefPid $ ref
497−destNid (Died (NodeIdentifier _) _) =
498− Nothing
499−destNid (Died (ProcessIdentifier _pid) _) =
500− fail "destNid: TODO"
501−destNid (Died (ChannelIdentifier _cid) _) =
502− fail "destNid: TODO"
494+-- We don't need to forward 'Died' signals; if monitoring/linking is setup,
495+-- then when a local process dies the monitoring/linking machinery will take
496+-- care of notifying remote nodes
497+destNid (Died _ _) =
498+ Nothing
503499destNid (Spawn _ _) =
504500 Nothing
505501