diff options
-rw-r--r-- | src/Network/BitTorrent/Client/Handle.hs | 3 | ||||
-rw-r--r-- | src/Network/BitTorrent/Tracker/Session.hs | 14 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/Network/BitTorrent/Client/Handle.hs b/src/Network/BitTorrent/Client/Handle.hs index 258af3fb..97ffc637 100644 --- a/src/Network/BitTorrent/Client/Handle.hs +++ b/src/Network/BitTorrent/Client/Handle.hs | |||
@@ -110,9 +110,10 @@ openMagnet rootPath uri @ Magnet {..} = do | |||
110 | closeHandle :: Handle -> BitTorrent () | 110 | closeHandle :: Handle -> BitTorrent () |
111 | closeHandle h @ Handle {..} = do | 111 | closeHandle h @ Handle {..} = do |
112 | freeHandle handleTopic $ do | 112 | freeHandle handleTopic $ do |
113 | Client {..} <- getClient | ||
113 | stop h | 114 | stop h |
114 | liftIO $ Exchange.closeSession handleExchange | 115 | liftIO $ Exchange.closeSession handleExchange |
115 | liftIO $ Tracker.closeSession handleTrackers | 116 | liftIO $ Tracker.closeSession trackerManager handleTrackers |
116 | 117 | ||
117 | {----------------------------------------------------------------------- | 118 | {----------------------------------------------------------------------- |
118 | -- Control | 119 | -- Control |
diff --git a/src/Network/BitTorrent/Tracker/Session.hs b/src/Network/BitTorrent/Tracker/Session.hs index a17973ad..107b83d6 100644 --- a/src/Network/BitTorrent/Tracker/Session.hs +++ b/src/Network/BitTorrent/Tracker/Session.hs | |||
@@ -214,9 +214,12 @@ newSession ih origUris = do | |||
214 | , sessionEvents = eventStream | 214 | , sessionEvents = eventStream |
215 | } | 215 | } |
216 | 216 | ||
217 | -- | Release scarce resources associated with the given session. | 217 | -- | Release scarce resources associated with the given session. This |
218 | closeSession :: Session -> IO () | 218 | -- function block until all trackers tied with this peer notified with |
219 | closeSession _ = return () | 219 | -- 'Stopped' event. |
220 | closeSession :: Manager -> Session -> IO () | ||
221 | closeSession m s = do | ||
222 | notify m s Stopped | ||
220 | 223 | ||
221 | {----------------------------------------------------------------------- | 224 | {----------------------------------------------------------------------- |
222 | -- Events | 225 | -- Events |
@@ -238,8 +241,9 @@ subscribe Session {..} = listen sessionEvents | |||
238 | -----------------------------------------------------------------------} | 241 | -----------------------------------------------------------------------} |
239 | 242 | ||
240 | -- | Normally you need to use 'Control.Monad.Trans.Resource.alloc'. | 243 | -- | Normally you need to use 'Control.Monad.Trans.Resource.alloc'. |
241 | withSession :: InfoHash -> TrackerList URI -> (Session -> IO ()) -> IO () | 244 | withSession :: Manager -> InfoHash -> TrackerList URI |
242 | withSession ih uris = bracket (newSession ih uris) closeSession | 245 | -> (Session -> IO ()) -> IO () |
246 | withSession m ih uris = bracket (newSession ih uris) (closeSession m) | ||
243 | 247 | ||
244 | -- | Get last announced status. The only action can alter this status | 248 | -- | Get last announced status. The only action can alter this status |
245 | -- is 'notify'. | 249 | -- is 'notify'. |