mirror of https://github.com/voidlizard/hbs2
okay?
This commit is contained in:
parent
1e9aadfab5
commit
fd7a394779
|
@ -694,8 +694,8 @@ downloadDispatcher brains env = flip runContT pure do
|
||||||
|
|
||||||
bm <- liftIO do
|
bm <- liftIO do
|
||||||
case _sockType p of
|
case _sockType p of
|
||||||
TCP -> newBurstMachine 10 256 (Just 256) 0.25 0.45
|
TCP -> newBurstMachine 20 256 (Just 256) 0.25 0.45
|
||||||
UDP -> newBurstMachine 10 256 (Just 50) 0.10 0.25
|
UDP -> newBurstMachine 3 256 (Just 50) 0.10 0.25
|
||||||
|
|
||||||
void $ ContT $ bracket none $ const do
|
void $ ContT $ bracket none $ const do
|
||||||
debug $ "Cancelling thread for" <+> pretty p
|
debug $ "Cancelling thread for" <+> pretty p
|
||||||
|
@ -744,29 +744,34 @@ downloadDispatcher brains env = flip runContT pure do
|
||||||
PChoose -> do
|
PChoose -> do
|
||||||
|
|
||||||
what <- atomically do
|
what <- atomically do
|
||||||
TSem.waitTSem sem
|
e <- readTVar _errors
|
||||||
|
|
||||||
wpsize <- readTVar wip <&> HM.size
|
if e > 10 then
|
||||||
let trsh = if wpsize < 10 then 3 else 0
|
pure Nothing
|
||||||
|
else do
|
||||||
|
TSem.waitTSem sem
|
||||||
|
|
||||||
blocks <- readTVar wip
|
wpsize <- readTVar wip <&> HM.size
|
||||||
|
let trsh = if wpsize < 10 then 3 else 0
|
||||||
|
|
||||||
when (HM.null blocks) retry
|
blocks <- readTVar wip
|
||||||
|
|
||||||
let todo = V.fromList (HM.toList blocks)
|
when (HM.null blocks) retry
|
||||||
let len = V.length todo
|
|
||||||
i <- stateTVar rndGen ( randomR (0, len - 1) )
|
|
||||||
|
|
||||||
let (h,dcb@DCB{..}) = V.unsafeIndex todo (i `mod` len)
|
let todo = V.fromList (HM.toList blocks)
|
||||||
|
let len = V.length todo
|
||||||
|
i <- stateTVar rndGen ( randomR (0, len - 1) )
|
||||||
|
|
||||||
busy <- readTVar dcbBusy
|
let (h,dcb@DCB{..}) = V.unsafeIndex todo (i `mod` len)
|
||||||
down <- readTVar dcbDownloaded
|
|
||||||
absent <- readTVar _sizeCache <&> (== Just Nothing) . HM.lookup h
|
|
||||||
|
|
||||||
if busy > trsh || down || absent then
|
busy <- readTVar dcbBusy
|
||||||
retry
|
down <- readTVar dcbDownloaded
|
||||||
else do
|
absent <- readTVar _sizeCache <&> (== Just Nothing) . HM.lookup h
|
||||||
pure (Just (h,dcb))
|
|
||||||
|
if busy > trsh || down || absent then
|
||||||
|
retry
|
||||||
|
else do
|
||||||
|
pure (Just (h,dcb))
|
||||||
|
|
||||||
case what of
|
case what of
|
||||||
Just (hx, dcb) -> go (PInit hx dcb)
|
Just (hx, dcb) -> go (PInit hx dcb)
|
||||||
|
@ -775,7 +780,7 @@ downloadDispatcher brains env = flip runContT pure do
|
||||||
if erno > 50 then do
|
if erno > 50 then do
|
||||||
pause @'Seconds 60
|
pause @'Seconds 60
|
||||||
else do
|
else do
|
||||||
pause @'Seconds 0.25
|
pause @'Seconds 1.00
|
||||||
go PChoose
|
go PChoose
|
||||||
|
|
||||||
PInit hx dcb -> do
|
PInit hx dcb -> do
|
||||||
|
|
Loading…
Reference in New Issue