@@ -33,7 +33,14 @@ import qualified Data.Map as Map
35import Data.Set (Set)
35import Data.Set (Set)
36−import qualified Data.Set as Set (empty, insert, delete, member, foldl')
36+import qualified Data.Set as Set
37import Data.Foldable (forM_)
44import Data.Foldable (forM_)
38import Data.Maybe (isJust, isNothing, catMaybes)
45import Data.Maybe (isJust, isNothing, catMaybes)
39import Data.Typeable (Typeable)
46import Data.Typeable (Typeable)
@@ -756,43 +763,54 @@ ncEffectGetInfo from pid =
756 node <- ask
763 node <- ask
757 mProc <- liftIO $ withMVar (localState node) $ return . (^. localProcessWithId lpid)
764 mProc <- liftIO $ withMVar (localState node) $ return . (^. localProcessWithId lpid)
758 case mProc of
765 case mProc of
760− dispatch (isLocal node (ProcessIdentifier from))
766+ Nothing -> dispatch (isLocal node (ProcessIdentifier from))
761− from node (ProcessInfoNone DiedUnknownId)
767+ from node (ProcessInfoNone DiedUnknownId)
762 Just proc -> do
768 Just proc -> do
769+ liftIO . putStrLn $ "getting links"
763− itsLinks <- gets (^. linksFor them)
770+ itsLinks <- gets (^. linksFor them)
771+ liftIO . putStrLn $ "getting monitors"
764− itsMons <- gets (^. monitorsFor them)
772+ itsMons <- gets (^. monitorsFor them)
773+ liftIO . putStrLn $ "getting registered names"
765− registered <- gets (^. registeredHere)
774+ registered <- gets (^. registeredHere)
766− sendInfo pid
775+ sendInfo pid
767− (isLocal node (ProcessIdentifier from))
776+ (isLocal node (ProcessIdentifier from))
779+ (Set.toList itsLinks)
780+ (Set.toList itsMons)
768− proc node itsLinks itsMons (registeredNames registered)
781+ (registeredNames registered)
770 where sendInfo :: ProcessId
783 where sendInfo :: ProcessId
772 -> LocalProcess
785 -> LocalProcess
773 -> LocalNode
786 -> LocalNode
774− -> Set ProcessId
787+ -> [ProcessId]
775− -> Set (ProcessId, MonitorRef)
788+ -> [(ProcessId, MonitorRef)]
776 -> [String]
789 -> [String]
778− sendInfo d lc lp n l m r = do
791+ sendInfo d lc lp n l m r =
792+ let n' = processNodeId pid
779 qLen <- qLength lp
794 qLen <- qLength lp
780 dispatch lc d n ProcessInfo {
795 dispatch lc d n ProcessInfo {
781− infoNode = localNodeId n
796+ infoNode = n'
782 , infoRegisteredNames = r
797 , infoRegisteredNames = r
783 , infoMessageQueueLength = qLen
798 , infoMessageQueueLength = qLen
784 , infoMonitors = m
799 , infoMonitors = m
785 , infoLinks = l
800 , infoLinks = l
788− dispatch :: (Serializable a)
803+ dispatch :: (Serializable a, Show a)
790 -> ProcessId
805 -> ProcessId
791 -> LocalNode
806 -> LocalNode
809+ dispatch True dest _ pInfo = do
810+ -- liftIO $ putStrLn $ "posting " ++ (show pInfo) ++ " to " ++ (show dest)
794− dispatch True dest _ pInfo = postAsMessage dest $ pInfo
811+ postAsMessage dest $ pInfo
795− dispatch False dest node pInfo =
812+ dispatch False dest node pInfo = do
813+ -- liftIO $ putStrLn $ "posting pinfo to node of " ++ (show dest)
796 liftIO $ sendMessage node
814 liftIO $ sendMessage node
797 (NodeIdentifier (localNodeId node))
815 (NodeIdentifier (localNodeId node))
798 (ProcessIdentifier dest)
816 (ProcessIdentifier dest)
@@ -802,10 +820,14 @@ ncEffectGetInfo from pid =
802 -- TODO: make this available to other functions?
820 -- TODO: make this available to other functions?
803 qLength :: LocalProcess -> NC (Maybe Int)
821 qLength :: LocalProcess -> NC (Maybe Int)
804 qLength lp = do
822 qLength lp = do
823+ liftIO $ putStrLn "getting qLen"
805 qRef <- liftIO $ deRefWeak (processWeakQ lp)
824 qRef <- liftIO $ deRefWeak (processWeakQ lp)
825+ liftIO $ putStrLn "checking length..."
806 case qRef of
826 case qRef of
807 Nothing -> return $ Nothing
827 Nothing -> return $ Nothing
808− Just qr -> liftIO $ Mailbox.length qr >>= return . Just
829+ len <- liftIO $ Mailbox.length q
810 registeredNames = Map.foldlWithKey (\ks k v -> if v == pid
832 registeredNames = Map.foldlWithKey (\ks k v -> if v == pid
811 then (k:ks)
833 then (k:ks)
@@ -902,7 +924,9 @@ postAsMessage :: Serializable a => ProcessId -> a -> NC ()
902postAsMessage pid = postMessage pid . createMessage
924postAsMessage pid = postMessage pid . createMessage
904postMessage :: ProcessId -> Message -> NC ()
926postMessage :: ProcessId -> Message -> NC ()
927+postMessage pid msg = do
928+ liftIO $ putStrLn ("posting message to " ++ show pid)
905−postMessage pid msg = withLocalProc pid $ \p -> enqueue (processQueue p) msg
929+ withLocalProc pid $ \p -> enqueue (processQueue p) msg
907throwException :: Exception e => ProcessId -> e -> NC ()
931throwException :: Exception e => ProcessId -> e -> NC ()
908throwException pid e = withLocalProc pid $ \p ->
932throwException pid e = withLocalProc pid $ \p ->