Skip to content

Commit

Permalink
using the new name
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Nov 17, 2023
1 parent 3160c87 commit 44e0f51
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions Network/HTTP2/Frame.hs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module Network.HTTP2.Frame (
) where

import qualified Data.ByteString as BS
import Network.Control (WindowSize)

import Imports
import Network.HTTP2.Frame.Decode
Expand Down
1 change: 1 addition & 0 deletions Network/HTTP2/Frame/Encode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import qualified Data.ByteString as BS
import Data.ByteString.Internal (unsafeCreate)
import Foreign.Ptr (Ptr, plusPtr)
import qualified Network.ByteOrder as N
import Network.Control (WindowSize)

import Imports
import Network.HTTP2.Frame.Types
Expand Down
4 changes: 1 addition & 3 deletions Network/HTTP2/Frame/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module Network.HTTP2.Frame.Types where

import Data.Ix
import Network.Control (WindowSize)
import Text.Read
import qualified Text.Read.Lex as L

Expand Down Expand Up @@ -212,9 +213,6 @@ updateSettings settings kvs = foldl' update settings kvs
update def _ = def
{- FOURMOLU_ENABLE -}

-- | The type for window size.
type WindowSize = Int

-- | The default initial window size.
--
-- >>> defaultWindowSize
Expand Down
10 changes: 5 additions & 5 deletions Network/HTTP2/H2/Window.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ import Network.HTTP2.H2.Types

getStreamWindowSize :: Stream -> IO WindowSize
getStreamWindowSize Stream{streamTxFlow} =
txFlowWindow <$> readTVarIO streamTxFlow
txWindowSize <$> readTVarIO streamTxFlow

getConnectionWindowSize :: Context -> IO WindowSize
getConnectionWindowSize Context{txFlow} =
txFlowWindow <$> readTVarIO txFlow
txWindowSize <$> readTVarIO txFlow

waitStreamWindowSize :: Stream -> IO ()
waitStreamWindowSize Stream{streamTxFlow} = atomically $ do
w <- txFlowWindow <$> readTVar streamTxFlow
w <- txWindowSize <$> readTVar streamTxFlow
checkSTM (w > 0)

waitConnectionWindowSize :: Context -> STM ()
waitConnectionWindowSize Context{txFlow} = do
w <- txFlowWindow <$> readTVar txFlow
w <- txWindowSize <$> readTVar txFlow
checkSTM (w > 0)

----------------------------------------------------------------
Expand All @@ -39,7 +39,7 @@ waitConnectionWindowSize Context{txFlow} = do
increaseWindowSize :: StreamId -> TVar TxFlow -> WindowSize -> IO ()
increaseWindowSize sid tvar n = do
atomically $ modifyTVar' tvar $ \flow -> flow{txfLimit = txfLimit flow + n}
w <- txFlowWindow <$> readTVarIO tvar
w <- txWindowSize <$> readTVarIO tvar
when (isWindowOverflow w) $ do
let msg = fromString ("window update for stream " ++ show sid ++ " is overflow")
err =
Expand Down

0 comments on commit 44e0f51

Please sign in to comment.