diff options
-rw-r--r-- | src/Network/BitTorrent/Internal.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Network/BitTorrent/Internal.hs b/src/Network/BitTorrent/Internal.hs index 5c9efd1f..f762bf34 100644 --- a/src/Network/BitTorrent/Internal.hs +++ b/src/Network/BitTorrent/Internal.hs | |||
@@ -119,7 +119,7 @@ data ClientSession = ClientSession { | |||
119 | , allowedExtensions :: [Extension] | 119 | , allowedExtensions :: [Extension] |
120 | 120 | ||
121 | -- | Semaphor used to bound number of active P2P sessions. | 121 | -- | Semaphor used to bound number of active P2P sessions. |
122 | , activeThreads :: QSemN | 122 | , activeThreads :: QSem |
123 | 123 | ||
124 | -- | Max number of active connections. | 124 | -- | Max number of active connections. |
125 | , maxActive :: Int | 125 | , maxActive :: Int |
@@ -151,7 +151,7 @@ newClient n exts = do | |||
151 | ClientSession | 151 | ClientSession |
152 | <$> newPeerID | 152 | <$> newPeerID |
153 | <*> pure exts | 153 | <*> pure exts |
154 | <*> newQSemN n | 154 | <*> newQSem n |
155 | <*> pure n | 155 | <*> pure n |
156 | <*> newTVarIO S.empty | 156 | <*> newTVarIO S.empty |
157 | <*> pure mgr | 157 | <*> pure mgr |
@@ -169,7 +169,7 @@ data SwarmSession = SwarmSession { | |||
169 | 169 | ||
170 | -- | Represent count of peers we _currently_ can connect to in the | 170 | -- | Represent count of peers we _currently_ can connect to in the |
171 | -- swarm. Used to bound number of concurrent threads. | 171 | -- swarm. Used to bound number of concurrent threads. |
172 | , vacantPeers :: QSemN | 172 | , vacantPeers :: QSem |
173 | 173 | ||
174 | -- | Modify this carefully updating global progress. | 174 | -- | Modify this carefully updating global progress. |
175 | , clientBitfield :: TVar Bitfield | 175 | , clientBitfield :: TVar Bitfield |
@@ -187,7 +187,7 @@ newSwarmSession :: Int -> Bitfield -> ClientSession -> Torrent | |||
187 | newSwarmSession n bf cs @ ClientSession {..} t @ Torrent {..} | 187 | newSwarmSession n bf cs @ ClientSession {..} t @ Torrent {..} |
188 | = SwarmSession <$> pure t | 188 | = SwarmSession <$> pure t |
189 | <*> pure cs | 189 | <*> pure cs |
190 | <*> newQSemN n | 190 | <*> newQSem n |
191 | <*> newTVarIO bf | 191 | <*> newTVarIO bf |
192 | <*> newTVarIO S.empty | 192 | <*> newTVarIO S.empty |
193 | 193 | ||
@@ -219,13 +219,13 @@ haveDone ix = | |||
219 | 219 | ||
220 | enterSwarm :: SwarmSession -> IO () | 220 | enterSwarm :: SwarmSession -> IO () |
221 | enterSwarm SwarmSession {..} = do | 221 | enterSwarm SwarmSession {..} = do |
222 | waitQSemN (activeThreads clientSession) 1 | 222 | waitQSem (activeThreads clientSession) |
223 | waitQSemN vacantPeers 1 | 223 | waitQSem vacantPeers |
224 | 224 | ||
225 | leaveSwarm :: SwarmSession -> IO () | 225 | leaveSwarm :: SwarmSession -> IO () |
226 | leaveSwarm SwarmSession {..} = do | 226 | leaveSwarm SwarmSession {..} = do |
227 | signalQSemN vacantPeers 1 | 227 | signalQSem vacantPeers |
228 | signalQSemN (activeThreads clientSession) 1 | 228 | signalQSem (activeThreads clientSession) |
229 | 229 | ||
230 | waitVacancy :: SwarmSession -> IO () -> IO () | 230 | waitVacancy :: SwarmSession -> IO () -> IO () |
231 | waitVacancy se = | 231 | waitVacancy se = |