diff --git a/Annex/Cluster.hs b/Annex/Cluster.hs index 0f748ef732..e43cc737bd 100644 --- a/Annex/Cluster.hs +++ b/Annex/Cluster.hs @@ -51,9 +51,8 @@ proxyCluster clusteruuid proxydone servermode clientside protoerrhandler = do -- known at this point, and would be too expensive to -- determine. Instead, pick the newest protocol version -- that we and the client both speak. The proxy code - -- checks protocol versions when operating on multiple - -- nodes, and allows nodes to have different protocol - -- versions. + -- checks protocol versions of remotes, so nodes can + -- have different protocol versions. let protocolversion = min maxProtocolVersion clientmaxversion sendClientProtocolVersion clientside othermsg protocolversion (getclientbypass protocolversion) (protoerrhandler noop) @@ -76,7 +75,7 @@ proxyCluster clusteruuid proxydone servermode clientside protoerrhandler = do , proxyUUID = fromClusterUUID clusteruuid , proxySelector = selectnode , proxyConcurrencyConfig = concurrencyconfig - , proxyProtocolVersion = protocolversion + , proxyClientProtocolVersion = protocolversion } proxy proxydone proxyparams othermsg (protoerrhandler closenodes) diff --git a/Command/P2PStdIO.hs b/Command/P2PStdIO.hs index dfc4499601..cc5d675e53 100644 --- a/Command/P2PStdIO.hs +++ b/Command/P2PStdIO.hs @@ -84,7 +84,7 @@ performProxy clientuuid servermode r = do , proxyUUID = Remote.uuid r , proxySelector = singleProxySelector remoteside , proxyConcurrencyConfig = concurrencyconfig - , proxyProtocolVersion = protocolversion + , proxyClientProtocolVersion = protocolversion } let runproxy othermsg' = proxy closer proxyparams othermsg' errhandler diff --git a/P2P/Http/State.hs b/P2P/Http/State.hs index 377357f7f9..ac9898f8c8 100644 --- a/P2P/Http/State.hs +++ b/P2P/Http/State.hs @@ -346,9 +346,8 @@ proxyConnection relv connparams workerpool proxyconn = do inAnnexWorker' workerpool $ do proxystate <- liftIO Proxy.mkProxyState concurrencyconfig <- Proxy.noConcurrencyConfig - -- TODO run remote protocol to get its version and - -- take minimum of that and connectionProtocolVersion - let protocolversion = connectionProtocolVersion connparams + let protocolversion = min remoteprotocolversion $ + connectionProtocolVersion connparams let proxyparams = Proxy.ProxyParams { Proxy.proxyMethods = mkProxyMethods , Proxy.proxyState = proxystate @@ -358,7 +357,7 @@ proxyConnection relv connparams workerpool proxyconn = do , Proxy.proxySelector = Proxy.singleProxySelector $ proxyConnectionRemoteSide proxyconn , Proxy.proxyConcurrencyConfig = concurrencyconfig - , Proxy.proxyProtocolVersion = protocolversion + , Proxy.proxyClientProtocolVersion = protocolversion } let proxy mrequestmessage = case mrequestmessage of Just requestmessage -> do @@ -516,8 +515,8 @@ openProxyConnectionToRemote -> [UUID] -> Remote -> IO (Either SomeException ProxyConnection) -openProxyConnectionToRemote workerpool protoversion bypass remote = - inAnnexWorker' workerpool (proxyRemoteSide protoversion bypass' remote) >>= \case +openProxyConnectionToRemote workerpool clientmaxversion bypass remote = + inAnnexWorker' workerpool (proxyRemoteSide clientmaxversion bypass' remote) >>= \case Left ex -> return (Left ex) Right remoteside -> return $ Right $ ProxyConnection (Remote.uuid remote) remoteside diff --git a/P2P/Proxy.hs b/P2P/Proxy.hs index d1d6aa860b..e78ef5a12e 100644 --- a/P2P/Proxy.hs +++ b/P2P/Proxy.hs @@ -208,10 +208,9 @@ data ProxyParams = ProxyParams , proxyUUID :: UUID , proxySelector :: ProxySelector , proxyConcurrencyConfig :: ConcurrencyConfig - , proxyProtocolVersion :: ProtocolVersion - -- ^ Protocol version being spoken between the proxy and the - -- client. When there are multiple remotes, some may speak an - -- earlier version. + , proxyClientProtocolVersion :: ProtocolVersion + -- ^ The remote(s) may speak an earlier version, or the same + -- version, but not a later version. } {- Proxy between the client and the remote. This picks up after @@ -452,7 +451,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle protoerrhandler requestcomplete $ client $ net $ sendMessage $ let nonplussed = all (== proxyUUID proxyparams) us - || proxyProtocolVersion proxyparams < ProtocolVersion 2 + || proxyClientProtocolVersion proxyparams < ProtocolVersion 2 in if all (maybe False (fst . fst)) v' then if nonplussed then SUCCESS @@ -496,7 +495,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle relayDATAFinish (runRemoteSide remoteside) client $ relayonemessage client (runRemoteSide remoteside) $ const requestcomplete - + relayPUT remoteside k len = relayDATAStart (runRemoteSide remoteside) $ relayDATACore len client (runRemoteSide remoteside) $ relayDATAFinish client (runRemoteSide remoteside) $ @@ -536,7 +535,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle _ -> False l <- forMC (proxyConcurrencyConfig proxyparams) remotesides initiate if all alreadyhave l - then if proxyProtocolVersion proxyparams < ProtocolVersion 2 + then if proxyClientProtocolVersion proxyparams < ProtocolVersion 2 then protoerrhandler requestcomplete $ client $ net $ sendMessage ALREADY_HAVE else protoerrhandler requestcomplete $ @@ -621,7 +620,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle | otherwise = relayonemessage x y (\_ () -> sendsuccessfailure) relayDATAFinishMulti k rs - | proxyProtocolVersion proxyparams == ProtocolVersion 0 = + | proxyProtocolVersion proxyparams == ProtocolVersion 0 = finish $ net receiveMessage | otherwise = flip protoerrhandler (client $ net $ receiveMessage) $ @@ -646,7 +645,7 @@ proxyRequest proxydone proxyparams requestcomplete requestmessage protoerrhandle case concat (catMaybes storeduuids) of [] -> FAILURE us - | proxyProtocolVersion proxyparams < ProtocolVersion 2 -> SUCCESS + | proxyClientProtocolVersion proxyparams < ProtocolVersion 2 -> SUCCESS | otherwise -> SUCCESS_PLUS us -- The associated file received from the P2P protocol diff --git a/doc/todo/git-annex_proxies.mdwn b/doc/todo/git-annex_proxies.mdwn index 1eed6540c7..947114a703 100644 --- a/doc/todo/git-annex_proxies.mdwn +++ b/doc/todo/git-annex_proxies.mdwn @@ -30,9 +30,6 @@ Planned schedule of work: * http server proxying hangs on git-annex copy --to it -* http server proxying needs to get the version negotiated with the proxied - remote and feed that into the proxy function. - * test http server proxying with special remotes * http server proxying needs to reuse connections to special remotes,