Bug #69637 [Com]: stream_select() warns: recompile php with FD_SETSIZE>1024 but it already is
Edit report at https://bugs.php.net/bug.php?id=69637&edit=1
ID: 69637
Comment by: stormdja at gmail dot com
Reported by: bousset1 at gmail dot com
Summary: stream_select() warns: recompile php with
FD_SETSIZE>1024 but it already is
Status: Verified
Type: Bug
Package: Sockets related
Operating System: linux (tested on ubuntu 14.04)
PHP Version: 5.6.8
Block user comment: N
Private report: N
New Comment:
@[2016-11-08 10:45 UTC] - directly modifiying system headers may not be a good idea.
Here's a simple patch (tested on php 7.2.14):
--- main/php.h 2019-01-08 09:59:17.000000000 +0000
+++ main/php.h 2019-01-30 09:03:18.698899000 +0000
@@ -515,6 +515,11 @@
#endif
+#undef __FD_SETSIZE
+#define __FD_SETSIZE 32768
+#undef FD_SETSIZE
+#define FD_SETSIZE 32768
+
/*
* Local variables:
* tab-width: 4
-----------
Result:
# php-7.2.14-009/bin/php -r "print_r(get_defined_constants(true));"|grep FD_SETSIZE
[PHP_FD_SETSIZE] => 32768
Previous Comments:
------------------------------------------------------------------------
[2017-04-24 19:05:58] erw at macrovita dot com dot br
If PHP process has more open file descriptors than FD_SETSIZE, it seems stream_select() will fail
even when trying to monitor just a couple file descriptors.
I get the error even when trying to stream_select() only 2 file descriptors, apparently because the
apache process has thousands of file descriptors open.
Environment: apache-2.4.23 event mpm, php-7.0.11, Gentoo Linux
// BTM11121, BTM10159
------------------------------------------------------------------------
[2016-11-08 10:45:07] kexianbin at diyism dot com
1.vi /usr/include/x86_64-linux-gnu/bits/typesizes.h:
#define __FD_SETSIZE 65536
2.compile:
./configure --with-curl --enable-fd-setsize=65536 CFLAGS='-D_FORTIFY_SOURCE=0'
make && sudo make install
3.vi /etc/security/limits.conf:
* soft nofile 65535
* hard nofile 65535
------------------------------------------------------------------------
[2016-07-03 12:30:29] cmb@php.net
Related To: Bug #43269
------------------------------------------------------------------------
[2016-07-02 15:20:57] cmb@php.net
Related To: Bug #72030
------------------------------------------------------------------------
[2016-05-31 21:05:34] deriamis at gmail dot com
The reason this appears to be happening is that sys/select.h on Linux is overriding FD_SETSIZE by
setting it to the value of __FD_SETSIZE, which is set statically to 1024, without checking that
it's already defined. The --enable-fd-setsize is not cross-platform and, people who need this
either have to patch PHP source in several places (bad) or system include files (worse). I think a
good way to do this is to set a dummy value and then in source set both FD_SETSIZE and __FD_SETSIZE
to the dummy value immediately before the sys/select.h include.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=69637
--
Edit this bug report at https://bugs.php.net/bug.php?id=69637&edit=1
Thread (6 messages)