Don't close socket handles, just leave that job for garbage collector, as doing it manually seems to be the cause of server hangs
authorunc0rr
Mon, 17 Nov 2008 18:24:34 +0000
changeset 1499 870305c40b81
parent 1498 264e11b5c639
child 1500 5721af6d73f0
Don't close socket handles, just leave that job for garbage collector, as doing it manually seems to be the cause of server hangs
netserver/hedgewars-server.hs
--- 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