summaryrefslogtreecommitdiff
path: root/dht/src/Network/QueryResponse
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-11-28 21:10:25 -0500
committerJoe Crayne <joe@jerkface.net>2020-01-01 22:50:28 -0500
commit05f443e31b52de18e6e2dd3b7b7bd599f28e4a6f (patch)
treedb434da1f23caab25929c4c137f4af6b00e032fc /dht/src/Network/QueryResponse
parent62be467e38b5919baeed90784ac1b62a3e256649 (diff)
Prefer IPv4 when parsing TCP nodes JSON.
Diffstat (limited to 'dht/src/Network/QueryResponse')
-rw-r--r--dht/src/Network/QueryResponse/TCP.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/dht/src/Network/QueryResponse/TCP.hs b/dht/src/Network/QueryResponse/TCP.hs
index fdca86b4..45ff73a6 100644
--- a/dht/src/Network/QueryResponse/TCP.hs
+++ b/dht/src/Network/QueryResponse/TCP.hs
@@ -27,6 +27,7 @@ import System.IO
27import System.IO.Error 27import System.IO.Error
28 28
29import DebugTag 29import DebugTag
30import DebugUtil
30import DPut 31import DPut
31import Connection.Tcp (socketFamily) 32import Connection.Tcp (socketFamily)
32import qualified Data.MinMaxPSQ as MM 33import qualified Data.MinMaxPSQ as MM
@@ -104,7 +105,13 @@ acquireConnection mvar tcpcache stream addr bDoCon = do
104 return h) 105 return h)
105 $ \e -> return Nothing 106 $ \e -> return Nothing
106 ret <- fmap join $ forM mh $ \h -> do 107 ret <- fmap join $ forM mh $ \h -> do
107 st <- streamHello stream addr h 108 mst <- catchIOError (Just <$> streamHello stream addr h)
109 (\e -> return Nothing)
110 case mst of
111 Nothing -> do
112 atomically $ modifyTVar' (lru tcpcache) $ MM.delete (TCPAddress $ streamAddr stream addr)
113 return Nothing
114 Just st -> do
108 dput XTCP $ "TCP Connected! " ++ show (streamAddr stream addr) 115 dput XTCP $ "TCP Connected! " ++ show (streamAddr stream addr)
109 signal <- newTVarIO False 116 signal <- newTVarIO False
110 let showAddr a = show (streamAddr stream a) 117 let showAddr a = show (streamAddr stream a)
@@ -129,6 +136,10 @@ acquireConnection mvar tcpcache stream addr bDoCon = do
129 now <- getPOSIXTime 136 now <- getPOSIXTime
130 forM_ (zip [1..] $ MM.toList c) $ \(i,MM.Binding (TCPAddress addr) r (Down tm)) -> do 137 forM_ (zip [1..] $ MM.toList c) $ \(i,MM.Binding (TCPAddress addr) r (Down tm)) -> do
131 dput XTCP $ unwords [show i ++ ".", "Still connected:", show addr, show (now - tm), showStat r] 138 dput XTCP $ unwords [show i ++ ".", "Still connected:", show addr, show (now - tm), showStat r]
139 mreport <- timeout 10000000 $ threadReport False -- XXX: Paranoid timeout
140 case mreport of
141 Just treport -> dput XTCP treport
142 Nothing -> dput XTCP "TCP ERROR: threadReport timed out."
132 hClose h 143 hClose h
133 let v = TCPSession 144 let v = TCPSession
134 { tcpHandle = h 145 { tcpHandle = h