@@ -64,7 +64,7 @@ response Context{outputQ} mgr tconf th strm req rsp = do
64 -- Since we must not enqueue an empty queue to the priority
64 -- Since we must not enqueue an empty queue to the priority
65 -- queue, we spawn a thread to ensure that the designated
65 -- queue, we spawn a thread to ensure that the designated
66 -- queue is not empty.
66 -- queue is not empty.
67− void $ forkIO $ waiter tvar sq outputQ
67+ void $ forkIO $ waiter tvar sq strm outputQ
68 atomically $ writeTVar tvar (SyncNext out)
68 atomically $ writeTVar tvar (SyncNext out)
69 let push b = do
69 let push b = do
70 atomically $ writeTBQueue sq (SBuilder b)
70 atomically $ writeTBQueue sq (SBuilder b)
@@ -130,27 +130,27 @@ worker ctx@Context{inputQ,outputQ} set tm app responder = do
130 Just e -> S.settingsOnException set (Just req) e
130 Just e -> S.settingsOnException set (Just req) e
131 clearStreamInfo sinfo
131 clearStreamInfo sinfo
133−waiter :: TVar Sync -> TBQueue Sequence -> PriorityTree Output -> IO ()
133+waiter :: TVar Sync -> TBQueue Sequence -> Stream -> PriorityTree Output -> IO ()
134−waiter tvar sq outQ = do
134+waiter tvar sq strm outQ = do
135 -- waiting for actions other than SyncNone
135 -- waiting for actions other than SyncNone
136 mx <- atomically $ do
136 mx <- atomically $ do
137 mout <- readTVar tvar
137 mout <- readTVar tvar
138 case mout of
138 case mout of
139− SyncNone -> retry
139+ SyncNone -> retry
140− SyncNext out -> do
140+ SyncNext out -> do
141 writeTVar tvar SyncNone
141 writeTVar tvar SyncNone
142− return $ Just out
142+ return $ Right out
143− SyncFinish -> return Nothing
143+ SyncFinish trailers -> return $ Left trailers
144 case mx of
144 case mx of
145− Nothing -> return ()
145+ Left trailers -> enqueueWhenWindowIsOpen outQ (OTrailers strm trailers)
146− Just out -> do
146+ Right out -> do
147 -- ensuring that the streaming queue is not empty.
147 -- ensuring that the streaming queue is not empty.
148 atomically $ do
148 atomically $ do
149 isEmpty <- isEmptyTBQueue sq
149 isEmpty <- isEmptyTBQueue sq
150 when isEmpty retry
150 when isEmpty retry
151 -- ensuring that stream window is greater than 0.
151 -- ensuring that stream window is greater than 0.
152 enqueueWhenWindowIsOpen outQ out
152 enqueueWhenWindowIsOpen outQ out
153− waiter tvar sq outQ
153+ waiter tvar sq strm outQ
155----------------------------------------------------------------
155----------------------------------------------------------------