aboutsummaryrefslogtreecommitdiff
path: root/Remote/Helper/Ssh.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-03-08 16:21:16 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-03-08 16:56:17 -0400
commitfa3db5c4d3704da5b4a7ffeb0b637f8f5dfda616 (patch)
tree9d53e0e8e5732b108168121cb7327ca6d5caf952 /Remote/Helper/Ssh.hs
parent2fb88331a17b0800dbf7272357e885ceb90da38a (diff)
use P2P protocol for drop
Not yet used for everything else, but this is enough to verify that it works, and do some benchmarking. Some bugfixes included, which got it working. Also fallback to old actions has been verified to work correctly. Benchmarked dropping one thousand files from a ssh remote on localhost. Using the old git-annex 40.867 seconds. With the P2P protocol 9.905 seconds! This commit was sponsored by Jochen Bartl on Patreon.
Diffstat (limited to 'Remote/Helper/Ssh.hs')
-rw-r--r--Remote/Helper/Ssh.hs15
1 files changed, 8 insertions, 7 deletions
diff --git a/Remote/Helper/Ssh.hs b/Remote/Helper/Ssh.hs
index 96c419dd4..84a1ee8cc 100644
--- a/Remote/Helper/Ssh.hs
+++ b/Remote/Helper/Ssh.hs
@@ -26,7 +26,6 @@ import Config
import qualified P2P.Protocol as P2P
import qualified P2P.IO as P2P
-import Control.Concurrent.Async
import Control.Concurrent.STM
toRepo :: ConsumeStdin -> Git.Repo -> RemoteGitConfig -> SshCommand -> Annex (FilePath, [CommandParam])
@@ -192,7 +191,7 @@ closeP2PSshConnection :: P2PSshConnection -> IO P2PSshConnection
closeP2PSshConnection P2P.ClosedConnection = return P2P.ClosedConnection
closeP2PSshConnection (P2P.OpenConnection (conn, pid)) = do
P2P.closeConnection conn
- void $ async $ waitForProcess pid
+ void $ waitForProcess pid
return P2P.ClosedConnection
-- Pool of connections over ssh to git-annex-shell p2pstdio.
@@ -235,8 +234,10 @@ storeP2PSshConnection connpool conn = atomically $ modifyTVar' connpool $ \case
-- If the remote does not support the P2P protocol, that's remembered in
-- the connection pool.
openP2PSshConnection :: Remote -> P2PSshConnectionPool -> Annex (Maybe P2PSshConnection)
-openP2PSshConnection r connpool =
- git_annex_shell ConsumeStdin (repo r) "p2pstdio" [] [] >>= \case
+openP2PSshConnection r connpool = do
+ u <- getUUID
+ let ps = [Param (fromUUID u)]
+ git_annex_shell ConsumeStdin (repo r) "p2pstdio" ps [] >>= \case
Nothing -> do
liftIO $ rememberunsupported
return Nothing
@@ -254,11 +255,11 @@ openP2PSshConnection r connpool =
let conn = P2P.P2PConnection
{ P2P.connRepo = repo r
, P2P.connCheckAuth = const False
- , P2P.connIhdl = from
- , P2P.connOhdl = to
+ , P2P.connIhdl = to
+ , P2P.connOhdl = from
}
let c = P2P.OpenConnection (conn, pid)
- -- When the connection is successful, the peer
+ -- When the connection is successful, the remote
-- will send an AUTH_SUCCESS with its uuid.
tryNonAsync (P2P.runNetProto conn $ P2P.postAuth) >>= \case
Right (Right (Just theiruuid)) | theiruuid == uuid r ->