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

Delete HalfClosedLocal #84

Closed
wants to merge 1 commit into from
Closed
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
16 changes: 2 additions & 14 deletions Network/HTTP2/Arch/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,8 @@ halfClosedRemote ctx stream@Stream{streamState} = do
traverse_ (closed ctx stream) closingCode
where
closeHalf :: StreamState -> (StreamState, Maybe ClosedCode)
closeHalf x@(Closed _) = (x, Nothing)
closeHalf (HalfClosedLocal cc) = (Closed cc, Just cc)
closeHalf _ = (HalfClosedRemote, Nothing)

halfClosedLocal :: Context -> Stream -> ClosedCode -> IO ()
halfClosedLocal ctx stream@Stream{streamState} cc = do
shouldFinalize <- atomicModifyIORef streamState closeHalf
when shouldFinalize $
closed ctx stream cc
where
closeHalf :: StreamState -> (StreamState, Bool)
closeHalf x@(Closed _) = (x, False)
closeHalf HalfClosedRemote = (Closed cc, True)
closeHalf _ = (HalfClosedLocal cc, False)
closeHalf x@(Closed _) = (x, Nothing)
closeHalf _ = (HalfClosedRemote, Nothing)

closed :: Context -> Stream -> ClosedCode -> IO ()
closed ctx@Context{concurrency,streamTable} strm@Stream{streamNumber} cc = do
Expand Down
12 changes: 0 additions & 12 deletions Network/HTTP2/Arch/Receiver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,6 @@ stream FrameHeaders header@FrameHeader{flags,streamId} bs ctx (Open (Body q _ _
-- we don't support continuation here.
E.throwIO $ ConnectionErrorIsSent ProtocolError streamId "continuation in trailer is not supported"

-- ignore data-frame except for flow-control when we're done locally
stream FrameData
FrameHeader{flags}
_bs
_ctx s@(HalfClosedLocal _)
_ = do
let endOfStream = testEndStream flags
if endOfStream then do
return HalfClosedRemote
else
return s

-- Transition (stream4)
stream FrameData
header@FrameHeader{flags,payloadLength,streamId}
Expand Down
24 changes: 8 additions & 16 deletions Network/HTTP2/Arch/Sender.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import Network.HTTP2.Arch.File
import Network.HTTP2.Arch.HPACK
import Network.HTTP2.Arch.Manager hiding (start)
import Network.HTTP2.Arch.Queue
import Network.HTTP2.Arch.Stream
import Network.HTTP2.Arch.Types
import Network.HTTP2.Arch.Window
import Network.HTTP2.Frame
Expand Down Expand Up @@ -151,9 +150,6 @@ frameSender ctx@Context{outputQ,controlQ,encodeDynamicTable,outputBufferLimit}
off <- flushIfNecessary off'
case body of
OutBodyNone -> do
-- halfClosedLocal calls closed which removes
-- the stream from stream table.
when (isServer ctx) $ halfClosedLocal ctx strm Finished
return off
OutBodyFile (FileSpec path fileoff bytecount) -> do
(pread, sentinel') <- confPositionReadMaker path
Expand Down Expand Up @@ -193,17 +189,14 @@ frameSender ctx@Context{outputQ,controlQ,encodeDynamicTable,outputBufferLimit}
----------------------------------------------------------------
outputOrEnqueueAgain :: Output Stream -> Offset -> IO Offset
outputOrEnqueueAgain out@(Output strm _ otyp _ _) off = E.handle resetStream $ do
state <- readStreamState strm
if isHalfClosedLocal state then
return off
else case otyp of
OWait wait -> do
-- Checking if all push are done.
forkAndEnqueueWhenReady wait outputQ out{outputType=OObj} mgr
return off
_ -> case mtbq of
Just tbq -> checkStreaming tbq
_ -> checkStreamWindowSize
case otyp of
OWait wait -> do
-- Checking if all push are done.
forkAndEnqueueWhenReady wait outputQ out{outputType=OObj} mgr
return off
_ -> case mtbq of
Just tbq -> checkStreaming tbq
_ -> checkStreamWindowSize
where
mtbq = outputStrmQ out
checkStreaming tbq = do
Expand Down Expand Up @@ -288,7 +281,6 @@ frameSender ctx@Context{outputQ,controlQ,encodeDynamicTable,outputBufferLimit}
fillFrameHeader FrameData datPayloadLen streamNumber flag buf
off'' <- handleTrailers mtrailers off'
void tell
when (isServer ctx) $ halfClosedLocal ctx strm Finished
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it good enough to remove this line only?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fce595b added isServer.
I cannot remember why.

decreaseWindowSize ctx strm datPayloadLen
if reqflush then do
flushN off''
Expand Down
5 changes: 0 additions & 5 deletions Network/HTTP2/Arch/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ isHalfClosedRemote HalfClosedRemote = True
isHalfClosedRemote (Closed _) = True
isHalfClosedRemote _ = False

isHalfClosedLocal :: StreamState -> Bool
isHalfClosedLocal (HalfClosedLocal _) = True
isHalfClosedLocal (Closed _) = True
isHalfClosedLocal _ = False

isClosed :: StreamState -> Bool
isClosed Closed{} = True
isClosed _ = False
Expand Down
12 changes: 5 additions & 7 deletions Network/HTTP2/Arch/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,15 @@ data StreamState =
Idle
| Open OpenState
| HalfClosedRemote
| HalfClosedLocal ClosedCode
| Closed ClosedCode
| Reserved

instance Show StreamState where
show Idle = "Idle"
show Open{} = "Open"
show HalfClosedRemote = "HalfClosedRemote"
show (HalfClosedLocal e) = "HalfClosedLocal: " ++ show e
show (Closed e) = "Closed: " ++ show e
show Reserved = "Reserved"
show Idle = "Idle"
show Open{} = "Open"
show HalfClosedRemote = "HalfClosedRemote"
show (Closed e) = "Closed: " ++ show e
show Reserved = "Reserved"

----------------------------------------------------------------

Expand Down
Loading