summaryrefslogtreecommitdiff
path: root/ext/sockets
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2012-09-02 23:18:45 +0200
committerIgor Wiedler <igor@wiedler.ch>2012-12-02 18:56:57 +0100
commitec2a132f9c345e6b40d04f7230d25b2fe5659672 (patch)
tree0fadf80e144764667d1e79356a8a6d17c4387de9 /ext/sockets
parent7552a7eb191b477349fa278e50fa8b3858382535 (diff)
downloadphp-git-ec2a132f9c345e6b40d04f7230d25b2fe5659672.tar.gz
Bug #49341: Add SO_REUSEPORT support for socket_set_option()
This is a BSD-only feature, and it will only be available on BSD. On other platforms the constant will simply not be set.
Diffstat (limited to 'ext/sockets')
-rw-r--r--ext/sockets/sockets.c3
-rw-r--r--ext/sockets/tests/bug49341.phpt15
2 files changed, 18 insertions, 0 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 0d1714257d..d6ee418510 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -788,6 +788,9 @@ PHP_MINIT_FUNCTION(sockets)
#endif
REGISTER_LONG_CONSTANT("SO_DEBUG", SO_DEBUG, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SO_REUSEADDR", SO_REUSEADDR, CONST_CS | CONST_PERSISTENT);
+#ifdef SO_REUSEPORT
+ REGISTER_LONG_CONSTANT("SO_REUSEPORT", SO_REUSEPORT, CONST_CS | CONST_PERSISTENT);
+#endif
REGISTER_LONG_CONSTANT("SO_KEEPALIVE", SO_KEEPALIVE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SO_DONTROUTE", SO_DONTROUTE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("SO_LINGER", SO_LINGER, CONST_CS | CONST_PERSISTENT);
diff --git a/ext/sockets/tests/bug49341.phpt b/ext/sockets/tests/bug49341.phpt
new file mode 100644
index 0000000000..c165ac7d68
--- /dev/null
+++ b/ext/sockets/tests/bug49341.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #49341: add SO_REUSEPORT support for socket_set_option()
+--SKIPIF--
+<?php
+if (!extension_loaded('sockets')) {
+ die('skip sockets extension not available.');
+}
+if (PHP_OS !== 'Darwin' && false === strpos(PHP_OS, 'BSD')) {
+ die('is not *BSD.');
+}
+--FILE--
+<?php
+var_dump(defined('SO_REUSEPORT'));
+--EXPECTF--
+bool(true)