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
|
@ -90,6 +90,7 @@ proxySpecialRemoteSide clientmaxversion r = mkRemoteSide r $ do
|
|||
, connCheckAuth = const False
|
||||
, connIhdl = P2PHandleTMVar ihdl (Just iwaitv) iclosedv
|
||||
, connOhdl = P2PHandleTMVar ohdl (Just owaitv) oclosedv
|
||||
, connProcess = Nothing
|
||||
, connIdent = ConnIdent (Just (Remote.name r))
|
||||
}
|
||||
let closeremoteconn = do
|
||||
|
|
|
@ -138,6 +138,7 @@ checkHiddenService = bracket setup cleanup go
|
|||
, connCheckAuth = const False
|
||||
, connIhdl = P2PHandle h
|
||||
, connOhdl = P2PHandle h
|
||||
, connProcess = Nothing
|
||||
, connIdent = ConnIdent Nothing
|
||||
}
|
||||
runst <- mkRunState Client
|
||||
|
|
|
@ -406,10 +406,10 @@ mkP2PConnectionPair connparams (n1, n2) = do
|
|||
(if connectionWaitVar connparams then Just wait2 else Nothing)
|
||||
closed2
|
||||
let clientconn = P2PConnection Nothing
|
||||
(const True) h2 h1
|
||||
(const True) h2 h1 Nothing
|
||||
(ConnIdent (Just n1))
|
||||
let serverconn = P2PConnection Nothing
|
||||
(const True) h1 h2
|
||||
(const True) h1 h2 Nothing
|
||||
(ConnIdent (Just n2))
|
||||
return (clientconn, serverconn)
|
||||
|
||||
|
|
|
@ -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) =
|
||||
|
|
|
@ -270,6 +270,7 @@ openP2PShellConnection' r maxprotoversion bypass = do
|
|||
, P2P.connCheckAuth = const False
|
||||
, P2P.connIhdl = P2P.P2PHandle to
|
||||
, P2P.connOhdl = P2P.P2PHandle from
|
||||
, P2P.connProcess = Nothing
|
||||
, P2P.connIdent = P2P.ConnIdent $
|
||||
Just $ "git-annex-shell connection " ++ show pidnum
|
||||
}
|
||||
|
|
|
@ -115,6 +115,7 @@ serveClient th@(TransportHandle _ _ rd) u r q = bracket setup cleanup start
|
|||
, connCheckAuth = (`isAllowedAuthToken` allowed)
|
||||
, connIhdl = P2PHandle h
|
||||
, connOhdl = P2PHandle h
|
||||
, connProcess = Nothing
|
||||
, connIdent = ConnIdent $ Just "tor remotedaemon"
|
||||
}
|
||||
-- not really Client, but we don't know their uuid yet
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue