
25 Oct
2017
25 Oct
'17
5:52 a.m.
Hi Ă–mer
You need to mask async exceptions between `accept()` and cleanup action registration, because an exception in between these operations will cause the socket to leak.
You can take a look at warp's accept loop:
https://github.com/yesodweb/wai/blob/master/warp/Network/Wai/Handler/Warp/Ru...
Trying to map steps for the code you've pointed me to in bad pseudo code: finally (mask >> acceptLoop serverSocket) (close serverSocket) acceptLoop = unmask sock <- accept serverSock mask forkIO $ do mask finally (unmask >> process sock) (close sock) acceptLoop Is this correct? Thanks Sumit