[Haskell-cafe] Problems with Network/MVar
pierreetienne.meunier at gmail.com
Tue Apr 1 09:21:27 UTC 2014
I’m trying to run a server to synchronize a bunch of machines, and one of the threads keeps crashing every ~50 hours.
One of the threads is an HTTP server and stays alive forever, so it’s not a Unix signal problem.
I don’t have much information on its stdout/stderr, and the bug is not very reproducible, since it can happen even though very few of its maximum ~200 clients are connected.
Is there a reason why the following can stop after some time?
server::Config -> MVar State -> IO ()
server config state=withSocketsDo $ do
installHandler sigPIPE Ignore Nothing
threads<-Sem.new $ maxThreads config
forever $ do
E.catch (bracket (listenOn $ port config)) sClose $
\sock->forever $ do
forkIO $ (reply state s a)`finally`(signal threads)`E.catch`(\e->let _=e::IOException in return ())
(\e->let _=e::IOException in return ())
This was compiled with GHC 7.6.3, -threaded and run on Debian Jessie (I have not tested other settings), and Config and State are both record types.
More information about the Haskell-Cafe