|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70483 stream_select depends on concrete value of given resource inside array
Submitted: 2015-09-13 18:14 UTC Modified: 2020-09-22 09:49 UTC
From: edefimov dot it at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Streams related
PHP Version: 5.6.13 OS: Ubuntu 14.04 (64bit)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: edefimov dot it at gmail dot com
New email:
PHP Version: OS:


 [2015-09-13 18:14 UTC] edefimov dot it at gmail dot com
When script creates resource with identifier greater than FD_SETSIZE and pass it as the only argument to stream_select, php warning is emitted and stream_select fails. 

Test script:

$nomatter = [];
$sockets = [];
for ($i = 0; $i <= 1024; $i++) {
    $sockets[] = stream_socket_client('tcp://', $errno, $errstr, STREAM_CLIENT_ASYNC_CONNECT);

$s = stream_socket_client('tcp://', $errno, $errstr, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);

$read = [$s];
$result = stream_select($read, $nomatter, $nomatter, 1);

Expected result:
resource(1030) of type (stream)

Actual result:
resource(1030) of type (stream)
PHP Warning:  stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE.
It is set to 1024, but you have descriptors numbered at least as high as 1028.
 --enable-fd-setsize=2048 is recommended, but you may want to set it
to equal the maximum number of open files supported by your system,
in order to avoid seeing this error again at a later date. in /test.php on line 13
PHP Stack trace:
PHP   1. {main}() /test.php:0
PHP   2. stream_select() /test.php:13


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-22 09:49 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-09-22 09:49 UTC]
This is not about the resource ID, but rather about the number of
the related file descriptor, which must not exceed the configured
--enable-fd-setsize value.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 14 15:01:29 2024 UTC