import System.IO
import Text.Printf
+import Control.Concurrent
import Debug.Trace
-responseWriter :: Handle -> InteractionQueue -> IO ()
-responseWriter h tQueue
+responseWriter :: Handle -> InteractionQueue -> ThreadId -> IO ()
+responseWriter h tQueue readerTID
= catch awaitSomethingToWrite $ \ exc ->
case exc of
- IOException _ -> return ()
- _ -> print exc
+ IOException _ -> return ()
+ AsyncException ThreadKilled -> return ()
+ BlockedIndefinitely -> putStrLn "requestWriter: blocked indefinitely"
+ _ -> print exc
where
awaitSomethingToWrite :: IO ()
awaitSomethingToWrite
readItr itr itrWillClose id
if willClose then
- hClose h
+ do killThread readerTID
+ hClose h
else
awaitSomethingToWrite