diff options
-rw-r--r-- | TCPProber.hs | 8 | ||||
-rw-r--r-- | src/Network/QueryResponse/TCP.hs | 9 |
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 #-} |
2 | module TCPProber where | 3 | module TCPProber where |
3 | 4 | ||
5 | #ifdef THREAD_DEBUG | ||
6 | import Control.Concurrent.Lifted.Instrument | ||
7 | #else | ||
4 | import Control.Concurrent | 8 | import Control.Concurrent |
5 | import GHC.Conc | 9 | import GHC.Conc |
10 | #endif | ||
6 | 11 | ||
7 | import Control.Arrow | 12 | import Control.Arrow |
8 | import Control.Concurrent.STM | 13 | import Control.Concurrent.STM |
@@ -14,6 +19,8 @@ import Data.Time.Clock.POSIX | |||
14 | import Network.Socket | 19 | import Network.Socket |
15 | import System.Timeout | 20 | import System.Timeout |
16 | 21 | ||
22 | import DPut | ||
23 | import DebugTag | ||
17 | import Crypto.Tox | 24 | import Crypto.Tox |
18 | import Data.Wrapper.PSQ as PSQ | 25 | import Data.Wrapper.PSQ as PSQ |
19 | import Network.Kademlia.Search | 26 | import Network.Kademlia.Search |
@@ -141,6 +148,7 @@ runProbeQueue prober client maxjobs = do | |||
141 | getNodes :: TCPProber -> TCP.TCPClient err () Nonce8 -> NodeId -> TCP.NodeInfo -> IO (Maybe ([TCP.NodeInfo],[TCP.NodeInfo],Maybe ())) | 148 | getNodes :: TCPProber -> TCP.TCPClient err () Nonce8 -> NodeId -> TCP.NodeInfo -> IO (Maybe ([TCP.NodeInfo],[TCP.NodeInfo],Maybe ())) |
142 | getNodes prober tcp seeking dst = do | 149 | getNodes 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 | } |