Skip to content

Commit ec2a132

Browse files
committed
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.
1 parent 7552a7e commit ec2a132

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

ext/sockets/sockets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,9 @@ PHP_MINIT_FUNCTION(sockets)
788788
#endif
789789
REGISTER_LONG_CONSTANT("SO_DEBUG", SO_DEBUG, CONST_CS | CONST_PERSISTENT);
790790
REGISTER_LONG_CONSTANT("SO_REUSEADDR", SO_REUSEADDR, CONST_CS | CONST_PERSISTENT);
791+
#ifdef SO_REUSEPORT
792+
REGISTER_LONG_CONSTANT("SO_REUSEPORT", SO_REUSEPORT, CONST_CS | CONST_PERSISTENT);
793+
#endif
791794
REGISTER_LONG_CONSTANT("SO_KEEPALIVE", SO_KEEPALIVE, CONST_CS | CONST_PERSISTENT);
792795
REGISTER_LONG_CONSTANT("SO_DONTROUTE", SO_DONTROUTE, CONST_CS | CONST_PERSISTENT);
793796
REGISTER_LONG_CONSTANT("SO_LINGER", SO_LINGER, CONST_CS | CONST_PERSISTENT);

ext/sockets/tests/bug49341.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #49341: add SO_REUSEPORT support for socket_set_option()
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('sockets')) {
6+
die('skip sockets extension not available.');
7+
}
8+
if (PHP_OS !== 'Darwin' && false === strpos(PHP_OS, 'BSD')) {
9+
die('is not *BSD.');
10+
}
11+
--FILE--
12+
<?php
13+
var_dump(defined('SO_REUSEPORT'));
14+
--EXPECTF--
15+
bool(true)

0 commit comments

Comments
 (0)