From 576ec6ed712ff42b6f10e65a3ed877bfdbbf5eac Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 26 Jul 2024 12:49:06 -0400 Subject: [PATCH] fix hang in GET from http p2p proxy serverP2PConnection = proxyfromclientconn causes serveGet to signalFullyConsumedByteString to it, which is what it's waiting for --- P2P/Http/Server.hs | 7 ++----- P2P/Http/State.hs | 10 +++++----- doc/todo/git-annex_proxies.mdwn | 4 +--- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/P2P/Http/Server.hs b/P2P/Http/Server.hs index f6e77f9180..42e06d3ee7 100644 --- a/P2P/Http/Server.hs +++ b/P2P/Http/Server.hs @@ -119,11 +119,8 @@ serveGet st su apiver (B64Key k) cu bypass baf startat sec auth = do let storer _offset len = sendContentWith $ \bs -> liftIO $ do atomically $ putTMVar bsv (len, bs) atomically $ takeTMVar endv - case serverP2PConnection conn of - Just c -> - signalFullyConsumedByteString $ - connOhdl c - Nothing -> noop + signalFullyConsumedByteString $ + connOhdl $ serverP2PConnection conn return $ \v -> do liftIO $ atomically $ putTMVar validityv v return True diff --git a/P2P/Http/State.hs b/P2P/Http/State.hs index 569853f7a7..377357f7f9 100644 --- a/P2P/Http/State.hs +++ b/P2P/Http/State.hs @@ -248,7 +248,7 @@ withP2PConnections workerpool a = do data P2PConnectionPair = P2PConnectionPair { clientRunState :: RunState , clientP2PConnection :: P2PConnection - , serverP2PConnection :: Maybe P2PConnection + , serverP2PConnection :: P2PConnection , releaseP2PConnection :: IO () -- ^ Releases a P2P connection, which can be reused for other -- requests. @@ -288,7 +288,7 @@ localP2PConnectionPair connparams relv startworker = do return $ Right $ P2PConnectionPair { clientRunState = clientrunst , clientP2PConnection = clientconn - , serverP2PConnection = Just serverconn + , serverP2PConnection = serverconn , releaseP2PConnection = releaseconn , closeP2PConnection = releaseconn } @@ -338,8 +338,8 @@ proxyConnection -> ProxyConnection -> IO (Either ConnectionProblem P2PConnectionPair) proxyConnection relv connparams workerpool proxyconn = do - (clientconn, proxyfromclientconn) <- mkP2PConnectionPair connparams - ("http client", "proxy") + (clientconn, proxyfromclientconn) <- + mkP2PConnectionPair connparams ("http client", "proxy") clientrunst <- mkClientRunState connparams proxyfromclientrunst <- mkClientRunState connparams asyncworker <- async $ @@ -377,7 +377,7 @@ proxyConnection relv connparams workerpool proxyconn = do return $ Right $ P2PConnectionPair { clientRunState = clientrunst , clientP2PConnection = clientconn - , serverP2PConnection = Nothing + , serverP2PConnection = proxyfromclientconn , releaseP2PConnection = releaseconn True , closeP2PConnection = releaseconn False } diff --git a/doc/todo/git-annex_proxies.mdwn b/doc/todo/git-annex_proxies.mdwn index c7d054d1e4..1eed6540c7 100644 --- a/doc/todo/git-annex_proxies.mdwn +++ b/doc/todo/git-annex_proxies.mdwn @@ -28,9 +28,7 @@ Planned schedule of work: ## work notes -* http server proxying hangs when git-annex copy --to it, - and git-annex get --from it, maybe other - times. Need to fully test. +* 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. -- 2.30.2