Don't close socket handles, just leave that job for garbage collector, as doing it manually seems to be the cause of server hangs
--- a/netserver/hedgewars-server.hs Mon Nov 17 16:48:52 2008 +0000
+++ b/netserver/hedgewars-server.hs Mon Nov 17 18:24:34 2008 +0000
@@ -85,12 +85,14 @@
do
forM_ answer (\str -> hPutStrLn ch str)
hPutStrLn ch ""
- hFlush ch
+ --hFlush ch
if head answer == "BYE" then return [ch] else return []
let outHandles = concat clHandles'
unless (null outHandles) $ putStrLn ((show $ length outHandles) ++ " / " ++ (show $ length clients) ++ " : " ++ (show answer))
- mapM_ (\ch -> Control.Exception.handle (const $ putStrLn "error on hClose") (hClose ch)) outHandles
+
+ -- strange, but this seems to be a bad idea to manually close these handles as it causes hangs
+ --mapM_ (\ch -> Control.Exception.handle (const $ putStrLn "error on hClose") (hClose ch)) outHandles
let mclients = remove clients outHandles
sendAnswers answers client mclients rooms