async exception safety
Masking ensures that EndStderrHandler gets written, so the helper threads shut down. However, nothing currently guarantees that calls to closeP2PSshConnection are async exception safe, so made a note about it. At this point, I've audited all calls to async, and made them all async exception safe, except for ones in the assistant, and a few in leaf commands (remotedaemon, enable-tor, multicast, p2p) which don't need to be.
This commit is contained in:
parent
a477f7253c
commit
dca19099a9
2 changed files with 11 additions and 8 deletions
|
@ -198,11 +198,13 @@ data StderrHandlerState = DiscardStderr | DisplayStderr | EndStderrHandler
|
||||||
|
|
||||||
closeP2PSshConnection :: P2PSshConnection -> IO (P2PSshConnection, Maybe ExitCode)
|
closeP2PSshConnection :: P2PSshConnection -> IO (P2PSshConnection, Maybe ExitCode)
|
||||||
closeP2PSshConnection P2P.ClosedConnection = return (P2P.ClosedConnection, Nothing)
|
closeP2PSshConnection P2P.ClosedConnection = return (P2P.ClosedConnection, Nothing)
|
||||||
closeP2PSshConnection (P2P.OpenConnection (_st, conn, pid, stderrhandlerst)) = do
|
closeP2PSshConnection (P2P.OpenConnection (_st, conn, pid, stderrhandlerst)) =
|
||||||
P2P.closeConnection conn
|
-- mask async exceptions, avoid cleanup being interrupted
|
||||||
atomically $ writeTVar stderrhandlerst EndStderrHandler
|
mask $ const $ do
|
||||||
exitcode <- waitForProcess pid
|
P2P.closeConnection conn
|
||||||
return (P2P.ClosedConnection, Just exitcode)
|
atomically $ writeTVar stderrhandlerst EndStderrHandler
|
||||||
|
exitcode <- waitForProcess pid
|
||||||
|
return (P2P.ClosedConnection, Just exitcode)
|
||||||
|
|
||||||
-- Pool of connections over ssh to git-annex-shell p2pstdio.
|
-- Pool of connections over ssh to git-annex-shell p2pstdio.
|
||||||
type P2PSshConnectionPool = TVar (Maybe P2PSshConnectionPoolState)
|
type P2PSshConnectionPool = TVar (Maybe P2PSshConnectionPoolState)
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
date="2020-06-04T19:39:23Z"
|
date="2020-06-04T19:39:23Z"
|
||||||
content="""
|
content="""
|
||||||
I've converted everything to withCreateProcess, except for process pools
|
I've converted everything to withCreateProcess, except for process pools
|
||||||
(P2P.IO, Assistant.TransferrerPool, Utility.CoProcess, and Remote.External),
|
(P2P.IO, Assistant.TransferrerPool, Utility.CoProcess, Remote.External,
|
||||||
which need to be handled as discussed in comment 8. And also
|
and P2PSshConnectionPool), which need to be handled as discussed in
|
||||||
Git.Command.pipeReadLazy may (or may not) need to be converted.
|
comment 8. And also Git.Command.pipeReadLazy may (or may not) need to be
|
||||||
|
converted.
|
||||||
|
|
||||||
During this conversion, I did not watch out for interactive processes that
|
During this conversion, I did not watch out for interactive processes that
|
||||||
might block on a password, so any timeout would also affect them. Really,
|
might block on a password, so any timeout would also affect them. Really,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue