|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-03-05 22:39 UTC] rodricg at sellingsource dot com
Description:
------------
Since php 5.2.0 stream_select fails to return the number of modified descriptors on a 64bit Linux OS (32bit seems to be immune to this). Verified to exist in the php-snap php5.2-200703052130.
This bug is the same as #40458 but I am unable to modify the status of that bug.
Reproduce code:
---------------
<?php
$sock = stream_socket_client('tcp://maila.microsoft.com:25', $eno, $estr, 10, STREAM_CLIENT_CONNECT);
stream_set_blocking($sock, 0);
sleep(1);
$r = $w = array($sock);
$n = stream_select($r, $w, $e = NULL, 10);
echo "Selected: {$n}\n";
echo "Read: ", print_r($r,1);
echo "Write: ", print_r($w,1);
?>
Expected result:
----------------
Selected: 2
Read: Array
(
[0] => Resource id #5
)
Write: Array
(
[0] => Resource id #5
)
Actual result:
--------------
Selected: 0
Read: Array
(
[0] => Resource id #5
)
Write: Array
(
[0] => Resource id #5
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 20:00:01 2025 UTC |
Tested on Linux/Intel 64, Linux/AMD 64, Linux/PPC 64 & Solaris/SPARC 64. In all cases I get: Selected: 2 Read: Array ( [0] => Resource id #5 ) Write: Array ( [0] => Resource id #5 )Just verified that I still see the same behavior with: php-5.2.3 openssl-0.9.8e gcc-4.1.2 I am using the same test script as before. Changing it to use: -O1 --with-openssl *or* -O2 --without-openssl gives the correct behavior.This was sent to me via email so I'm posting it here in the interest of collecting all relevant information. > I have the same weird behaviour on x86_64 but with gcc-3.4.6-8 (CentOS 4.5) > and PHP 5.2.4 > > P.S. I havent tested yet if it's related but I have FD_SETSIZE macro in > /usr/include/* set to 16384 (instead of original 1024). Though > stream_select in php4 has no problems. > > Well, I started to debug the code and noticed that system's select() > returns correct return value but this value will be later overwritten?? and > PHP script gets always wrong result. > > The cure for me was to replace an variable type from 'int' to 'long' in > function stream_array_from_fd_set: > > --- streamsfuncs.c.orig 2007-10-09 16:21:30.000000000 +0300 > +++ streamsfuncs.c 2007-10-09 16:21:41.000000000 +0300 > @@ -608,7 +608,7 @@ > zval **elem, **dest_elem; > php_stream *stream; > HashTable *new_hash; > - int this_fd, ret = 0; > + long this_fd, ret = 0; > > if (Z_TYPE_P(stream_array) != IS_ARRAY) { > return 0; > > regards, > Margus Kaidja