[Haskell-cafe] Fwd: Safe TCP accept loop
Ömer Sinan Ağacan
omeragacan at gmail.com
Tue Oct 24 05:43:24 UTC 2017
Hi Sumit,
> Does this method of handling an accept loop still need masking of async
> exceptions
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/Run.hs#L211
Hope this helps,
Ömer
2017-10-24 2:08 GMT+03:00 Sumit Raja <sumitraja at gmail.com>:
> Hi,
>
> I sent this to beginners but got no responses so I'm hoping someone
> here can help. I’ve looked at
> https://wiki.haskell.org/Concurrency_demos/Graceful_exit and used(2)
> Using throwTo without the use of block and unblock. It runs on 8.2.1
> with my limited testing. I can’t find out much about what the > 7.x
> GHC replacement for block/unblock is other than mask. What does the
> unblock do in acceptConnections'?
>
> Does this method of handling an accept loop still need masking of
> async exceptions ? If so where does this need to be done?
>
> I've got a version with async running for my specific application
> (https://bitbucket.org/sumitraja/hvrr/src/6927216597a35a9a0d7f2e55cca83fa5b7279ee0/hvrr-comms/src/Network/VRR/Server/TCP/TCPAcceptLoop.hs)
> but I don't know if I need to unmask at any point so was hoping for
> some guidance.
>
>
> Thanks
>
>
>
> Sumit
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
More information about the Haskell-Cafe
mailing list