Avoid looping if long-running git cat-file or git hash-object crashes and keeps crashing when restarted.
This commit is contained in:
parent
e3344c1c71
commit
858eb26303
4 changed files with 17 additions and 7 deletions
|
@ -128,9 +128,14 @@ leaveZombie = fst
|
||||||
|
|
||||||
{- Runs a git command as a coprocess. -}
|
{- Runs a git command as a coprocess. -}
|
||||||
gitCoProcessStart :: Bool -> [CommandParam] -> Repo -> IO CoProcess.CoProcessHandle
|
gitCoProcessStart :: Bool -> [CommandParam] -> Repo -> IO CoProcess.CoProcessHandle
|
||||||
gitCoProcessStart restartable params repo = CoProcess.start restartable "git"
|
gitCoProcessStart restartable params repo = CoProcess.start numrestarts "git"
|
||||||
(toCommand $ gitCommandLine params repo)
|
(toCommand $ gitCommandLine params repo)
|
||||||
(gitEnv repo)
|
(gitEnv repo)
|
||||||
|
where
|
||||||
|
{- If a long-running git command like cat-file --batch
|
||||||
|
- crashes, it will likely start up again ok. If it keeps crashing
|
||||||
|
- 10 times, something is badly wrong. -}
|
||||||
|
numrestarts = if restartable then 10 else 0
|
||||||
|
|
||||||
gitCreateProcess :: [CommandParam] -> Repo -> CreateProcess
|
gitCreateProcess :: [CommandParam] -> Repo -> CreateProcess
|
||||||
gitCreateProcess params repo =
|
gitCreateProcess params repo =
|
||||||
|
|
|
@ -30,15 +30,15 @@ data CoProcessState = CoProcessState
|
||||||
}
|
}
|
||||||
|
|
||||||
data CoProcessSpec = CoProcessSpec
|
data CoProcessSpec = CoProcessSpec
|
||||||
{ coProcessRestartable :: Bool
|
{ coProcessNumRestarts :: Int
|
||||||
, coProcessCmd :: FilePath
|
, coProcessCmd :: FilePath
|
||||||
, coProcessParams :: [String]
|
, coProcessParams :: [String]
|
||||||
, coProcessEnv :: Maybe [(String, String)]
|
, coProcessEnv :: Maybe [(String, String)]
|
||||||
}
|
}
|
||||||
|
|
||||||
start :: Bool -> FilePath -> [String] -> Maybe [(String, String)] -> IO CoProcessHandle
|
start :: Int -> FilePath -> [String] -> Maybe [(String, String)] -> IO CoProcessHandle
|
||||||
start restartable cmd params env = do
|
start numrestarts cmd params env = do
|
||||||
s <- start' $ CoProcessSpec restartable cmd params env
|
s <- start' $ CoProcessSpec numrestarts cmd params env
|
||||||
newMVar s
|
newMVar s
|
||||||
|
|
||||||
start' :: CoProcessSpec -> IO CoProcessState
|
start' :: CoProcessSpec -> IO CoProcessState
|
||||||
|
@ -66,7 +66,7 @@ query ch send receive = do
|
||||||
return
|
return
|
||||||
where
|
where
|
||||||
restartable s a cont
|
restartable s a cont
|
||||||
| coProcessRestartable (coProcessSpec s) =
|
| coProcessNumRestarts (coProcessSpec s) > 0 =
|
||||||
maybe restart cont =<< catchMaybeIO a
|
maybe restart cont =<< catchMaybeIO a
|
||||||
| otherwise = cont =<< a
|
| otherwise = cont =<< a
|
||||||
restart = do
|
restart = do
|
||||||
|
@ -75,7 +75,8 @@ query ch send receive = do
|
||||||
hClose $ coProcessTo s
|
hClose $ coProcessTo s
|
||||||
hClose $ coProcessFrom s
|
hClose $ coProcessFrom s
|
||||||
void $ waitForProcess $ coProcessPid s
|
void $ waitForProcess $ coProcessPid s
|
||||||
s' <- start' (coProcessSpec s)
|
s' <- start' $ (coProcessSpec s)
|
||||||
|
{ coProcessNumRestarts = coProcessNumRestarts (coProcessSpec s) - 1 }
|
||||||
putMVar ch s'
|
putMVar ch s'
|
||||||
query ch send receive
|
query ch send receive
|
||||||
|
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -6,6 +6,8 @@ git-annex (5.20131231) UNRELEASED; urgency=medium
|
||||||
in subdirectories to go missing.
|
in subdirectories to go missing.
|
||||||
* Windows: Avoid eating stdin when running ssh to add a authorized key,
|
* Windows: Avoid eating stdin when running ssh to add a authorized key,
|
||||||
since this is used for password prompting.
|
since this is used for password prompting.
|
||||||
|
* Avoid looping if long-running git cat-file or git hash-object crashes
|
||||||
|
and keeps crashing when restarted.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Tue, 31 Dec 2013 13:41:18 -0400
|
-- Joey Hess <joeyh@debian.org> Tue, 31 Dec 2013 13:41:18 -0400
|
||||||
|
|
||||||
|
|
|
@ -12,3 +12,5 @@ This results in git-annex entering an endless loop:
|
||||||
fatal: Unable to read current working directory: No such file or directory
|
fatal: Unable to read current working directory: No such file or directory
|
||||||
fatal: Unable to read current working directory: No such file or directory
|
fatal: Unable to read current working directory: No such file or directory
|
||||||
fatal: Unable to read current working directory: No such file or directory
|
fatal: Unable to read current working directory: No such file or directory
|
||||||
|
|
||||||
|
> [[fixed|done]] --[[Joey]]
|
||||||
|
|
Loading…
Reference in a new issue