From b508ea5f95269761794731dbb8a1e4f7b21c786d Mon Sep 17 00:00:00 2001 From: Paolo Capriotti Date: Mon, 29 Nov 2021 11:28:52 +0100 Subject: [PATCH] Make sure connection preface is always sent first This fixes a race condition in the client between the `frameSender` thread and the main thread, in the case where a SETTINGS frame is sent in response to a server SETTINGS frame before the connection preface has had a chance to be sent. --- Network/HTTP2/Client/Run.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Network/HTTP2/Client/Run.hs b/Network/HTTP2/Client/Run.hs index 49e782af..f13f023f 100644 --- a/Network/HTTP2/Client/Run.hs +++ b/Network/HTTP2/Client/Run.hs @@ -24,11 +24,11 @@ run ClientConfig{..} conf@Config{..} client = do clientInfo <- newClientInfo scheme authority cacheLimit ctx <- newContext clientInfo mgr <- start confTimeoutManager + exchangeSettings conf ctx tid0 <- forkIO $ frameReceiver ctx confReadN -- fixme: if frameSender is terminated but the main thread is alive, -- what will happen? tid1 <- forkIO $ frameSender ctx conf mgr - exchangeSettings conf ctx client (sendRequest ctx scheme authority) `E.finally` do stop mgr killThread tid0