[php-src] Issue #8472: The resource returned by stream_socket_accept may have incorrect metadata

From: Date: Sun, 01 May 2022 12:23:43 +0000
Subject: [php-src] Issue #8472: The resource returned by stream_socket_accept may have incorrect metadata
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-241356@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8472 Author: ichaoX ### Description The following code: ```php <?php function setNonBlocking($stream) { var_dump($block = stream_get_meta_data($stream)['blocked']); if ($block) { stream_set_blocking($stream, false); var_dump(stream_get_meta_data($stream)['blocked']); } } $server = stream_socket_server("tcp://127.0.0.1:4321"); setNonBlocking($server); $client = stream_socket_client("tcp://127.0.0.1:4321"); $res = stream_socket_accept($server); setNonBlocking($res); // Removing the following line will cause blocking // stream_set_blocking($res,false); fwrite($client,str_repeat('0',5)); var_dump(fread($res,4)); var_dump(fread($res,4)); ``` Resulted in this output: ``` bool(true) bool(false) bool(false) string(4) "0000" ``` But I expected this output instead: ``` bool(true) bool(false) bool(true) bool(false) string(4) "0000" string(1) "0" ``` ### PHP Version PHP 8.1.2, PHP 7.4.14 ### Operating System Debian

« previous php.bugs (#241356) next »