fixed the multicast socket fd leak

Turns out sClose was working fine.. but it was not being run on every
opened socket. The upstream bug is that multicastSender can crash
on an invalid (or ipv6) address and when this happens it's already
opened a socket, which just goes missing with no way to close it.
A simple fix to the library can avoid this, as I describe here:
https://github.com/audreyt/network-multicast/issues/2

In the meantime, just skipping ipv6 addresses will fix the fd leak.
This commit is contained in:
Joey Hess 2012-09-12 01:18:52 -04:00
parent 6b36c18f2d
commit 4e48f5e6d6

View file

@ -57,6 +57,8 @@ multicastPairMsg repeats secret pairdata stage = go M.empty repeats
mapM_ (sendinterface cache') addrs
threadDelaySeconds (Seconds 2)
go cache' $ pred <$> n
{- The multicast library currently chokes on ipv6 addresses. -}
sendinterface cache (IPv6Addr _) = noop
sendinterface cache i = void $ catchMaybeIO $
withSocketsDo $ bracket setup cleanup use
where