summaryrefslogtreecommitdiff
path: root/dht/Presence
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2019-10-18 09:43:20 +0000
committerJoe Crayne <joe@jerkface.net>2020-01-01 19:52:45 -0500
commit5bde2cfe951577be3018b437619cd0e87ab20096 (patch)
tree3077430f036d44d856caa3ca65e9f7644102fee5 /dht/Presence
parent88cb351cb6ddfb5e80f247bea6cc503ed1e12baf (diff)
Control.Concurrent.ThreadUtil replaces #ifdef imports
* new function, forkLabeled * new module Control.Concurrent.ThreadUtil * label a few unlabeled threads
Diffstat (limited to 'dht/Presence')
-rw-r--r--dht/Presence/Presence.hs3
-rw-r--r--dht/Presence/XMPPServer.hs11
2 files changed, 5 insertions, 9 deletions
diff --git a/dht/Presence/Presence.hs b/dht/Presence/Presence.hs
index 8cdd1cdc..a09a517d 100644
--- a/dht/Presence/Presence.hs
+++ b/dht/Presence/Presence.hs
@@ -290,7 +290,8 @@ chooseResourceName state k (Remote addr) clientsNameForMe desired = do
290 buds <- configText ConfigFiles.getBuddies (clientUser client) (clientProfile client) 290 buds <- configText ConfigFiles.getBuddies (clientUser client) (clientProfile client)
291 forM_ buds $ \bud -> do 291 forM_ buds $ \bud -> do
292 let (_,h,_) = splitJID bud 292 let (_,h,_) = splitJID bud
293 forkIO $ void $ resolvePeer (manager state $ clientProfile client) h 293 forkLabeled "XMPP.buddies.resolvePeer" $ do
294 void $ resolvePeer (manager state $ clientProfile client) h
294 295
295 atomically $ do 296 atomically $ do
296 modifyTVar' (clients state) $ Map.insert k client 297 modifyTVar' (clients state) $ Map.insert k client
diff --git a/dht/Presence/XMPPServer.hs b/dht/Presence/XMPPServer.hs
index e98b9a2e..de2dd5d3 100644
--- a/dht/Presence/XMPPServer.hs
+++ b/dht/Presence/XMPPServer.hs
@@ -65,12 +65,7 @@ import Control.Monad.Trans (lift)
65import Control.Monad.IO.Class (MonadIO, liftIO) 65import Control.Monad.IO.Class (MonadIO, liftIO)
66import Control.Monad.Fix (fix) 66import Control.Monad.Fix (fix)
67import Control.Monad 67import Control.Monad
68#ifdef THREAD_DEBUG 68import Control.Concurrent.ThreadUtil (forkIO,myThreadId,forkLabeled,labelThread,ThreadId,MVar,putMVar,takeMVar,newMVar)
69import Control.Concurrent.Lifted.Instrument (forkIO,myThreadId,labelThread,ThreadId,MVar,putMVar,takeMVar,newMVar)
70#else
71import Control.Concurrent.Lifted (forkIO,myThreadId,ThreadId)
72import GHC.Conc (labelThread)
73#endif
74import Control.Concurrent.STM 69import Control.Concurrent.STM
75import Data.List hiding ((\\)) 70import Data.List hiding ((\\))
76-- import Control.Concurrent.STM.TChan 71-- import Control.Concurrent.STM.TChan
@@ -344,7 +339,7 @@ conduitToChan c = do
344 chan <- atomically newLockedChan 339 chan <- atomically newLockedChan
345 clsrs <- atomically $ newTVar (Just []) 340 clsrs <- atomically $ newTVar (Just [])
346 quitvar <- atomically $ newEmptyTMVar 341 quitvar <- atomically $ newEmptyTMVar
347 forkIO $ do 342 forkLabeled "XMPP.conduitToChan" $ do
348 runConduit $ c .| copyToChannel id chan clsrs .| awaitForever (const $ return ()) 343 runConduit $ c .| copyToChannel id chan clsrs .| awaitForever (const $ return ())
349 atomically $ writeTVar clsrs Nothing 344 atomically $ writeTVar clsrs Nothing
350 return (chan,clsrs,quitvar) 345 return (chan,clsrs,quitvar)
@@ -462,7 +457,7 @@ sendReply donevar stype reply replychan = do
462 , stanzaOrigin = LocalPeer 457 , stanzaOrigin = LocalPeer
463 } 458 }
464 ioWriteChan replychan replyStanza 459 ioWriteChan replychan replyStanza
465 void . liftIO . forkIO $ do 460 void . liftIO . forkLabeled "XMPPServer.sendReply" $ do
466 mapM_ (liftIO . atomically . writeLChan (stanzaChan replyStanza)) reply 461 mapM_ (liftIO . atomically . writeLChan (stanzaChan replyStanza)) reply
467 liftIO . atomically $ writeTVar (stanzaClosers replyStanza) Nothing 462 liftIO . atomically $ writeTVar (stanzaClosers replyStanza) Nothing
468 -- liftIO $ wlog "finished reply stanza" 463 -- liftIO $ wlog "finished reply stanza"