From ec3d89b295a004e992dec3ba03a7efe9a1b62fe2 Mon Sep 17 00:00:00 2001 From: Sam T Date: Fri, 16 Aug 2013 17:34:45 +0400 Subject: ~ Make enterSwarm exception safe. --- src/Network/BitTorrent/Sessions.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Network') diff --git a/src/Network/BitTorrent/Sessions.hs b/src/Network/BitTorrent/Sessions.hs index f2035066..9713f438 100644 --- a/src/Network/BitTorrent/Sessions.hs +++ b/src/Network/BitTorrent/Sessions.hs @@ -297,7 +297,8 @@ defaultThreadCount = 1000 enterSwarm :: SwarmSession -> IO () enterSwarm SwarmSession {..} = do MSem.wait (activeThreads clientSession) - MSem.wait vacantPeers + MSem.wait vacantPeers `onException` + MSem.signal (activeThreads clientSession) leaveSwarm :: SwarmSession -> IO () leaveSwarm SwarmSession {..} = mask_ $ do -- cgit v1.2.3