summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Tracker.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/BitTorrent/Tracker.hs')
-rw-r--r--src/Network/BitTorrent/Tracker.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Network/BitTorrent/Tracker.hs b/src/Network/BitTorrent/Tracker.hs
index e1f9ff76..6bf6de4b 100644
--- a/src/Network/BitTorrent/Tracker.hs
+++ b/src/Network/BitTorrent/Tracker.hs
@@ -164,8 +164,14 @@ getPeerList = getChanContents . sePeers
164getProgress :: TSession -> IO Progress 164getProgress :: TSession -> IO Progress
165getProgress = readTVarIO . seProgress 165getProgress = readTVarIO . seProgress
166 166
167sec :: Int
168sec = 1000 * 1000
169
167waitInterval :: TSession -> IO () 170waitInterval :: TSession -> IO ()
168waitInterval = readIORef . seInterval >=> threadDelay 171waitInterval se @ TSession {..} = do
172 delay <- readIORef seInterval
173 print delay
174 threadDelay (delay * sec)
169 175
170withTracker :: Progress -> TConnection -> (TSession -> IO a) -> IO a 176withTracker :: Progress -> TConnection -> (TSession -> IO a) -> IO a
171withTracker initProgress conn action = bracket start end (action . fst) 177withTracker initProgress conn action = bracket start end (action . fst)
@@ -174,7 +180,7 @@ withTracker initProgress conn action = bracket start end (action . fst)
174 resp <- askTracker (startedReq conn initProgress) 180 resp <- askTracker (startedReq conn initProgress)
175 print resp 181 print resp
176 se <- newSession initProgress (respInterval resp) (respPeers resp) 182 se <- newSession initProgress (respInterval resp) (respPeers resp)
177 tid <- forkIO (syncSession se) 183 tid <- forkIO (return ()) -- (syncSession se)
178 return (se, tid) 184 return (se, tid)
179 185
180 syncSession se @ TSession {..} = forever $ do 186 syncSession se @ TSession {..} = forever $ do
@@ -197,7 +203,8 @@ withTracker initProgress conn action = bracket start end (action . fst)
197 end (se, tid) = do 203 end (se, tid) = do
198 killThread tid 204 killThread tid
199 pr <- getProgress se 205 pr <- getProgress se
200 askTracker $ stoppedReq conn pr 206 print "stopping"
207 leaveTracker $ stoppedReq conn pr
201 208
202 209
203 210