diff options
Diffstat (limited to 'src/Network/BitTorrent')
-rw-r--r-- | src/Network/BitTorrent/Client.hs | 4 | ||||
-rw-r--r-- | src/Network/BitTorrent/DHT.hs | 6 | ||||
-rw-r--r-- | src/Network/BitTorrent/DHT/Session.hs | 12 |
3 files changed, 11 insertions, 11 deletions
diff --git a/src/Network/BitTorrent/Client.hs b/src/Network/BitTorrent/Client.hs index 905d3384..bd4993ba 100644 --- a/src/Network/BitTorrent/Client.hs +++ b/src/Network/BitTorrent/Client.hs | |||
@@ -98,8 +98,8 @@ initClient opts @ Options {..} logFun = do | |||
98 | let mkEx = Exchange.newManager (exchangeOptions pid opts) (connHandler tmap) | 98 | let mkEx = Exchange.newManager (exchangeOptions pid opts) (connHandler tmap) |
99 | (_, emgr) <- allocate mkEx Exchange.closeManager | 99 | (_, emgr) <- allocate mkEx Exchange.closeManager |
100 | 100 | ||
101 | let mkNode = startNode defaultHandlers def optNodeAddr logFun | 101 | let mkNode = DHT.newNode defaultHandlers def optNodeAddr logFun |
102 | (_, node) <- allocate mkNode stopNode | 102 | (_, node) <- allocate mkNode DHT.closeNode |
103 | 103 | ||
104 | resourceMap <- getInternalState | 104 | resourceMap <- getInternalState |
105 | return Client | 105 | return Client |
diff --git a/src/Network/BitTorrent/DHT.hs b/src/Network/BitTorrent/DHT.hs index ed42363f..44c55128 100644 --- a/src/Network/BitTorrent/DHT.hs +++ b/src/Network/BitTorrent/DHT.hs | |||
@@ -44,8 +44,8 @@ module Network.BitTorrent.DHT | |||
44 | , LogFun | 44 | , LogFun |
45 | , Node | 45 | , Node |
46 | , defaultHandlers | 46 | , defaultHandlers |
47 | , startNode | 47 | , newNode |
48 | , stopNode | 48 | , closeNode |
49 | 49 | ||
50 | -- ** Monad | 50 | -- ** Monad |
51 | , MonadDHT (..) | 51 | , MonadDHT (..) |
@@ -86,7 +86,7 @@ dht :: Address ip | |||
86 | -> IO a -- ^ result. | 86 | -> IO a -- ^ result. |
87 | dht opts addr action = do | 87 | dht opts addr action = do |
88 | runStderrLoggingT $ LoggingT $ \ logger -> do | 88 | runStderrLoggingT $ LoggingT $ \ logger -> do |
89 | bracket (startNode defaultHandlers opts addr logger) stopNode $ | 89 | bracket (newNode defaultHandlers opts addr logger) closeNode $ |
90 | \ node -> runDHT node action | 90 | \ node -> runDHT node action |
91 | {-# INLINE dht #-} | 91 | {-# INLINE dht #-} |
92 | 92 | ||
diff --git a/src/Network/BitTorrent/DHT/Session.hs b/src/Network/BitTorrent/DHT/Session.hs index 69970918..43bd65e5 100644 --- a/src/Network/BitTorrent/DHT/Session.hs +++ b/src/Network/BitTorrent/DHT/Session.hs | |||
@@ -33,8 +33,8 @@ module Network.BitTorrent.DHT.Session | |||
33 | -- ** Initialization | 33 | -- ** Initialization |
34 | , LogFun | 34 | , LogFun |
35 | , NodeHandler | 35 | , NodeHandler |
36 | , startNode | 36 | , newNode |
37 | , stopNode | 37 | , closeNode |
38 | 38 | ||
39 | -- * DHT | 39 | -- * DHT |
40 | -- | Use @asks options@ to get options passed to 'startNode' | 40 | -- | Use @asks options@ to get options passed to 'startNode' |
@@ -294,13 +294,13 @@ type NodeHandler ip = Handler (DHT ip) | |||
294 | -- | Run DHT session. You /must/ properly close session using | 294 | -- | Run DHT session. You /must/ properly close session using |
295 | -- 'stopNode' function, otherwise socket or other scarce resources may | 295 | -- 'stopNode' function, otherwise socket or other scarce resources may |
296 | -- leak. | 296 | -- leak. |
297 | startNode :: Address ip | 297 | newNode :: Address ip |
298 | => [NodeHandler ip] -- ^ handlers to run on accepted queries; | 298 | => [NodeHandler ip] -- ^ handlers to run on accepted queries; |
299 | -> Options -- ^ various dht options; | 299 | -> Options -- ^ various dht options; |
300 | -> NodeAddr ip -- ^ node address to bind; | 300 | -> NodeAddr ip -- ^ node address to bind; |
301 | -> LogFun -- ^ | 301 | -> LogFun -- ^ |
302 | -> IO (Node ip) -- ^ a new DHT node running at given address. | 302 | -> IO (Node ip) -- ^ a new DHT node running at given address. |
303 | startNode hs opts naddr logger = do | 303 | newNode hs opts naddr logger = do |
304 | s <- createInternalState | 304 | s <- createInternalState |
305 | runInternalState initNode s | 305 | runInternalState initNode s |
306 | `onException` closeInternalState s | 306 | `onException` closeInternalState s |
@@ -323,8 +323,8 @@ startNode hs opts naddr logger = do | |||
323 | 323 | ||
324 | -- | Some resources like listener thread may live for | 324 | -- | Some resources like listener thread may live for |
325 | -- some short period of time right after this DHT session closed. | 325 | -- some short period of time right after this DHT session closed. |
326 | stopNode :: Node ip -> IO () | 326 | closeNode :: Node ip -> IO () |
327 | stopNode Node {..} = closeInternalState resources | 327 | closeNode Node {..} = closeInternalState resources |
328 | 328 | ||
329 | -- | Run DHT operation on the given session. | 329 | -- | Run DHT operation on the given session. |
330 | runDHT :: Node ip -> DHT ip a -> IO a | 330 | runDHT :: Node ip -> DHT ip a -> IO a |