add connProcess to P2PConnection
When using the new generic P2P transport to open an outgoing connection to a peer, this will hold the pid of the git-annex-p2p-<netname> command. closeConnection simply waits for it. Rather than relying on garbage collection of the closed handles to close it. In Remote.Helper.Ssh, connProcess is set to Nothing, even though there is a similar process being used there. That code stores the pid in OpenConnection instead, and handles waiting for it itself. A bit ugly, but not worth cleaning up at this point, maybe later.
This commit is contained in:
parent
f631bc9e56
commit
a6f8248465
6 changed files with 13 additions and 2 deletions
|
@ -97,6 +97,7 @@ data P2PConnection = P2PConnection
|
|||
, connCheckAuth :: (AuthToken -> Bool)
|
||||
, connIhdl :: P2PHandle
|
||||
, connOhdl :: P2PHandle
|
||||
, connProcess :: Maybe ProcessHandle
|
||||
, connIdent :: ConnIdent
|
||||
}
|
||||
|
||||
|
@ -115,6 +116,7 @@ stdioP2PConnection g = P2PConnection
|
|||
, connCheckAuth = const False
|
||||
, connIhdl = P2PHandle stdin
|
||||
, connOhdl = P2PHandle stdout
|
||||
, connProcess = Nothing
|
||||
, connIdent = ConnIdent Nothing
|
||||
}
|
||||
|
||||
|
@ -129,6 +131,7 @@ stdioP2PConnectionDupped g = do
|
|||
, connCheckAuth = const False
|
||||
, connIhdl = P2PHandle readh
|
||||
, connOhdl = P2PHandle writeh
|
||||
, connProcess = Nothing
|
||||
, connIdent = ConnIdent Nothing
|
||||
}
|
||||
|
||||
|
@ -141,6 +144,7 @@ connectPeer g (TorAnnex onionaddress onionport) = do
|
|||
, connCheckAuth = const False
|
||||
, connIhdl = P2PHandle h
|
||||
, connOhdl = P2PHandle h
|
||||
, connProcess = Nothing
|
||||
, connIdent = ConnIdent Nothing
|
||||
}
|
||||
|
||||
|
@ -148,6 +152,9 @@ closeConnection :: P2PConnection -> IO ()
|
|||
closeConnection conn = do
|
||||
closehandle (connIhdl conn)
|
||||
closehandle (connOhdl conn)
|
||||
case connProcess conn of
|
||||
Nothing -> noop
|
||||
Just ph -> void $ waitForProcess ph
|
||||
where
|
||||
closehandle (P2PHandle h) = hClose h
|
||||
closehandle (P2PHandleTMVar _ _ closedv) =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue