aboutsummaryrefslogtreecommitdiff
path: root/P2P
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2018-03-08 14:02:18 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2018-03-08 15:11:31 -0400
commit9c1fb9d7822efadae1027c9763e2bf573399d0b3 (patch)
tree873811f61c835336e6774cff252ab00f2da18f1f /P2P
parent6637d79273a84c83fa13bb5d797d4dcee07c363e (diff)
p2p ssh connection pools
Much like Remote.P2P, there's a pool of connections to a peer, in order to support concurrent operations. Deals with old git-annex-ssh on the remote that does not support p2pstdio, by only trying once to use it, and remembering if it's not supported. Made p2pstdio send an AUTH_SUCCESS with its uuid, which serves the dual purposes of something to detect to see that the connection is working, and a way to verify that it's connected to the right uuid. (There's a redundant uuid check since the uuid field is sent by git_annex_shell, but I anticipate that being removed later when the legacy git-annex-shell stuff gets removed.) Not entirely happy with Remote.Git.runSsh's behavior when the proto action fails. Running the fallback will work ok, but what will we do when the fallbacks later get removed? It might be better to try to reconnect, in case the connection got closed. This commit was sponsored by Boyd Stephen Smith Jr. on Patreon.
Diffstat (limited to 'P2P')
-rw-r--r--P2P/IO.hs5
-rw-r--r--P2P/Protocol.hs4
2 files changed, 9 insertions, 0 deletions
diff --git a/P2P/IO.hs b/P2P/IO.hs
index 6cdc5b7d5..8b532c7f4 100644
--- a/P2P/IO.hs
+++ b/P2P/IO.hs
@@ -10,6 +10,7 @@
module P2P.IO
( RunProto
, P2PConnection(..)
+ , ClosableConnection(..)
, stdioP2PConnection
, connectPeer
, closeConnection
@@ -51,6 +52,10 @@ data P2PConnection = P2PConnection
, connOhdl :: Handle
}
+data ClosableConnection conn
+ = OpenConnection conn
+ | ClosedConnection
+
-- P2PConnection using stdio.
stdioP2PConnection :: Git.Repo -> P2PConnection
stdioP2PConnection g = P2PConnection
diff --git a/P2P/Protocol.hs b/P2P/Protocol.hs
index c750ae6ff..4acbaadef 100644
--- a/P2P/Protocol.hs
+++ b/P2P/Protocol.hs
@@ -250,6 +250,10 @@ $(makeFree ''LocalF)
auth :: UUID -> AuthToken -> Proto (Maybe UUID)
auth myuuid t = do
net $ sendMessage (AUTH myuuid t)
+ postAuth
+
+postAuth :: Proto (Maybe UUID)
+postAuth = do
r <- net receiveMessage
case r of
AUTH_SUCCESS theiruuid -> return $ Just theiruuid