]> granicus.if.org Git - php/commitdiff
Bug #63000: MCAST_JOIN_GROUP on OSX is broken
authorLars Strojny <lstrojny@php.net>
Wed, 19 Sep 2012 20:17:35 +0000 (22:17 +0200)
committerLars Strojny <lstrojny@php.net>
Wed, 19 Sep 2012 20:17:35 +0000 (22:17 +0200)
The multicast support in PHP 5.4 makes use of MCAST_JOIN_GROUP if it is present.
The problem is that OSX 10.7 added the constant, but did not correctly implement
the feature. This causes the setsockopt call to fail.

The solution to the problem is to not use MCAST_JOIN_GROUP on OSX.

For reference, this was also done in VLC:

* http://trac.videolan.org/vlc/ticket/6104#comment:19

NEWS
ext/sockets/multicast.h
ext/sockets/tests/bug63000.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index e769b356a60458c648c0fae7b11860263c6384fd..8fb38102686b86d42f5654ca11311b11957bd589 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -247,7 +247,9 @@ PHP                                                                        NEWS
 
 - Sockets:
   . Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe)
-    
+  . Fixed bug #63000 (MCAST_JOIN_GROUP on OSX is broken, merge of PR 185 by
+    Igor Wiedler). (Lars)
+
 - SPL:
   . Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to
     dot files). (Laruence)
index ccd9b1d2a8e9148d822478862b89ecfa416b5bb8..5619c9c7fb29386fd1d5f1879f3188167a134b35 100644 (file)
 /* $Id$ */
 
 #if defined(MCAST_JOIN_GROUP) && \
-       (!defined(PHP_WIN32) || (_WIN32_WINNT >= 0x600 && SOCKETS_ENABLE_VISTA_API))
+       (!defined(PHP_WIN32) || (_WIN32_WINNT >= 0x600 && SOCKETS_ENABLE_VISTA_API)) && \
+       !defined(__APPLE__)
 #define RFC3678_API 1
 /* has block/unblock and source membership, in this case for both IPv4 and IPv6 */
 #define HAS_MCAST_EXT 1
-#elif defined(IP_ADD_SOURCE_MEMBERSHIP)
+#elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__)
 /* has block/unblock and source membership, but only for IPv4 */
 #define HAS_MCAST_EXT 1
 #endif
diff --git a/ext/sockets/tests/bug63000.phpt b/ext/sockets/tests/bug63000.phpt
new file mode 100644 (file)
index 0000000..c806ba4
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug #63000: Multicast on OSX
+--SKIPIF--
+<?php
+if (!extension_loaded('sockets')) {
+    die('skip sockets extension not available.');
+}
+if (PHP_OS !== 'Darwin') {
+    die('is not OSX.');
+}
+--FILE--
+<?php
+$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
+socket_bind($socket, '0.0.0.0', 31057);
+
+$so = socket_set_option($socket, IPPROTO_IP, MCAST_JOIN_GROUP, array(
+    "group" => '224.0.0.251',
+    "interface" => 0,
+));
+var_dump($so);
+--EXPECTF--
+bool(true)