@@ -33,7 +33,14 @@ import qualified Data.Map as Map
3333 , keys
3434 )
3535import Data.Set (Set)
36−import qualified Data.Set as Set (empty, insert, delete, member, foldl')
36+import qualified Data.Set as Set
37+ ( empty
38+ , insert
39+ , delete
40+ , member
41+ , foldl'
42+ , toList
43+ )
3744import Data.Foldable (forM_)
3845import Data.Maybe (isJust, isNothing, catMaybes)
3946import Data.Typeable (Typeable)
@@ -756,43 +763,54 @@ ncEffectGetInfo from pid =
756763 node <- ask
757764 mProc <- liftIO $ withMVar (localState node) $ return . (^. localProcessWithId lpid)
758765 case mProc of
759− Nothing -> do
760− dispatch (isLocal node (ProcessIdentifier from))
761− from node (ProcessInfoNone DiedUnknownId)
766+ Nothing -> dispatch (isLocal node (ProcessIdentifier from))
767+ from node (ProcessInfoNone DiedUnknownId)
762768 Just proc -> do
763− itsLinks <- gets (^. linksFor them)
764− itsMons <- gets (^. monitorsFor them)
765− registered <- gets (^. registeredHere)
766− sendInfo pid
767− (isLocal node (ProcessIdentifier from))
768− proc node itsLinks itsMons (registeredNames registered)
769+ liftIO . putStrLn $ "getting links"
770+ itsLinks <- gets (^. linksFor them)
771+ liftIO . putStrLn $ "getting monitors"
772+ itsMons <- gets (^. monitorsFor them)
773+ liftIO . putStrLn $ "getting registered names"
774+ registered <- gets (^. registeredHere)
775+ sendInfo pid
776+ (isLocal node (ProcessIdentifier from))
777+ proc
778+ node
779+ (Set.toList itsLinks)
780+ (Set.toList itsMons)
781+ (registeredNames registered)
769782
770783 where sendInfo :: ProcessId
771784 -> Bool
772785 -> LocalProcess
773786 -> LocalNode
774− -> Set ProcessId
775− -> Set (ProcessId, MonitorRef)
787+ -> [ProcessId]
788+ -> [(ProcessId, MonitorRef)]
776789 -> [String]
777790 -> NC ()
778− sendInfo d lc lp n l m r = do
791+ sendInfo d lc lp n l m r =
792+ let n' = processNodeId pid
793+ in do
779794 qLen <- qLength lp
780795 dispatch lc d n ProcessInfo {
781− infoNode = localNodeId n
796+ infoNode = n'
782797 , infoRegisteredNames = r
783798 , infoMessageQueueLength = qLen
784799 , infoMonitors = m
785800 , infoLinks = l
786801 }
787802
788− dispatch :: (Serializable a)
803+ dispatch :: (Serializable a, Show a)
789804 => Bool
790805 -> ProcessId
791806 -> LocalNode
792807 -> a
793808 -> NC ()
794− dispatch True dest _ pInfo = postAsMessage dest $ pInfo
795− dispatch False dest node pInfo =
809+ dispatch True dest _ pInfo = do
810+ -- liftIO $ putStrLn $ "posting " ++ (show pInfo) ++ " to " ++ (show dest)
811+ postAsMessage dest $ pInfo
812+ dispatch False dest node pInfo = do
813+ -- liftIO $ putStrLn $ "posting pinfo to node of " ++ (show dest)
796814 liftIO $ sendMessage node
797815 (NodeIdentifier (localNodeId node))
798816 (ProcessIdentifier dest)
@@ -802,10 +820,14 @@ ncEffectGetInfo from pid =
802820 -- TODO: make this available to other functions?
803821 qLength :: LocalProcess -> NC (Maybe Int)
804822 qLength lp = do
823+ liftIO $ putStrLn "getting qLen"
805824 qRef <- liftIO $ deRefWeak (processWeakQ lp)
825+ liftIO $ putStrLn "checking length..."
806826 case qRef of
807827 Nothing -> return $ Nothing
808− Just qr -> liftIO $ Mailbox.length qr >>= return . Just
828+ Just q -> do
829+ len <- liftIO $ Mailbox.length q
830+ return $ Just len
809831
810832 registeredNames = Map.foldlWithKey (\ks k v -> if v == pid
811833 then (k:ks)
@@ -902,7 +924,9 @@ postAsMessage :: Serializable a => ProcessId -> a -> NC ()
902924postAsMessage pid = postMessage pid . createMessage
903925
904926postMessage :: ProcessId -> Message -> NC ()
905−postMessage pid msg = withLocalProc pid $ \p -> enqueue (processQueue p) msg
927+postMessage pid msg = do
928+ liftIO $ putStrLn ("posting message to " ++ show pid)
929+ withLocalProc pid $ \p -> enqueue (processQueue p) msg
906930
907931throwException :: Exception e => ProcessId -> e -> NC ()
908932throwException pid e = withLocalProc pid $ \p ->