php.net |  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: -
From: edefimov dot it at gmail dot com Assigned:
Status: Open Package: Streams related
PHP Version: 5.6.13 OS: Ubuntu 14.04 (64bit)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-09-13 18:14 UTC] edefimov dot it at gmail dot com
Description:
------------
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:
---------------
<?php

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

$s = stream_socket_client('tcp://php.net:80', $errno, $errstr, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);
var_dump($s);

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

Expected result:
----------------
resource(1030) of type (stream)
int(1)


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
int(0)


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 23:01:25 2019 UTC