Commit 4feb38f4 authored by Simon Marlow's avatar Simon Marlow
Browse files

make this test deterministic on a multiprocessor

parent 05f4af5f
......@@ -19,7 +19,9 @@ module Main where
import Network.Socket
import System.IO
import Prelude hiding (putStr)
import System.IO hiding (putStr)
import qualified System.IO
import System.IO.Error
import Control.Concurrent
import System.Environment ( getArgs )
......@@ -40,6 +42,11 @@ eofAsEmptyHandler e
| isEOFError e = return ""
| otherwise = ioError e
-- For debugging, enable the putStr below. Turn it off to get deterministic
-- results: on a multiprocessor we can't predict the order of the messages.
putStr = const (return ())
-- putStr = System.IO.putStr
echo_server s = do
(s', clientAddr) <- accept s
proc <- read_data s' 0
......@@ -110,9 +117,9 @@ main = {- withSocketsDo $ -} do
c <- myForkIO (echo_client (read n::Int))
-- let 'em run until they've signaled they're done
join s
putStr("join s")
System.IO.putStr "join s\n"
join c
putStr("join c")
System.IO.putStr "join c\n"
-- these are used to make the main thread wait until
-- the child threads have exited
......
Client wrote: Hello there sailor
Server recv: Hello there sailor
Server read: Hello there sailor
Server wrote: Hello there sailor
Client read successClient wrote: Hello there sailor
Server recv: Hello there sailor
Server read: Hello there sailor
Server wrote: Hello there sailor
Client read successClient wrote: Hello there sailor
Server recv: Hello there sailor
Server read: Hello there sailor
Server wrote: Hello there sailor
Client read successClient read nil
Server recv: server read: server processed 57 bytes
join sjoin c
\ No newline at end of file
server processed 57 bytes
join s
join c
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment