Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/http2-manager/src/HTTP2/Client/Manager.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module HTTP2.Client.Manager
defaultHttp2Manager,
http2ManagerWithSSLCtx,
withHTTP2Request,
withHTTP2RequestOnSingleUseConn,
connectIfNotAlreadyConnected,
ConnectionAlreadyClosed (..),
disconnectTarget,
Expand Down
9 changes: 9 additions & 0 deletions libs/http2-manager/src/HTTP2/Client/Manager/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ withHTTP2Request mgr target req k = do
conn <- getOrMakeConnection mgr target
sendRequestWithConnection conn req k

-- | Temporary workaround for https://github.com/kazu-yamamoto/http2/issues/102
withHTTP2RequestOnSingleUseConn :: Http2Manager -> Target -> HTTP2.Request -> (HTTP2.Response -> IO a) -> IO a
withHTTP2RequestOnSingleUseConn Http2Manager {..} target req k = do
sendReqMVar <- newEmptyMVar
thread <- liftIO . async $ startPersistentHTTP2Connection sslContext target cacheLimit sslRemoveTrailingDot tcpConnectionTimeout sendReqMVar
let newConn = HTTP2Conn thread (putMVar sendReqMVar CloseConnection) sendReqMVar
sendRequestWithConnection newConn req $ \resp -> do
k resp <* disconnect newConn

-- | Connects to a server if it is not already connected, useful when making
-- many concurrent requests. This way the first few requests don't have to fight
-- for making a connection This way the first few requests don't have to fight
Expand Down
2 changes: 1 addition & 1 deletion services/federator/src/Federator/Remote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ interpretRemote = interpret $ \case
resp <- mapError (RemoteError target pathT) . (fromEither @FederatorClientHTTP2Error =<<) . embed $
Codensity $ \k ->
E.catches
(H2Manager.withHTTP2Request mgr (True, hostname, fromIntegral port) req' (consumeStreamingResponseWith $ k . Right))
(H2Manager.withHTTP2RequestOnSingleUseConn mgr (True, hostname, fromIntegral port) req' (consumeStreamingResponseWith $ k . Right))
[ E.Handler $ k . Left,
E.Handler $ k . Left . FederatorClientTLSException,
E.Handler $ k . Left . FederatorClientHTTP2Exception,
Expand Down