summaryrefslogtreecommitdiff
path: root/dht/Presence
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2019-10-18 10:35:34 +0000
committerJoe Crayne <joe@jerkface.net>2020-01-01 19:53:46 -0500
commitad35d7aa97d2fad2615f5d0dd4aee4e984d403f6 (patch)
treef8ad06edb3499ff1f801846db99b4b7419f5e55a /dht/Presence
parentc479c2dd58c12d159c05040a08da6c4c7730c407 (diff)
more forkLabeled, and now forkOSLabeled
Diffstat (limited to 'dht/Presence')
-rw-r--r--dht/Presence/DNSCache.hs16
1 files changed, 5 insertions, 11 deletions
diff --git a/dht/Presence/DNSCache.hs b/dht/Presence/DNSCache.hs
index e28655c5..14581fee 100644
--- a/dht/Presence/DNSCache.hs
+++ b/dht/Presence/DNSCache.hs
@@ -22,12 +22,7 @@ module DNSCache
22 , withPort 22 , withPort
23 ) where 23 ) where
24 24
25#ifdef THREAD_DEBUG 25import Control.Concurrent.ThreadUtil
26import Control.Concurrent.Lifted.Instrument
27#else
28import Control.Concurrent.Lifted
29import GHC.Conc (labelThread)
30#endif
31import Control.Arrow 26import Control.Arrow
32import Control.Concurrent.STM 27import Control.Concurrent.STM
33import Data.Text ( Text ) 28import Data.Text ( Text )
@@ -108,10 +103,10 @@ make6mapped4 :: SockAddr -> SockAddr
108make6mapped4 addr@(SockAddrInet6 {}) = addr 103make6mapped4 addr@(SockAddrInet6 {}) = addr
109make6mapped4 addr@(SockAddrInet port a) = SockAddrInet6 port 0 (0,0,0xFFFF,fromBE32 a) 0 104make6mapped4 addr@(SockAddrInet port a) = SockAddrInet6 port 0 (0,0,0xFFFF,fromBE32 a) 0
110 105
111tryForkOS :: IO () -> IO ThreadId 106tryForkOS :: String -> IO () -> IO ThreadId
112tryForkOS action = catchIOError (forkOS action) $ \e -> do 107tryForkOS lbl action = catchIOError (forkOSLabeled lbl action) $ \e -> do
113 dput XMisc $ "DNSCache: Link with -threaded to avoid excessively long time-out." 108 dput XMisc $ "DNSCache: Link with -threaded to avoid excessively long time-out."
114 forkIO action 109 forkLabeled lbl action
115 110
116 111
117-- Attempt to resolve the given domain name. Returns an empty list if the 112-- Attempt to resolve the given domain name. Returns an empty list if the
@@ -126,8 +121,7 @@ rawForwardResolve ::
126rawForwardResolve dns onFail timeout addrtext = do 121rawForwardResolve dns onFail timeout addrtext = do
127 r <- atomically newEmptyTMVar 122 r <- atomically newEmptyTMVar
128 mvar <- interruptibleDelay 123 mvar <- interruptibleDelay
129 rt <- tryForkOS $ do 124 rt <- tryForkOS ("resolve."++show addrtext) $ do
130 myThreadId >>= flip labelThread ("resolve."++show addrtext)
131 resolver r mvar 125 resolver r mvar
132 startDelay mvar timeout 126 startDelay mvar timeout
133 did <- atomically $ tryPutTMVar r [] 127 did <- atomically $ tryPutTMVar r []