diff options
-rw-r--r-- | Connection/Tox.hs | 10 | ||||
-rw-r--r-- | Connection/Tox/Threads.hs | 7 |
2 files changed, 7 insertions, 10 deletions
diff --git a/Connection/Tox.hs b/Connection/Tox.hs index 1fe07f82..2c485edd 100644 --- a/Connection/Tox.hs +++ b/Connection/Tox.hs | |||
@@ -66,10 +66,10 @@ data StatefulTask st = StatefulTask | |||
66 | , taskState :: TVar st | 66 | , taskState :: TVar st |
67 | } | 67 | } |
68 | 68 | ||
69 | launch :: String -> st -> ((st -> STM ()) -> IO ()) -> IO (StatefulTask st) | 69 | launch :: String -> st -> (TVar st -> IO ()) -> IO (StatefulTask st) |
70 | launch lbl st f = do | 70 | launch lbl st f = do |
71 | stvar <- newTVarIO st | 71 | stvar <- newTVarIO st |
72 | tid <- forkIO (f $ writeTVar stvar) | 72 | tid <- forkIO (f stvar) |
73 | labelThread tid lbl | 73 | labelThread tid lbl |
74 | return $ StatefulTask tid stvar | 74 | return $ StatefulTask tid stvar |
75 | 75 | ||
@@ -128,9 +128,7 @@ setToxPolicy params conmap k policy = case policy of | |||
128 | , transitionToState = (\_ -> return ()) :: G.Status ToxProgress -> STM () | 128 | , transitionToState = (\_ -> return ()) :: G.Status ToxProgress -> STM () |
129 | } | 129 | } |
130 | persue_methods = PersueContactMethods | 130 | persue_methods = PersueContactMethods |
131 | { getHandshakeParams = retry -- :: STM params | 131 | { -- TODO |
132 | , sendHandshake = \_ -> return () -- :: params -> IO () | ||
133 | , retryInterval = _todo :: Int | ||
134 | } | 132 | } |
135 | freshen_methods = FreshenContactMethods | 133 | freshen_methods = FreshenContactMethods |
136 | { dhtkeyInterval = _todo :: Int | 134 | { dhtkeyInterval = _todo :: Int |
@@ -181,10 +179,12 @@ setToxPolicy params conmap k policy = case policy of | |||
181 | OpenToConnect -> do -- passively accept connections if they initiate. | 179 | OpenToConnect -> do -- passively accept connections if they initiate. |
182 | mst <- lookupForPolicyChange conmap k policy | 180 | mst <- lookupForPolicyChange conmap k policy |
183 | forM_ mst $ \st -> do | 181 | forM_ mst $ \st -> do |
182 | {- | ||
184 | let getPolicy = readTVar $ connPolicy st | 183 | let getPolicy = readTVar $ connPolicy st |
185 | accept_thread <- launch ("accept:"++show k) | 184 | accept_thread <- launch ("accept:"++show k) |
186 | (G.InProgress $ toEnum 0) | 185 | (G.InProgress $ toEnum 0) |
187 | $ acceptContact getPolicy _accept_methods | 186 | $ acceptContact getPolicy _accept_methods |
187 | -} | ||
188 | atomically $ do | 188 | atomically $ do |
189 | let routing = dhtRouting params | 189 | let routing = dhtRouting params |
190 | Key _ nid = k | 190 | Key _ nid = k |
diff --git a/Connection/Tox/Threads.hs b/Connection/Tox/Threads.hs index f3357215..73c83338 100644 --- a/Connection/Tox/Threads.hs +++ b/Connection/Tox/Threads.hs | |||
@@ -116,15 +116,12 @@ persueContact getPolicy getStatus PersueContactMethods{..} statusVar = do | |||
116 | whileTryingAndNotEstablished getPolicy getStatus statusVar | 116 | whileTryingAndNotEstablished getPolicy getStatus statusVar |
117 | $ \retryAfterTimeout -> | 117 | $ \retryAfterTimeout -> |
118 | orElse (do | 118 | orElse (do |
119 | readTVar statusVar >>= check . (/= InProgress AcquiringIPAddress) | ||
119 | theirDhtKey <- DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) | 120 | theirDhtKey <- DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) |
120 | -- We don't have an IP address yet. | 121 | -- We don't have an IP address yet. |
121 | maybe (return ()) (const retry) =<< readTVar (contactLastSeenAddr contact) | 122 | maybe (return ()) (const retry) =<< readTVar (contactLastSeenAddr contact) |
122 | return $ do -- AcquiringIPAddress | 123 | return $ do -- AcquiringIPAddress |
123 | atomically $ do | 124 | atomically $ writeTVar statusVar (InProgress AcquiringIPAddress) |
124 | status <- readTVar statusVar | ||
125 | if status == InProgress AcquiringIPAddress | ||
126 | then retry | ||
127 | else writeTVar statusVar (InProgress AcquiringIPAddress) | ||
128 | retryAfterTimeout 0) | 125 | retryAfterTimeout 0) |
129 | (do | 126 | (do |
130 | theirDhtKey <- DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) | 127 | theirDhtKey <- DHT.dhtpk <$> retryUntilJust (contactKeyPacket contact) |