, Handler handleBIOS
, Handler handleOthers
]
+ `finally`
+ enqueue' tQueue EndOfInteraction
where
handleAsyncE ∷ AsyncException → IO ()
handleAsyncE ThreadKilled = return ()
dump ∷ Exception e ⇒ e → IO ()
dump e
= do hPutStrLn stderr "requestReader caught an exception:"
- hPutStrLn stderr (show $ toException e)
+ hPutStrLn stderr $ show e
acceptRequest ∷ HandleLike h ⇒ Context h → Lazy.ByteString → IO ()
acceptRequest ctx@(Context {..}) input
-- Too many requests in the pipeline...
retry
if Lazy.null input then
- endOfRequests ctx
+ return ()
else
case LP.parse request input of
LP.Done input' req → acceptParsableRequest ctx req input'
LP.Fail _ _ _ → acceptNonparsableRequest ctx
-endOfRequests ∷ HandleLike h ⇒ Context h → IO ()
-endOfRequests ctx
- = enqueue ctx EndOfInteraction
-
acceptNonparsableRequest ∷ HandleLike h ⇒ Context h → IO ()
acceptNonparsableRequest ctx@(Context {..})
= do syi ← mkSyntacticallyInvalidInteraction cConfig
acceptRequest ctx input
enqueue ∷ (HandleLike h, Interaction i) ⇒ Context h → i → IO ()
-{-# INLINEABLE enqueue #-}
-enqueue (Context {..}) itr
+enqueue (Context {..}) = enqueue' cQueue
+
+enqueue' ∷ Interaction i ⇒ InteractionQueue → i → IO ()
+enqueue' tQueue itr
= atomically $
- do queue ← readTVar cQueue
- writeTVar cQueue (toInteraction itr ⊲ queue)
+ do queue ← readTVar tQueue
+ writeTVar tQueue (toInteraction itr ⊲ queue)
dump ∷ Exception e ⇒ e → IO ()
dump e
= do hPutStrLn stderr "requestWriter caught an exception:"
- hPutStrLn stderr (show $ toException e)
+ hPutStrLn stderr $ show e
awaitSomethingToWrite ∷ HandleLike h ⇒ Context h → IO ()
awaitSomethingToWrite ctx@(Context {..})