summaryrefslogtreecommitdiff
path: root/src/Network/BitTorrent/Tracker
diff options
context:
space:
mode:
authorSam Truzjan <pxqr.sta@gmail.com>2014-02-26 15:55:54 +0400
committerSam Truzjan <pxqr.sta@gmail.com>2014-02-26 15:55:54 +0400
commit4371e51bcdc7ed85bea384169d039a98742572bd (patch)
treef4984e13335645d5f74033bf7fc12f9a0bada7ee /src/Network/BitTorrent/Tracker
parent63cda028ce38fd37bd3ee55f546b107f161af170 (diff)
Move backoff multiplier to options
Diffstat (limited to 'src/Network/BitTorrent/Tracker')
-rw-r--r--src/Network/BitTorrent/Tracker/RPC/UDP.hs8
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
69defMaxTimeout :: Int 69defMaxTimeout :: Int
70defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec 70defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec
71 71
72defMultiplier :: Int
73defMultiplier = 2
74
72-- announce request packet 75-- announce request packet
73defMaxPacketSize :: Int 76defMaxPacketSize :: Int
74defMaxPacketSize = 98 77defMaxPacketSize = 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
86instance Default Options where 91instance 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
525queryTracker :: Manager -> URI -> Request -> IO Response 531queryTracker :: Manager -> URI -> Request -> IO Response
526queryTracker mgr uri req = do 532queryTracker mgr uri req = do