From 42c7e85689505fc719088c613f1dc4bc52752643 Mon Sep 17 00:00:00 2001 From: joe Date: Tue, 11 Jul 2017 13:03:13 -0400 Subject: Added DHT name to listener thread label. --- examples/dhtd.hs | 1 + src/Network/BitTorrent/DHT.hs | 1 + src/Network/DatagramServer.hs | 7 +++++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 15db79ea..ab256831 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs @@ -167,6 +167,7 @@ godht :: , Pretty (NodeInfo dht IPv4 u) , Default u , Show u + , Typeable dht ) => String -> (NodeAddr IPv4 -> NodeId dht -> DHT raw dht u IPv4 b) -> IO b godht p f = do a <- btBindAddr p False diff --git a/src/Network/BitTorrent/DHT.hs b/src/Network/BitTorrent/DHT.hs index b130e727..1a67c7c4 100644 --- a/src/Network/BitTorrent/DHT.hs +++ b/src/Network/BitTorrent/DHT.hs @@ -124,6 +124,7 @@ dht :: , WireFormat raw dht , Show u , Default u + , Typeable dht ) => Options -- ^ normally you need to use 'Data.Default.def'; -> NodeAddr ip -- ^ address to bind this node; diff --git a/src/Network/DatagramServer.hs b/src/Network/DatagramServer.hs index 55a26e58..891417d4 100644 --- a/src/Network/DatagramServer.hs +++ b/src/Network/DatagramServer.hs @@ -375,6 +375,7 @@ queryK mgr@Manager{..} dest params kont = do Method meth = method :: Method msg a b signature = querySignature meth tid addr logMsg 'D' "query.sending" signature + -- [Debug#query.sending] &MessageType 0 #312020202020202020202020202020202020202020202020 @77.37.142.179:33445 mres <- liftIO $ do ares <- registerQuery (tid, addr) pendingCalls @@ -591,15 +592,17 @@ listener mgr@Manager{..} hs p = do -- | Should be run before any 'query', otherwise they will never -- succeed. -listen :: ( WireFormat raw msg +listen :: forall raw msg. + ( WireFormat raw msg , Ord (TransactionID msg) , Eq (QueryMethod msg) , Show (QueryMethod msg) , Serialize (TransactionID msg) + , Typeable msg ) => Manager raw msg -> [Handler IO msg raw] -> Protocol raw msg -> IO () listen mgr@Manager{..} hs p = do tid <- fork $ do - myThreadId >>= liftIO . flip labelThread "KRPC.listen" + myThreadId >>= liftIO . flip labelThread ("KRPC.listen." ++ (L.last $ L.words $ show $ typeOf (Proxy :: Proxy msg))) listener mgr hs p `Lifted.finally` liftIO (takeMVar listenerThread) liftIO $ putMVar listenerThread tid -- cgit v1.2.3