Skip to content

Commit

Permalink
timeout for handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Nov 5, 2024
1 parent e901414 commit 2baca8b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions warp-tls/Network/Wai/Handler/WarpTLS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ httpOverTls
-> S.ByteString
-> params
-> IO (Connection, Transport)
httpOverTls TLSSettings{..} _set s bs0 params =
httpOverTls TLSSettings{..} set s bs0 params =
makeConn `onException` close s
where
makeConn = do
Expand All @@ -359,9 +359,14 @@ httpOverTls TLSSettings{..} _set s bs0 params =
let recvN = wrappedRecvN rawRecvN
ctx <- TLS.contextNew (backend recvN) params
TLS.contextHookSetLogging ctx tlsLogging
TLS.handshake ctx
mysa <- getSocketName s
attachConn mysa ctx
let tm = settingsTimeout set * 1000000
mconn <- timeout tm $ do
TLS.handshake ctx
mysa <- getSocketName s
attachConn mysa ctx
case mconn of
Nothing -> throwIO IncompleteHeaders
Just conn -> return conn
wrappedRecvN recvN n = handleAny (const mempty) $ recvN n
backend recvN =
TLS.Backend
Expand Down

0 comments on commit 2baca8b

Please sign in to comment.