fix hang in GET from http p2p proxy

serverP2PConnection = proxyfromclientconn causes serveGet to
signalFullyConsumedByteString to it, which is what it's waiting for
This commit is contained in:
Joey Hess 2024-07-26 12:49:06 -04:00
parent 60ccbc4fe6
commit 576ec6ed71
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 8 additions and 13 deletions

View file

@ -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

View file

@ -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
}

View file

@ -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.