php-src/ext/sockets/tests/socket_reuseport_cbpf.phpt
David Carlier 615b8006c4 socket module add SO_ATTACH_REUSEPORT_CPBF for Linux.
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
2022-09-29 23:32:39 +01:00

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)