@@ -35,16 +35,15 @@ data Leftover = LZero
36----------------------------------------------------------------
36----------------------------------------------------------------
38−unlessClosed :: Context -> Connection -> Stream -> IO () -> IO ()
38+unlessClosed :: Connection -> Stream -> IO () -> IO ()
40− Connection{connSendAll}
39+unlessClosed Connection{connSendAll}
41 strm@Stream{streamState,streamNumber}
40 strm@Stream{streamState,streamNumber}
42 body = E.handle resetStream $ do
41 body = E.handle resetStream $ do
43 state <- readIORef streamState
42 state <- readIORef streamState
44 unless (isClosed state) body
43 unless (isClosed state) body
46 resetStream e = do
45 resetStream e = do
47− closed ctx strm (ResetByMe e)
46+ closed strm (ResetByMe e)
48 let rst = resetFrame InternalError streamNumber
47 let rst = resetFrame InternalError streamNumber
49 connSendAll rst
48 connSendAll rst
@@ -85,12 +84,12 @@ frameSender ctx@Context{outputQ,connectionWindow}
85 connSendAll frame
84 connSendAll frame
87 switch (OResponse strm s h aux) = do
86 switch (OResponse strm s h aux) = do
88− unlessClosed ctx conn strm $
87+ unlessClosed conn strm $
89 getWindowSize connectionWindow (streamWindow strm) >>=
88 getWindowSize connectionWindow (streamWindow strm) >>=
90 sendResponse strm s h aux
89 sendResponse strm s h aux
92 switch (ONext strm curr) = do
91 switch (ONext strm curr) = do
93− unlessClosed ctx conn strm $ do
92+ unlessClosed conn strm $ do
94 lim <- getWindowSize connectionWindow (streamWindow strm)
93 lim <- getWindowSize connectionWindow (streamWindow strm)
95 -- Data frame payload
94 -- Data frame payload
96 Next datPayloadLen mnext <- curr lim
95 Next datPayloadLen mnext <- curr lim
@@ -98,7 +97,7 @@ frameSender ctx@Context{outputQ,connectionWindow}
98 maybeEnqueueNext strm mnext
97 maybeEnqueueNext strm mnext
100 switch (OPush oldStrm push strm s h aux) = do
99 switch (OPush oldStrm push strm s h aux) = do
101− unlessClosed ctx conn oldStrm $ do
100+ unlessClosed conn oldStrm $ do
102 lim <- getWindowSize connectionWindow (streamWindow strm)
101 lim <- getWindowSize connectionWindow (streamWindow strm)
103 -- Write and send the promise.
102 -- Write and send the promise.
104 builder <- hpackEncodeCIHeaders ctx $ promiseHeaders push
103 builder <- hpackEncodeCIHeaders ctx $ promiseHeaders push
@@ -111,7 +110,7 @@ frameSender ctx@Context{outputQ,connectionWindow}
111 switch (OTrailers strm []) = do
110 switch (OTrailers strm []) = do
112 let flag = setEndStream defaultFlags
111 let flag = setEndStream defaultFlags
113 fillFrameHeader FrameData 0 (streamNumber strm) flag connWriteBuffer
112 fillFrameHeader FrameData 0 (streamNumber strm) flag connWriteBuffer
114− closed ctx strm Finished
113+ closed strm Finished
115 flushN frameHeaderLength
114 flushN frameHeaderLength
117 switch (OTrailers strm trailers) = do
116 switch (OTrailers strm trailers) = do
@@ -119,7 +118,7 @@ frameSender ctx@Context{outputQ,connectionWindow}
119 -- consecutive header+continuation frames and end the stream.
118 -- consecutive header+continuation frames and end the stream.
120 builder <- hpackEncodeCIHeaders ctx trailers
119 builder <- hpackEncodeCIHeaders ctx trailers
121 off <- headerContinue (streamNumber strm) builder True
120 off <- headerContinue (streamNumber strm) builder True
122− closed ctx strm Finished
121+ closed strm Finished
123 flushN $ off + frameHeaderLength
122 flushN $ off + frameHeaderLength
@@ -224,7 +223,7 @@ frameSender ctx@Context{outputQ,connectionWindow}
224 -- the context would be switched to the receiver,
223 -- the context would be switched to the receiver,
225 -- resulting the inconsistency of concurrency.
224 -- resulting the inconsistency of concurrency.
226 case mnext of
225 case mnext of
227− CFinish -> closed ctx strm Finished
226+ CFinish -> closed strm Finished
228 _ -> return ()
227 _ -> return ()
229 flushN total
228 flushN total
230 atomically $ do
229 atomically $ do