mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
615b8006c4
to be used in conjunction with SO_REUSPORT, giving a greater control over how we bind a socket instead of the round robin workflow, we do instead attach to the processor id as : - we assign the processor_id to A in the BPF filter. - then returns A. in other words, a more modern version of SO_INCOMING_CPU (ie can have a per worker notion we do not use here). Closes #8062
31 lines
759 B
PHP
31 lines
759 B
PHP
--TEST--
|
|
Test if socket_set_option() works, option:SO_ATTACH_REUSEPORT_CBPF
|
|
--EXTENSIONS--
|
|
sockets
|
|
--SKIPIF--
|
|
<?php
|
|
|
|
if (!defined("SO_ATTACH_REUSEPORT_CBPF")) {
|
|
die('SKIP on platforms not supporting SO_ATTACH_REUSEPORT_CBPF');
|
|
}
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
|
|
|
|
if (!$socket) {
|
|
die('Unable to create AF_INET socket [socket]');
|
|
}
|
|
var_dump(socket_set_option( $socket, SOL_SOCKET, SO_REUSEADDR, true));
|
|
var_dump(socket_set_option( $socket, SOL_SOCKET, SO_REUSEPORT, true));
|
|
var_dump(socket_set_option( $socket, SOL_SOCKET, SO_ATTACH_REUSEPORT_CBPF, SKF_AD_CPU));
|
|
var_dump(socket_bind($socket, '0.0.0.0'));
|
|
socket_listen($socket);
|
|
socket_close($socket);
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|