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: 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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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
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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-22 09:49 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-09-22 09:49 UTC] cmb@php.net
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: Mon Dec 09 18:01:27 2024 UTC