|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-11-21 14:52 UTC] wez@php.net
[2004-11-21 22:21 UTC] jed at jed dot bz
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 18:00:02 2025 UTC |
Description: ------------ Posted to php.general. Posted here on behalf of original bug discoverer, as I wrote a large test case for it. PHP 5.0.2 CLI Windows XP SP 2 with DEP excepted for PHP-CLI (DEP *was* a problem early, but I excepted it for php.exe) socket_select() will fail when managing a large number of sockets. The sockets extension itself can manage a bunch, but when socket_select() is attempted with a 'read' array larger than exactly 64 sockets, it prints out the following message and dies: Warning: socket_select(): unable to select [0]: An operation was attempted on something that is not a socket. PHP's problem? My problem? A print_r of the array before feeding it to socket_select shows this: Array ( [1] => Resource id #4 [2] => Resource id #5 [3] => Resource id #6 (...) [64] => Resource id #67 [65] => Resource id #68 ) Valid resources, I'd assume. Zero-basing the array causes the same problem. If there are more than exactly 64 sockets in the array fed to socket_select for the read parameter socket_select() will fail. Due to lack of time I'll only submit the test case for read, but write and except might be prone to the same problem. Let's tackle one at a time. Latest CVS was unusable as the sockets extension currently doesn't link correctly (numerous PHP startup warnings were encountered when starting php just for php -v)... The snaps I used to obtain this result were 5.0.x-dev 200411201730 ("5.0.3-dev") 5.1.x-dev 200411201930 Might have been misconfiguration on my end, because 5.0.x popped up a box reporting a mismatch between extensions even after I changed extension_dir to the snapshot package's extensions. Reproduce code: --------------- The Server http://labs.jed.bz/HCJ/server.php.txt The Load Client http://labs.jed.bz/HCJ/load.php.txt When executing, make sure $max_connections in the server is exactly equal to $connections in the load tester (or, if you prefer, make it one under, and telnet in to the server to make the last one). Expected result: ---------------- ... connecting #65 of 65 ... ok waiting for spew Array ( ... ) spew! done! Actual result: -------------- [63] => Resource id #67 [64] => Resource id #68 ) Warning: socket_select(): unable to select [0]: An operation was attempted on something that is not a socket. in F:\Projects\HCJ\load.php on line 39 spew! done! ---------------- This appeared in my debugger output while I was messing with getting a backtrace (possible in VS?). Interest you? First-chance exception at 0x7c81eb33 in php.exe: 0x000006A6: The binding handle is invalid. ---------------- I can't recompile with debug symbols at this point, I'm unfortunately pressed for time. Perhaps someone can run it through VS and see what comes up.