fix --time-limit
It got broken in several ways by the streaming seeking optimisations around version 8.20201007. Moved time limit checking out of the matcher, which was a hack in the first place. So everywhere that uses Limit.getMatcher needs to check time limit. Well, almost everywhere. Command.Info uses it, but it does not make sense to time limit getting info. And Command.MultiCast uses it just to build up a list of files that then get passed to a command, so it would never have hit the timeout in a useful way. This implementation is a little more expensive when at time limit than necessary, since it continues seeking only to discard everything after the time limit. I did try making it close the file handles to force a faster shutdown, but that didn't work and hung. Could certianly be improved somehow, but seeking is probably not the expensive bit when a time limit is hit, so this seems acceptable for now.
This commit is contained in:
parent
a5511c32d7
commit
a3a19518d8
6 changed files with 73 additions and 40 deletions
|
@ -1,6 +1,6 @@
|
|||
{- git-annex command-line option parsing
|
||||
-
|
||||
- Copyright 2010-2019 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -11,6 +11,7 @@ module CmdLine.GitAnnex.Options where
|
|||
|
||||
import Control.Monad.Fail as Fail (MonadFail(..))
|
||||
import Options.Applicative
|
||||
import Data.Time.Clock.POSIX
|
||||
import qualified Data.Map as M
|
||||
|
||||
import Annex.Common
|
||||
|
@ -403,12 +404,17 @@ jobsOption =
|
|||
|
||||
timeLimitOption :: [GlobalOption]
|
||||
timeLimitOption =
|
||||
[ globalSetter Limit.addTimeLimit $ option (eitherReader parseDuration)
|
||||
[ globalSetter settimelimit $ option (eitherReader parseDuration)
|
||||
( long "time-limit" <> short 'T' <> metavar paramTime
|
||||
<> help "stop after the specified amount of time"
|
||||
<> hidden
|
||||
)
|
||||
]
|
||||
where
|
||||
settimelimit duration = do
|
||||
start <- liftIO getPOSIXTime
|
||||
let cutoff = start + durationToPOSIXTime duration
|
||||
Annex.changeState $ \s -> s { Annex.timelimit = Just (duration, cutoff) }
|
||||
|
||||
data DaemonOptions = DaemonOptions
|
||||
{ foregroundDaemonOption :: Bool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue