Skip to content

Commit

Permalink
Revert "[chore] update warp"
Browse files Browse the repository at this point in the history
This reverts commit 0d87411.
  • Loading branch information
MangoIV committed Jun 19, 2024
1 parent 0d87411 commit 2f2f13e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 80 deletions.
14 changes: 4 additions & 10 deletions libs/http2-manager/src/HTTP2/Client/Manager/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Control.Monad
import Control.Monad.IO.Class
import Data.ByteString
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C8
import Data.IORef
import Data.Map
import qualified Data.Map as Map
Expand Down Expand Up @@ -292,9 +291,9 @@ startPersistentHTTP2Connection ::
startPersistentHTTP2Connection ctx (tlsEnabled, hostname, port) cl removeTrailingDot tcpConnectTimeout sendReqMVar = do
liveReqs <- newIORef mempty
let clientConfig =
HTTP2.defaultClientConfig
HTTP2.ClientConfig
{ HTTP2.scheme = if tlsEnabled then "https" else "http",
HTTP2.authority = C8.unpack hostname,
HTTP2.authority = hostname,
HTTP2.cacheLimit = cl
}
-- Sends error to requests which show up too late, i.e. after the
Expand Down Expand Up @@ -334,7 +333,7 @@ startPersistentHTTP2Connection ctx (tlsEnabled, hostname, port) cl removeTrailin
bracket connectTCPWithTimeout NS.close $ \sock -> do
bracket (mkTransport sock transportConfig) cleanupTransport $ \transport ->
bracket (allocHTTP2Config transport) HTTP2.freeSimpleConfig $ \http2Cfg -> do
let runAction = HTTP2.run clientConfig http2Cfg $ \sendReq _aux -> do
let runAction = HTTP2.run clientConfig http2Cfg $ \sendReq -> do
handleRequests liveReqs sendReq
-- Any request threads still hanging about after 'runAction' finishes
-- are canceled with 'ConnectionAlreadyClosed'.
Expand Down Expand Up @@ -452,9 +451,6 @@ allocHTTP2Config (SecureTransport ssl) = do
error "openssl: SSL.read returned more bytes than asked for, this is probably a bug"
| otherwise ->
readData (acc <> chunk) (n - chunkLen)
let s = fromMaybe (error "http2-manager: SSL without socket") $ SSL.sslSocket ssl
mysa <- NS.getSocketName s
peersa <- NS.getPeerName s

pure
HTTP2.Config
Expand All @@ -463,7 +459,5 @@ allocHTTP2Config (SecureTransport ssl) = do
HTTP2.confSendAll = SSL.write ssl,
HTTP2.confReadN = readData mempty,
HTTP2.confPositionReadMaker = HTTP2.defaultPositionReadMaker,
HTTP2.confTimeoutManager = timmgr,
HTTP2.confMySockAddr = mysa,
HTTP2.confPeerSockAddr = peersa
HTTP2.confTimeoutManager = timmgr
}
14 changes: 3 additions & 11 deletions libs/http2-manager/test/Test/HTTP2/Client/ManagerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import qualified Data.ByteString.Lazy.Char8 as LBS
import Data.IORef
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe (fromMaybe, isJust)
import Data.Maybe (isJust)
import Data.Streaming.Network (bindPortTCP, bindRandomPortTCP)
import Data.Unique
import Foreign.Marshal.Alloc (mallocBytes)
Expand All @@ -33,10 +33,8 @@ import HTTP2.Client.Manager.Internal
import Network.HTTP.Types
import qualified Network.HTTP2.Client as Client
import qualified Network.HTTP2.Client as HTTP2
import Network.HTTP2.Server (defaultServerConfig)
import qualified Network.HTTP2.Server as Server
import Network.Socket
import qualified Network.Socket as NS
import qualified OpenSSL.Session as SSL
import System.Random (randomRIO)
import qualified System.TimeManager
Expand Down Expand Up @@ -295,20 +293,14 @@ allocServerConfig (Right ssl) = do
error "openssl: SSL.read returned more bytes than asked for, this is probably a bug"
| otherwise ->
readData (prevChunk <> chunk) (n - chunkLen)

let s = fromMaybe (error "http2-manager: SSL without socket") $ SSL.sslSocket ssl
mysa <- NS.getSocketName s
peersa <- NS.getPeerName s
pure
Server.Config
{ Server.confWriteBuffer = buf,
Server.confBufferSize = bufsize,
Server.confSendAll = SSL.write ssl,
Server.confReadN = readData mempty,
Server.confPositionReadMaker = Server.defaultPositionReadMaker,
Server.confTimeoutManager = timmgr,
Server.confMySockAddr = mysa,
Server.confPeerSockAddr = peersa
Server.confTimeoutManager = timmgr
}

testServerOnSocket :: Maybe SSL.SSLContext -> Socket -> IORef Int -> IORef (Map Unique (Async ())) -> IO ()
Expand All @@ -330,7 +322,7 @@ testServerOnSocket mCtx listenSock connsCounter conns = do
cleanup cfg = do
Server.freeSimpleConfig cfg `finally` (shutdownSSL `finally` close sock)
thread <- async $ bracket (allocServerConfig serverCfgParam) cleanup $ \cfg -> do
Server.run defaultServerConfig cfg testServer `finally` modifyIORef conns (Map.delete connKey)
Server.run cfg testServer `finally` modifyIORef conns (Map.delete connKey)
modifyIORef conns $ Map.insert connKey thread

testServer :: Server.Request -> Server.Aux -> (Server.Response -> [Server.PushPromise] -> IO ()) -> IO ()
Expand Down
2 changes: 1 addition & 1 deletion libs/wire-api-federation/src/Wire/API/Federation/Client.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ instance VersionedMonad Version (FederatorClient c) where
liftCodensity :: Codensity IO a -> FederatorClient c a
liftCodensity = FederatorClient . lift . lift . lift

headersFromTable :: HTTP2.TokenHeaderTable -> [HTTP.Header]
headersFromTable :: HTTP2.HeaderTable -> [HTTP.Header]
headersFromTable (headerList, _) = flip map headerList $ first HTTP2.tokenKey

-- This opens a new http2 connection. Using a http2-manager leads to this problem https://wearezeta.atlassian.net/browse/WPB-4787
Expand Down
66 changes: 10 additions & 56 deletions nix/haskell-pins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -258,30 +258,7 @@ let
hash = "sha256-E35PVxi/4iJFfWts3td52KKZKQt4dj9KFP3SvWG77Cc=";
};
};

# open PR https://github.com/yesodweb/wai/pull/958 for sending connection: close when closing connection
warp = {
packages.warp = "warp";
src = pkgs.fetchFromGitHub {
owner = "yesodweb";
repo = "wai";
rev = "8b20c9db265a202a2c7ba2a9ec8786a1ee59957b";
hash = "sha256-fKUSiRl38FKY1gFSmbksktoqoLfQrDxRRWEh4k+RRW4=";
};
};

# this contains an important fix to the initialization of the window size
# and should be switched to upstream as soon as we can
http2 = {
src = pkgs.fetchFromGitHub {
owner = "kazu-yamamoto";
repo = "http2";
rev = "80921ad15fac05715ede7063d57585d4e7049f99";
hash = "sha256-AQPZzx0SiIPbWG2AguGcDITTQLKW9OX1qxmiS+wrHN8=";
};
};
};

hackagePins = {
# Major re-write upstream, we should get rid of this dependency rather than
# adapt to upstream, this will go away when completing servantification.
Expand All @@ -290,38 +267,16 @@ let
sha256 = "sha256-DSMckKIeVE/buSMg8Mq+mUm1bYPYB7veA11Ns7vTBbc=";
};

# start pinned dependencies for http2
http-semantics = {
version = "0.1.1";
sha256 = "sha256-znxplxXjPWNrGR7//7e6HS9CaS1ID/aXUhRYfWakTWU=";
};

network-run = {
version = "0.3.0";
sha256 = "sha256-FP2GZKwacC+TLLwEIVgKBtnKplYPf5xOIjDfvlbQV0o=";
};
time-manager = {
version = "0.1.0";
sha256 = "sha256-WRe9LZrOIPJVBFk0vMN2IMoxgP0a0psQCiCiOFWJc74=";
};
auto-update = {
version = "0.2.0";
sha256 = "sha256-d/0IDjaaCLz8tlx88z8Ew8ol9PrSRPVWaUwTbim70yE=";
};

network-control = {
version = "0.1.0";
sha256 = "sha256-D6pKb6+0Pr08FnObGbXBVMv04ys3N731p7U+GYH1oEg=";
http2 = {
version = "4.1.4";
sha256 = "sha256-r4Bu0vourKMkBO1cPeJVszSbAqHopmkv9EeTHcaTfuo=";
};
# end pinned dependencies for http2

# pinned for warp
warp-tls = {
version = "3.4.5";
sha256 = "sha256-3cDi/+n7wHfcWT/iFWAsGdLYXtKYXmvzolDt+ACJnaM=";
# warp is not compatible with
warp = {
version = "3.3.30";
sha256 = "sha256-VrK27a2wFtezh9qabcXGe2tw9EwBmI8mKwmpCtXq9rc=";
};
# end pinned for warp

# PR: https://github.com/wireapp/wire-server/pull/4027
HsOpenSSL = {
version = "0.11.7.7";
Expand Down Expand Up @@ -356,12 +311,11 @@ let
gitPins;
# AttrSet
hackagePackages = lib.attrsets.mapAttrs
(pkg: args:
(pkg: { version, sha256 }:
hself.callHackageDirect
{
ver = args.version;
sha256 = args.sha256 or "";
inherit pkg;
ver = version;
inherit pkg sha256;
}
{ }
)
Expand Down
16 changes: 14 additions & 2 deletions nix/manual-overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,20 @@ hself: hsuper: {
tls = hsuper.tls_2_0_5;
tls-session-manager = hsuper.tls-session-manager_0_0_5;

# warp requires curl in its testsuite
warp = hlib.addTestToolDepends hsuper.warp [ curl ];
# for warp (and its transitive deps)
# we have a PR open https://github.com/yesodweb/wai/pull/958
# unfortunately, because of breakage in http2, our fork has moved beyond what
# we can use in wire itself, hence the patch
# the version of warp is pinned in ./haskell-pins.nix
warp = hlib.addTestToolDepends
(hlib.appendPatches hsuper.warp [
(fetchpatch {
url = "https://github.com/yesodweb/wai/commit/ef993a357822d9bc2a2040afcb656b31c378491c.patch";
stripLen = 1;
sha256 = "sha256-rv/ujqyBmpsChQg2uS3/HUgQZCA3SzBiF8kUnZJN0xs=";
})
]) [ curl ];
# end for warp

# -----------------
# flags and patches
Expand Down

0 comments on commit 2f2f13e

Please sign in to comment.