[Pkg-haskell-commits] darcs: haskell-network-multicast: fix multicastReceiver socket leak when unable to set up socket
Louis Bettens
louis at bettens.info
Sat Aug 24 19:57:27 UTC 2013
Sat Aug 24 19:51:28 UTC 2013 Louis Bettens <louis at bettens.info>
* fix multicastReceiver socket leak when unable to set up socket
M ./changelog +8
A ./patches/
A ./patches/fix-multicastReceiver-socket-leak-when-unable-to-set-up-socket.diff
Sat Aug 24 19:51:28 UTC 2013 Louis Bettens <louis at bettens.info>
* fix multicastReceiver socket leak when unable to set up socket
diff -rN -u old-haskell-network-multicast/changelog new-haskell-network-multicast/changelog
--- old-haskell-network-multicast/changelog 2013-08-24 19:57:27.185541657 +0000
+++ new-haskell-network-multicast/changelog 2013-08-24 19:57:27.189546728 +0000
@@ -1,3 +1,11 @@
+haskell-network-multicast (0.0.7-2.1) UNRELEASED; urgency=low
+
+ * Non-maintainer upload.
+ * Fix multicastReceiver socket leak when unable to set up socket.
+ * Closes: #720714, fixed and reported upstream by Joey Hess.
+
+ -- Louis Bettens <louis at bettens.info> Sat, 24 Aug 2013 21:18:34 +0200
+
haskell-network-multicast (0.0.7-2) unstable; urgency=low
* Enable compat level 9
diff -rN -u old-haskell-network-multicast/patches/fix-multicastReceiver-socket-leak-when-unable-to-set-up-socket.diff new-haskell-network-multicast/patches/fix-multicastReceiver-socket-leak-when-unable-to-set-up-socket.diff
--- old-haskell-network-multicast/patches/fix-multicastReceiver-socket-leak-when-unable-to-set-up-socket.diff 1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-network-multicast/patches/fix-multicastReceiver-socket-leak-when-unable-to-set-up-socket.diff 2013-08-24 19:57:27.197543953 +0000
@@ -0,0 +1,49 @@
+From: Joey Hess <joeyh at debian.org>
+Subject: fix multicastReceiver socket leak when unable to set up socket
+
+Origin: upstream, https://github.com/audreyt/network-multicast/commit/0fae21bd7584dc80190c523e165c1b83a17da238
+diff --git a/src/Network/Multicast.hsc b/src/Network/Multicast.hsc
+index 5a87ed8..6876aab 100644
+--- a/src/Network/Multicast.hsc
++++ b/src/Network/Multicast.hsc
+@@ -30,6 +30,7 @@ import Foreign.C.Error
+ import Foreign.Storable
+ import Foreign.Marshal
+ import Foreign.Ptr
++import Control.Exception (bracketOnError)
+
+ type TimeToLive = Int
+ type LoopbackMode = Bool
+@@ -72,18 +73,22 @@ multicastSender host port = do
+ -- > print (msg, addr) in loop
+ --
+ multicastReceiver :: HostName -> PortNumber -> IO Socket
+-multicastReceiver host port = do
+- proto <- getProtocolNumber "udp"
+- sock <- socket AF_INET Datagram proto
+-#ifdef SO_REUSEPORT
+- setSocketOption sock ReusePort 1
++multicastReceiver host port = bracketOnError get close setup
++ where
++ get = do
++ proto <- getProtocolNumber "udp"
++ sock <- socket AF_INET Datagram proto
++#if defined(SO_REUSEPORT) && ! defined (__linux__)
++ setSocketOption sock ReusePort 1
+ #else
+- setSocketOption sock ReuseAddr 1
++ setSocketOption sock ReuseAddr 1
++ return sock
+ #endif
+- (addrInfo:_) <- getAddrInfo Nothing (Just host) (Just $ show port)
+- bindSocket sock $ addrAddress addrInfo
+- addMembership sock host
+- return sock
++ setup sock = do
++ (addrInfo:_) <- getAddrInfo Nothing (Just host) (Just $ show port)
++ bindSocket sock $ addrAddress addrInfo
++ addMembership sock host
++ return sock
+
+ doSetSocketOption :: Storable a => CInt -> Socket -> a -> IO CInt
+ doSetSocketOption ip_multicast_option (MkSocket s _ _ _ _) x = alloca $ \ptr -> do
More information about the Pkg-haskell-commits
mailing list