diff options
author | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-28 19:24:42 +0400 |
---|---|---|
committer | Sam Truzjan <pxqr.sta@gmail.com> | 2014-02-28 19:24:42 +0400 |
commit | 6ff528851f77b46f549db2bd4c6ba7d99d6b828f (patch) | |
tree | 2cac0af9bf39c20c85189b92d29f7b30413bd1bc /src/Network/BitTorrent/Tracker/RPC | |
parent | ec271d0444658d6a56c221473cfaf3b2b01abea2 (diff) |
optMinTimeout should be in seconds, not in useconds
Diffstat (limited to 'src/Network/BitTorrent/Tracker/RPC')
-rw-r--r-- | src/Network/BitTorrent/Tracker/RPC/UDP.hs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/Network/BitTorrent/Tracker/RPC/UDP.hs b/src/Network/BitTorrent/Tracker/RPC/UDP.hs index 48732b9b..0c9c3367 100644 --- a/src/Network/BitTorrent/Tracker/RPC/UDP.hs +++ b/src/Network/BitTorrent/Tracker/RPC/UDP.hs | |||
@@ -68,11 +68,11 @@ sec = 1000000 | |||
68 | 68 | ||
69 | -- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs> | 69 | -- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs> |
70 | defMinTimeout :: Int | 70 | defMinTimeout :: Int |
71 | defMinTimeout = 15 * sec | 71 | defMinTimeout = 15 |
72 | 72 | ||
73 | -- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs> | 73 | -- | See <http://www.bittorrent.org/beps/bep_0015.html#time-outs> |
74 | defMaxTimeout :: Int | 74 | defMaxTimeout :: Int |
75 | defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec | 75 | defMaxTimeout = 15 * 2 ^ (8 :: Int) |
76 | 76 | ||
77 | -- | See: <http://www.bittorrent.org/beps/bep_0015.html#time-outs> | 77 | -- | See: <http://www.bittorrent.org/beps/bep_0015.html#time-outs> |
78 | defMultiplier :: Int | 78 | defMultiplier :: Int |
@@ -90,18 +90,18 @@ data Options = Options | |||
90 | -- | 90 | -- |
91 | optMaxPacketSize :: {-# UNPACK #-} !Int | 91 | optMaxPacketSize :: {-# UNPACK #-} !Int |
92 | 92 | ||
93 | -- | Starting timeout interval. If a response is not received | 93 | -- | Starting timeout interval in seconds. If a response is not |
94 | -- after 'optMinTimeout' then 'Manager' repeat RPC with timeout | 94 | -- received after 'optMinTimeout' then 'Manager' repeat RPC with |
95 | -- interval multiplied by 'optMultiplier' and so on until | 95 | -- timeout interval multiplied by 'optMultiplier' and so on until |
96 | -- timeout interval reach 'optMaxTimeout'. | 96 | -- timeout interval reach 'optMaxTimeout'. |
97 | -- | 97 | -- |
98 | -- 'optMinTimeout' /must/ be a positive value. | 98 | -- 'optMinTimeout' /must/ be a positive value. |
99 | -- | 99 | -- |
100 | , optMinTimeout :: {-# UNPACK #-} !Int | 100 | , optMinTimeout :: {-# UNPACK #-} !Int |
101 | 101 | ||
102 | -- | After 'optMaxTimeout' reached and tracker still not | 102 | -- | Final timeout interval in seconds. After 'optMaxTimeout' |
103 | -- responding both 'announce' and 'scrape' functions will throw | 103 | -- reached and tracker still not responding both 'announce' and |
104 | -- 'TimeoutExpired' exception. | 104 | -- 'scrape' functions will throw 'TimeoutExpired' exception. |
105 | -- | 105 | -- |
106 | -- 'optMaxTimeout' /must/ be greater than 'optMinTimeout'. | 106 | -- 'optMaxTimeout' /must/ be greater than 'optMinTimeout'. |
107 | -- | 107 | -- |
@@ -574,7 +574,7 @@ retransmission Options {..} action = go optMinTimeout | |||
574 | go curTimeout | 574 | go curTimeout |
575 | | curTimeout > optMaxTimeout = throwIO $ TimeoutExpired curTimeout | 575 | | curTimeout > optMaxTimeout = throwIO $ TimeoutExpired curTimeout |
576 | | otherwise = do | 576 | | otherwise = do |
577 | r <- timeout curTimeout action | 577 | r <- timeout (curTimeout * sec) action |
578 | maybe (go (optMultiplier * curTimeout)) return r | 578 | maybe (go (optMultiplier * curTimeout)) return r |
579 | 579 | ||
580 | queryTracker :: Manager -> URI -> Request -> IO Response | 580 | queryTracker :: Manager -> URI -> Request -> IO Response |