From 4371e51bcdc7ed85bea384169d039a98742572bd Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Wed, 26 Feb 2014 15:55:54 +0400 Subject: Move backoff multiplier to options --- src/Network/BitTorrent/Tracker/RPC/UDP.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/Network/BitTorrent/Tracker/RPC/UDP.hs') 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 defMaxTimeout :: Int defMaxTimeout = 15 * 2 ^ (8 :: Int) * sec +defMultiplier :: Int +defMultiplier = 2 + -- announce request packet defMaxPacketSize :: Int defMaxPacketSize = 98 @@ -81,6 +84,8 @@ data Options = Options -- | in seconds. , optMaxTimeout :: {-# UNPACK #-} !Int + + , optMultiplier :: {-# UNPACK #-} !Int } deriving (Show, Eq) instance Default Options where @@ -88,6 +93,7 @@ instance Default Options where { optMaxPacketSize = defMaxPacketSize , optMinTimeout = defMinTimeout , optMaxTimeout = defMaxTimeout + , optMultiplier = defMultiplier } {----------------------------------------------------------------------- @@ -520,7 +526,7 @@ retransmission Options {..} action = go optMinTimeout | curTimeout > optMaxTimeout = throwIO $ TimeoutExpired curTimeout | otherwise = do r <- timeout curTimeout action - maybe (go (2 * curTimeout)) return r + maybe (go (optMultiplier * curTimeout)) return r queryTracker :: Manager -> URI -> Request -> IO Response queryTracker mgr uri req = do -- cgit v1.2.3