diff options
-rw-r--r-- | Announcer.hs | 7 | ||||
-rw-r--r-- | Announcer/Tox.hs | 3 | ||||
-rw-r--r-- | ToxToXMPP.hs | 1 |
3 files changed, 7 insertions, 4 deletions
diff --git a/Announcer.hs b/Announcer.hs index 37ed03ef..ef931cce 100644 --- a/Announcer.hs +++ b/Announcer.hs | |||
@@ -17,6 +17,7 @@ module Announcer | |||
17 | , stopAnnouncer | 17 | , stopAnnouncer |
18 | , cancel | 18 | , cancel |
19 | , itemStatusNum | 19 | , itemStatusNum |
20 | , runAction | ||
20 | 21 | ||
21 | -- lower level, Announcer.Tox needs these. | 22 | -- lower level, Announcer.Tox needs these. |
22 | , scheduleImmediately | 23 | , scheduleImmediately |
@@ -111,6 +112,9 @@ scheduleAbs :: Announcer -> AnnounceKey -> ScheduledItem -> POSIXTime -> STM () | |||
111 | scheduleAbs announcer k item absTime = | 112 | scheduleAbs announcer k item absTime = |
112 | writeTChan (commander announcer) $ ScheduleAction (k, absTime, item) | 113 | writeTChan (commander announcer) $ ScheduleAction (k, absTime, item) |
113 | 114 | ||
115 | runAction :: Announcer -> IO () -> STM () | ||
116 | runAction announcer = writeTChan (commander announcer) . RunAction | ||
117 | |||
114 | -- | Terminate the 'Announcer' thread. Don't use the Announcer after this. | 118 | -- | Terminate the 'Announcer' thread. Don't use the Announcer after this. |
115 | stopAnnouncer :: Announcer -> IO () | 119 | stopAnnouncer :: Announcer -> IO () |
116 | stopAnnouncer announcer = do | 120 | stopAnnouncer announcer = do |
@@ -139,7 +143,7 @@ readTChanTimeout delay pktChannel = do | |||
139 | toMicroseconds :: POSIXTime -> Int | 143 | toMicroseconds :: POSIXTime -> Int |
140 | toMicroseconds = round . (* 1000) . (* 1000) | 144 | toMicroseconds = round . (* 1000) . (* 1000) |
141 | 145 | ||
142 | data SchedulerCommand = ShutdownScheduler | ScheduleAction KPS | 146 | data SchedulerCommand = ShutdownScheduler | ScheduleAction KPS | RunAction (IO ()) |
143 | 147 | ||
144 | listener :: Announcer -> IO () | 148 | listener :: Announcer -> IO () |
145 | listener announcer = relisten | 149 | listener announcer = relisten |
@@ -174,6 +178,7 @@ listener announcer = relisten | |||
174 | handleCommand = | 178 | handleCommand = |
175 | \case | 179 | \case |
176 | ShutdownScheduler -> atomically declareInactive | 180 | ShutdownScheduler -> atomically declareInactive |
181 | RunAction io -> io >> relisten | ||
177 | ScheduleAction (k, p, s) -> do | 182 | ScheduleAction (k, p, s) -> do |
178 | atomically $ | 183 | atomically $ |
179 | modifyTVar | 184 | modifyTVar |
diff --git a/Announcer/Tox.hs b/Announcer/Tox.hs index d0fc828f..38741d10 100644 --- a/Announcer/Tox.hs +++ b/Announcer/Tox.hs | |||
@@ -185,8 +185,7 @@ scheduleSearch announcer k SearchMethod{sSearch,sWithResult,sNearestNodes,sTarge | |||
185 | ns <- atomically $ newTVar MM.empty | 185 | ns <- atomically $ newTVar MM.empty |
186 | let astate = AnnounceState st ns | 186 | let astate = AnnounceState st ns |
187 | onResult sr = do | 187 | onResult sr = do |
188 | -- XXX: Using /k/ here as the announce key is causing the search not to repeat. | 188 | runAction announcer $ do |
189 | scheduleImmediately announcer k $ ScheduledItem $ \_ _ _ -> return $ do | ||
190 | got <- sWithResult r sr | 189 | got <- sWithResult r sr |
191 | -- If we had a way to get the source of a search result, we might want to | 190 | -- If we had a way to get the source of a search result, we might want to |
192 | -- treat it similarly to an announcing node and remember it in the 'aStoringNodes' | 191 | -- treat it similarly to an announcing node and remember it in the 'aStoringNodes' |
diff --git a/ToxToXMPP.hs b/ToxToXMPP.hs index c61764ef..9391a232 100644 --- a/ToxToXMPP.hs +++ b/ToxToXMPP.hs | |||
@@ -175,7 +175,6 @@ startConnecting0 tx them contact = do | |||
175 | -- likelihood of failure as the chances of packet loss | 175 | -- likelihood of failure as the chances of packet loss |
176 | -- happening to all (up to to 8) packets sent is low. | 176 | -- happening to all (up to to 8) packets sent is low. |
177 | -- | 177 | -- |
178 | -- TODO: Reschedule this as appropriate within 'dispatch' function. | ||
179 | scheduleSearch announcer | 178 | scheduleSearch announcer |
180 | akey | 179 | akey |
181 | (SearchMethod (toxQSearch tox) | 180 | (SearchMethod (toxQSearch tox) |