summaryrefslogtreecommitdiff
path: root/test/resourceExhausted.hs
diff options
context:
space:
mode:
Diffstat (limited to 'test/resourceExhausted.hs')
-rw-r--r--test/resourceExhausted.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/resourceExhausted.hs b/test/resourceExhausted.hs
new file mode 100644
index 00000000..4cdef98e
--- /dev/null
+++ b/test/resourceExhausted.hs
@@ -0,0 +1,35 @@
1import Control.Concurrent
2import System.IO
3import System.Mem.Weak
4import System.IO.Error
5
6import Network.StreamServer
7import Network.Address (getBindAddress)
8import DPut
9import DebugTag
10
11sesh sock n h = do
12 s <- hGetContents h
13 putStr s
14
15main = do
16 setVerbose XMisc
17 bind <- getBindAddress "8889" True
18 serv <- streamServer (withSession sesh) [bind]
19
20 wtid <- getAcceptLoopThreadId serv
21 mtid <- deRefWeak wtid
22 case mtid of
23 Nothing -> hPutStrLn stderr "missing accept loop?"
24 Just tid -> do
25 threadDelay 1000000
26 hPutStrLn stderr "Throwing execption now..."
27 let -- e = userError "resource exhausted" `ioeSetErrorType` fullErrorType
28 e = mkIOError fullErrorType "resourceExhausted.hs" Nothing Nothing
29 throwTo tid e
30 hPutStrLn stderr "Thrown."
31
32 getLine
33
34 quitListening serv
35 return ()