summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Network/BitTorrent/Exchange.hs5
-rw-r--r--src/Network/BitTorrent/Internal.lhs10
2 files changed, 9 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/Exchange.hs b/src/Network/BitTorrent/Exchange.hs
index 5be9ae73..a0e7df8c 100644
--- a/src/Network/BitTorrent/Exchange.hs
+++ b/src/Network/BitTorrent/Exchange.hs
@@ -171,10 +171,7 @@ runP2P se addr p2p = waitVacancy se $ runSession se addr p2p
171-- some other loop. Note that this function may block while waiting 171-- some other loop. Note that this function may block while waiting
172-- for a vacant place: use forkIO and runP2P instead. 172-- for a vacant place: use forkIO and runP2P instead.
173spawnP2P :: SwarmSession -> PeerAddr -> P2P () -> IO ThreadId 173spawnP2P :: SwarmSession -> PeerAddr -> P2P () -> IO ThreadId
174spawnP2P se addr p2p = do 174spawnP2P se addr p2p = forkThrottle se $ runSession se addr p2p
175 enterSwarm se
176 forkIO $ do
177 runSession se addr p2p `finally` leaveSwarm se
178 175
179-- TODO unify this all using PeerConnection 176-- TODO unify this all using PeerConnection
180{- 177{-
diff --git a/src/Network/BitTorrent/Internal.lhs b/src/Network/BitTorrent/Internal.lhs
index 7edcc977..5f6ad458 100644
--- a/src/Network/BitTorrent/Internal.lhs
+++ b/src/Network/BitTorrent/Internal.lhs
@@ -56,9 +56,8 @@
56> , newSeeder 56> , newSeeder
57> , getClientBitfield 57> , getClientBitfield
58> 58>
59> , enterSwarm
60> , leaveSwarm
61> , waitVacancy 59> , waitVacancy
60> , forkThrottle
62> 61>
63> , pieceLength 62> , pieceLength
64> 63>
@@ -616,6 +615,13 @@ Peer sessions throttling
616> bracket (enterSwarm se) (const (leaveSwarm se)) 615> bracket (enterSwarm se) (const (leaveSwarm se))
617> . const 616> . const
618 617
618> forkThrottle :: SwarmSession -> IO () -> IO ThreadId
619> forkThrottle se action = do
620> enterSwarm se
621> (forkIO $ do
622> action `finally` leaveSwarm se)
623> `onException` leaveSwarm se
624
619Peer sessions 625Peer sessions
620------------------------------------------------------------------------ 626------------------------------------------------------------------------
621 627