summaryrefslogtreecommitdiff
path: root/src/Network/StreamServer.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/StreamServer.hs')
-rw-r--r--src/Network/StreamServer.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Network/StreamServer.hs b/src/Network/StreamServer.hs
index 7fecc7aa..6a36ed00 100644
--- a/src/Network/StreamServer.hs
+++ b/src/Network/StreamServer.hs
@@ -36,10 +36,14 @@ import System.IO
36import Control.Monad 36import Control.Monad
37import Control.Monad.Fix (fix) 37import Control.Monad.Fix (fix)
38#ifdef THREAD_DEBUG 38#ifdef THREAD_DEBUG
39import Control.Concurrent.Lifted.Instrument (forkIO, threadDelay, ThreadId, mkWeakThreadId, labelThread, myThreadId) 39import Control.Concurrent.Lifted.Instrument
40 ( forkIO, threadDelay, ThreadId, mkWeakThreadId, labelThread, myThreadId
41 , killThread )
40#else 42#else
41import GHC.Conc (labelThread) 43import GHC.Conc (labelThread)
42import Control.Concurrent (forkIO, threadDelay, ThreadId, mkWeakThreadId, myThreadId) 44import Control.Concurrent
45 ( forkIO, threadDelay, ThreadId, mkWeakThreadId, myThreadId
46 , killThread )
43#endif 47#endif
44import Control.Exception (catch,handle,try,finally) 48import Control.Exception (catch,handle,try,finally)
45import System.IO.Error (tryIOError) 49import System.IO.Error (tryIOError)
@@ -71,9 +75,10 @@ removeSocketFile _ = return ()
71 75
72-- | Terminate the server accept-loop. Call this to shut down the server. 76-- | Terminate the server accept-loop. Call this to shut down the server.
73quitListening :: ServerHandle -> IO () 77quitListening :: ServerHandle -> IO ()
74quitListening (ServerHandle socket _) = 78quitListening (ServerHandle socket acceptThread) =
75 finally (Socket.getSocketName socket >>= removeSocketFile) 79 finally (Socket.getSocketName socket >>= removeSocketFile)
76 (Socket.close socket) 80 (do mapM_ killThread =<< deRefWeak acceptThread
81 Socket.close socket)
77 82
78 83
79-- | It's 'bshow' instead of 'show' to enable swapping in a 'ByteString' 84-- | It's 'bshow' instead of 'show' to enable swapping in a 'ByteString'