Bug #70483 [Opn->Nab]: stream_select depends on concrete value of given resource inside array

From: Date: Tue, 22 Sep 2020 09:49:34 +0000
Subject: Bug #70483 [Opn->Nab]: stream_select depends on concrete value of given resource inside array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229123@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70483&edit=1

 ID:                 70483
 Updated by:         cmb@php.net
 Reported by:        edefimov dot it at gmail dot com
 Summary:            stream_select depends on concrete value of given
                     resource inside array
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            Streams related
 Operating System:   Ubuntu 14.04 (64bit)
 PHP Version:        5.6.13
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2015-09-13 18:14:36] 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)



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=70483&edit=1


Thread (2 messages)

« previous php.bugs (#229123) next »