convert to withCreateProcess for async exception safety
Not yet 100% done, so far I've grepped for waitForProcess and converted everything that uses that to start the process with withCreateProcess. Except for some things like P2P.IO and Assistant.TransferrerPool, and Utility.CoProcess, that manage a pool of processes. See #2 in https://git-annex.branchable.com/todo/more_extensive_retries_to_mask_transient_failures/#comment-209f8a8c38e63fb3a704e1282cb269c7 for how those will need to be dealt with. checkSuccessProcess, ignoreFailureProcess, and forceSuccessProcess calls waitForProcess, so callers of them will also need to be dealt with, and have not been yet.
This commit is contained in:
parent
1ee5919d1e
commit
92f775eba0
9 changed files with 68 additions and 65 deletions
|
@ -37,14 +37,15 @@ transportUsingCmd cmd params rr@(RemoteRepo r gc) url h@(TransportHandle (LocalR
|
|||
|
||||
transportUsingCmd' :: FilePath -> [CommandParam] -> Transport
|
||||
transportUsingCmd' cmd params (RemoteRepo r gc) url transporthandle ichan ochan =
|
||||
robustConnection 1 $ do
|
||||
(Just toh, Just fromh, Just errh, pid) <-
|
||||
createProcess (proc cmd (toCommand params))
|
||||
{ std_in = CreatePipe
|
||||
, std_out = CreatePipe
|
||||
, std_err = CreatePipe
|
||||
}
|
||||
|
||||
robustConnection 1 $ withCreateProcess p go
|
||||
where
|
||||
p = (proc cmd (toCommand params))
|
||||
{ std_in = CreatePipe
|
||||
, std_out = CreatePipe
|
||||
, std_err = CreatePipe
|
||||
}
|
||||
|
||||
go (Just toh) (Just fromh) (Just errh) pid = do
|
||||
-- Run all threads until one finishes and get the status
|
||||
-- of the first to finish. Cancel the rest.
|
||||
status <- catchDefaultIO (Right ConnectionClosed) $
|
||||
|
@ -58,7 +59,8 @@ transportUsingCmd' cmd params (RemoteRepo r gc) url transporthandle ichan ochan
|
|||
void $ waitForProcess pid
|
||||
|
||||
return $ either (either id id) id status
|
||||
where
|
||||
go _ _ _ _ = error "internal"
|
||||
|
||||
send msg = atomically $ writeTChan ochan msg
|
||||
|
||||
fetch = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue