Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for latest http-semantics #120

Merged
merged 1 commit into from
Jun 12, 2024
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
23 changes: 15 additions & 8 deletions Network/HTTP2/Client/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Network.HTTP2.Client.Run where

import Control.Concurrent.STM (check)
import Data.ByteString.Builder (Builder)
import qualified Data.ByteString.UTF8 as UTF8
import Data.IORef
import Network.Control (RxFlow (..), defaultMaxData)
Expand Down Expand Up @@ -182,8 +181,8 @@ sendRequest ctx@Context{..} mgr scheme auth (Request req) = do
(sid, newstrm) <- openOddStreamWait ctx
case outObjBody req of
OutBodyStreaming strmbdy ->
sendStreaming ctx mgr req' sid newstrm $ \unmask push flush ->
unmask $ strmbdy push flush
sendStreaming ctx mgr req' sid newstrm $ \iface ->
outBodyUnmask iface $ strmbdy (outBodyPush iface) (outBodyFlush iface)
OutBodyStreamingUnmask strmbdy ->
sendStreaming ctx mgr req' sid newstrm strmbdy
_ -> atomically $ do
Expand All @@ -199,16 +198,24 @@ sendStreaming
-> OutObj
-> StreamId
-> Stream
-> ((forall x. IO x -> IO x) -> (Builder -> IO ()) -> IO () -> IO ())
-> (OutBodyIface -> IO ())
-> IO ()
sendStreaming Context{..} mgr req sid newstrm strmbdy = do
tbq <- newTBQueueIO 10 -- fixme: hard coding: 10
forkManagedUnmask mgr $ \unmask -> do
let push b = atomically $ writeTBQueue tbq (StreamingBuilder b)
flush = atomically $ writeTBQueue tbq StreamingFlush
finished = atomically $ writeTBQueue tbq $ StreamingFinished (decCounter mgr)
decrementedCounter <- newIORef False
let decCounterOnce = do
alreadyDecremented <- atomicModifyIORef decrementedCounter $ \b -> (True, b)
unless alreadyDecremented $ decCounter mgr
let iface = OutBodyIface {
outBodyUnmask = unmask
, outBodyPush = \b -> atomically $ writeTBQueue tbq (StreamingBuilder b Nothing)
, outBodyPushFinal = \b -> atomically $ writeTBQueue tbq (StreamingBuilder b (Just decCounterOnce))
, outBodyFlush = atomically $ writeTBQueue tbq StreamingFlush
}
finished = atomically $ writeTBQueue tbq $ StreamingFinished decCounterOnce
incCounter mgr
strmbdy unmask push flush `finally` finished
strmbdy iface `finally` finished
atomically $ do
sidOK <- readTVar outputQStreamID
check (sidOK == sid)
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/H2/Sender.hs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
let payloadOff = off0 + frameHeaderLength
datBuf = confWriteBuffer `plusPtr` payloadOff
datBufSiz = buflim - payloadOff
Next datPayloadLen reqflush mnext <- curr datBuf datBufSiz lim -- checkme
Next datPayloadLen reqflush mnext <- curr datBuf (min datBufSiz lim)

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.10)

• Couldn't match expected type ‘IO Next’

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.0)

• Couldn't match expected type: IO Next

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.2)

• Couldn't match expected type: IO Next

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.4)

• Couldn't match expected type: IO Next

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 9.6)

• Couldn't match expected type: IO Next

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (macOS-latest, 8.10)

• Couldn't match expected type ‘IO Next’

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (macOS-latest, 9.0)

• Couldn't match expected type: IO Next

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (macOS-latest, 9.2)

• Couldn't match expected type: IO Next

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (macOS-latest, 9.4)

• Couldn't match expected type: IO Next

Check failure on line 160 in Network/HTTP2/H2/Sender.hs

View workflow job for this annotation

GitHub Actions / build (macOS-latest, 9.6)

• Couldn't match expected type: IO Next
NextTrailersMaker tlrmkr' <- runTrailersMaker tlrmkr datBuf datPayloadLen
fillDataHeaderEnqueueNext
strm
Expand Down
2 changes: 1 addition & 1 deletion Network/HTTP2/Server/Worker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ response wc@WorkerConf{..} mgr th tconf strm (Request req) (Response rsp) pps =
writeOutputQ $ Output strm rsp otyp (Just tbq) (return ())
let push b = do
T.pause th
atomically $ writeTBQueue tbq (StreamingBuilder b)
atomically $ writeTBQueue tbq (StreamingBuilder b Nothing)
T.resume th
flush = atomically $ writeTBQueue tbq StreamingFlush
finished = atomically $ writeTBQueue tbq $ StreamingFinished (decCounter mgr)
Expand Down
Loading