summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TCPProber.hs8
-rw-r--r--src/Network/QueryResponse/TCP.hs9
2 files changed, 14 insertions, 3 deletions
diff --git a/TCPProber.hs b/TCPProber.hs
index 8d468e53..8059fea7 100644
--- a/TCPProber.hs
+++ b/TCPProber.hs
@@ -1,8 +1,13 @@
1{-# LANGUAGE CPP #-}
1{-# LANGUAGE LambdaCase #-} 2{-# LANGUAGE LambdaCase #-}
2module TCPProber where 3module TCPProber where
3 4
5#ifdef THREAD_DEBUG
6import Control.Concurrent.Lifted.Instrument
7#else
4import Control.Concurrent 8import Control.Concurrent
5import GHC.Conc 9import GHC.Conc
10#endif
6 11
7import Control.Arrow 12import Control.Arrow
8import Control.Concurrent.STM 13import Control.Concurrent.STM
@@ -14,6 +19,8 @@ import Data.Time.Clock.POSIX
14import Network.Socket 19import Network.Socket
15import System.Timeout 20import System.Timeout
16 21
22import DPut
23import DebugTag
17import Crypto.Tox 24import Crypto.Tox
18import Data.Wrapper.PSQ as PSQ 25import Data.Wrapper.PSQ as PSQ
19import Network.Kademlia.Search 26import Network.Kademlia.Search
@@ -141,6 +148,7 @@ runProbeQueue prober client maxjobs = do
141getNodes :: TCPProber -> TCP.TCPClient err () Nonce8 -> NodeId -> TCP.NodeInfo -> IO (Maybe ([TCP.NodeInfo],[TCP.NodeInfo],Maybe ())) 148getNodes :: TCPProber -> TCP.TCPClient err () Nonce8 -> NodeId -> TCP.NodeInfo -> IO (Maybe ([TCP.NodeInfo],[TCP.NodeInfo],Maybe ()))
142getNodes prober tcp seeking dst = do 149getNodes prober tcp seeking dst = do
143 r <- TCP.getUDPNodes' tcp seeking (TCP.udpNodeInfo dst) 150 r <- TCP.getUDPNodes' tcp seeking (TCP.udpNodeInfo dst)
151 dput XTCP $ "Got via TCP nodes: " ++ show r
144 let tcps (ns,_,mb) = (ns',ns',mb) 152 let tcps (ns,_,mb) = (ns',ns',mb)
145 where ns' = do 153 where ns' = do
146 n <- ns 154 n <- ns
diff --git a/src/Network/QueryResponse/TCP.hs b/src/Network/QueryResponse/TCP.hs
index 154e9145..328a19e1 100644
--- a/src/Network/QueryResponse/TCP.hs
+++ b/src/Network/QueryResponse/TCP.hs
@@ -98,7 +98,7 @@ acquireConnection mvar tcpcache stream addr = do
98 killThread (tcpThread r) 98 killThread (tcpThread r)
99 streamGoodbye st 99 streamGoodbye st
100 hClose (tcpHandle r) 100 hClose (tcpHandle r)
101 atomically $ writeTVar (lru tcpcache) cache' 101 atomically $ modifyTVar' (lru tcpcache) $ MM.delete (TCPAddress k)
102 102
103 return $ Just $ streamEncode st 103 return $ Just $ streamEncode st
104 Just (tm,v) -> do 104 Just (tm,v) -> do
@@ -126,7 +126,10 @@ tcpTransport maxcon stream = do
126 return Transport 126 return Transport
127 { awaitMessage = (takeMVar msgvar >>=) 127 { awaitMessage = (takeMVar msgvar >>=)
128 , sendMessage = \addr y -> do 128 , sendMessage = \addr y -> do
129 msock <- acquireConnection msgvar tcpcache stream addr 129 t <- forkIO $ do
130 mapM_ ($ y) msock 130 msock <- acquireConnection msgvar tcpcache stream addr
131 mapM_ ($ y) msock
132 `catchIOError` \e -> return ()
133 labelThread t "tcp-send"
131 , closeTransport = closeAll tcpcache stream 134 , closeTransport = closeAll tcpcache stream
132 } 135 }