diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Network/BitTorrent/Tracker/RPC/UDP.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Network/BitTorrent/Tracker/RPC/UDP.hs b/src/Network/BitTorrent/Tracker/RPC/UDP.hs index f057597c..f271e864 100644 --- a/src/Network/BitTorrent/Tracker/RPC/UDP.hs +++ b/src/Network/BitTorrent/Tracker/RPC/UDP.hs | |||
@@ -69,6 +69,9 @@ defMinTimeout = 15 * sec | |||
69 | defMaxTimeout :: Int | 69 | defMaxTimeout :: Int |
70 | defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec | 70 | defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec |
71 | 71 | ||
72 | defMultiplier :: Int | ||
73 | defMultiplier = 2 | ||
74 | |||
72 | -- announce request packet | 75 | -- announce request packet |
73 | defMaxPacketSize :: Int | 76 | defMaxPacketSize :: Int |
74 | defMaxPacketSize = 98 | 77 | defMaxPacketSize = 98 |
@@ -81,6 +84,8 @@ data Options = Options | |||
81 | 84 | ||
82 | -- | in seconds. | 85 | -- | in seconds. |
83 | , optMaxTimeout :: {-# UNPACK #-} !Int | 86 | , optMaxTimeout :: {-# UNPACK #-} !Int |
87 | |||
88 | , optMultiplier :: {-# UNPACK #-} !Int | ||
84 | } deriving (Show, Eq) | 89 | } deriving (Show, Eq) |
85 | 90 | ||
86 | instance Default Options where | 91 | instance Default Options where |
@@ -88,6 +93,7 @@ instance Default Options where | |||
88 | { optMaxPacketSize = defMaxPacketSize | 93 | { optMaxPacketSize = defMaxPacketSize |
89 | , optMinTimeout = defMinTimeout | 94 | , optMinTimeout = defMinTimeout |
90 | , optMaxTimeout = defMaxTimeout | 95 | , optMaxTimeout = defMaxTimeout |
96 | , optMultiplier = defMultiplier | ||
91 | } | 97 | } |
92 | 98 | ||
93 | {----------------------------------------------------------------------- | 99 | {----------------------------------------------------------------------- |
@@ -520,7 +526,7 @@ retransmission Options {..} action = go optMinTimeout | |||
520 | | curTimeout > optMaxTimeout = throwIO $ TimeoutExpired curTimeout | 526 | | curTimeout > optMaxTimeout = throwIO $ TimeoutExpired curTimeout |
521 | | otherwise = do | 527 | | otherwise = do |
522 | r <- timeout curTimeout action | 528 | r <- timeout curTimeout action |
523 | maybe (go (2 * curTimeout)) return r | 529 | maybe (go (optMultiplier * curTimeout)) return r |
524 | 530 | ||
525 | queryTracker :: Manager -> URI -> Request -> IO Response | 531 | queryTracker :: Manager -> URI -> Request -> IO Response |
526 | queryTracker mgr uri req = do | 532 | queryTracker mgr uri req = do |