@@ -18,7 +18,7 @@ import qualified Data.List as List (delete)
18import Data.Set (Set)
18import Data.Set (Set)
19import qualified Data.Set as Set (empty, insert, delete, member)
19import qualified Data.Set as Set (empty, insert, delete, member)
20import Data.Foldable (forM_)
20import Data.Foldable (forM_)
21−import Data.Maybe (isJust)
21+import Data.Maybe (isJust, fromMaybe)
22import Data.Typeable (Typeable)
22import Data.Typeable (Typeable)
23import Control.Category ((>>>))
23import Control.Category ((>>>))
24import Control.Applicative ((<$>))
24import Control.Applicative ((<$>))
@@ -450,15 +450,12 @@ ncEffectProcessDied pid reason = do
450ncEffectSpawn :: ProcessId -> Closure (Process ()) -> SpawnRef -> NC ()
450ncEffectSpawn :: ProcessId -> Closure (Process ()) -> SpawnRef -> NC ()
451ncEffectSpawn pid cProc ref = do
451ncEffectSpawn pid cProc ref = do
452 mProc <- unClosure cProc
452 mProc <- unClosure cProc
453− case mProc of
453+ -- If the closure does not exist, we spawn a process that throws an exception
454− Just proc -> do
454+ -- This allows the remote node to find out what's happening
455+ let proc = fromMaybe (fail $ "Error: unknown closure " ++ show cProc) mProc
455− node <- ncMsg getLocalNode
456+ node <- ncMsg getLocalNode
456− pid' <- liftIO $ forkProcess node proc
457+ pid' <- liftIO $ forkProcess node proc
457− ncMsg $ sendMessage (ProcessIdentifier pid) (DidSpawn ref pid')
458+ ncMsg $ sendMessage (ProcessIdentifier pid) (DidSpawn ref pid')
459− -- TODO: what should we do when unClosure returns Nothing?
460− liftIO . putStrLn $ "Error: closure " ++ show cProc ++ " not found"
463--------------------------------------------------------------------------------
460--------------------------------------------------------------------------------
464-- Auxiliary --
461-- Auxiliary --
@@ -494,12 +491,11 @@ destNid (Monitor pid _) =
494 Just . processNodeId $ pid
491 Just . processNodeId $ pid
495destNid (Unmonitor ref) =
492destNid (Unmonitor ref) =
496 Just . processNodeId . monitorRefPid $ ref
493 Just . processNodeId . monitorRefPid $ ref
497−destNid (Died (NodeIdentifier _) _) =
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
499−destNid (Died (ProcessIdentifier _pid) _) =
500− fail "destNid: TODO"
501−destNid (Died (ChannelIdentifier _cid) _) =
502− fail "destNid: TODO"
503destNid (Spawn _ _) =
499destNid (Spawn _ _) =