summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJoe Crayne <joe@jerkface.net>2019-10-17 22:48:46 -0400
committerJoe Crayne <joe@jerkface.net>2020-01-01 19:45:16 -0500
commit1e193f42fb51ff2e32b80a1f8ca64df421c30dce (patch)
tree9da87365988b33a0c0051eed55f0b9f270521bae /test
parentb27c28f1a5c41c25b5693195ec8c15510c144413 (diff)
Fixed resource-exhausted logic.
Diffstat (limited to 'test')
-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 ()