have onLocal stop any coprocesses, not only cat-file

I have not seen any other coprocesses being started, but let's avoid
problems if any do for whatever reason.
This commit is contained in:
Joey Hess 2017-02-17 14:30:18 -04:00
parent d074532aff
commit 00464fbed7
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
2 changed files with 12 additions and 10 deletions

View file

@ -56,14 +56,16 @@ dupState = do
- Also closes various handles in it. -}
mergeState :: AnnexState -> Annex ()
mergeState st = do
st' <- liftIO $ snd <$> run st closehandles
st' <- liftIO $ snd <$> run st stopCoProcesses
forM_ (M.toList $ Annex.cleanup st') $
uncurry addCleanup
Annex.Queue.mergeFrom st'
changeState $ \s -> s { errcounter = errcounter s + errcounter st' }
where
closehandles = do
catFileStop
checkAttrStop
hashObjectStop
checkIgnoreStop
{- Stops all long-running git query processes. -}
stopCoProcesses :: Annex ()
stopCoProcesses = do
catFileStop
checkAttrStop
hashObjectStop
checkIgnoreStop

View file

@ -54,9 +54,9 @@ import qualified Remote.P2P
import P2P.Address
import Annex.Path
import Creds
import Annex.CatFile
import Messages.Progress
import Types.NumCopies
import Annex.Concurrent
import Control.Concurrent
import Control.Concurrent.MSampleVar
@ -613,7 +613,7 @@ repairRemote r a = return $ do
{- Runs an action from the perspective of a local remote.
-
- The AnnexState is cached for speed and to avoid resource leaks.
- However, catFileStop is called to avoid git-cat-file processes hanging
- However, coprocesses are stopped to avoid git processes hanging
- around on removable media.
-
- The repository's git-annex branch is not updated, as an optimisation.
@ -637,7 +637,7 @@ onLocal r a = do
go st a' = do
curro <- Annex.getState Annex.output
(ret, st') <- liftIO $ Annex.run (st { Annex.output = curro }) $
catFileStop `after` a'
stopCoProcesses `after` a'
cache st'
return ret