|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-09-17 11:57 UTC] wez@php.net
[2003-09-17 12:49 UTC] bill at baghead dot co dot uk
[2003-09-17 13:14 UTC] wez@php.net
[2003-09-17 18:35 UTC] wez@php.net
[2003-09-17 18:37 UTC] wez@php.net
[2003-09-18 04:15 UTC] bill at baghead dot co dot uk
[2003-09-24 21:41 UTC] robert at interjinn dot com
[2003-11-28 17:46 UTC] wez@php.net
[2003-12-16 09:53 UTC] bill at baghead dot co dot uk
[2004-01-14 09:49 UTC] wez@php.net
[2004-01-19 14:11 UTC] sniper@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 00:00:01 2025 UTC |
Description: ------------ Hi, When using xinetd with a php script - then using php to read from the "socket" with STDIN / STDOUT, as thats how xinetd translates sockets. I find that setting blocking on the socket like the code below, I find the while loops and uses all my cpu time - whereas the fread should block, and wait till it gets something.. If I uncomment the sleep line - it drops down the cpu usage, but I would rather have the blocking working. The process function processes the data, and is irrelevant here. PHP Was compiled with: ./configure --enable-cli --with-sockets --with-openssl --with-curl --enable-pcntl --enable-sigchild --with-mysql --enable-sockets Made with: C_INCLUDE_PATH=/usr/kerberos/include make Version: PHP 4.3.4-dev (cli) (built: Sep 17 2003 16:04:24) Reproduce code: --------------- <?php set_time_limit (0); ob_implicit_flush (); stream_set_blocking(STDIN,TRUE); $read = array(STDIN); while (true) { $buf = fread(STDIN,128); //if ($buf == "") { sleep(1); } process($buf); unset($buf); } ?> Expected result: ---------------- For the fread to block and wait for input, rather than return immediately. Actual result: -------------- The fread returns (even with no data), and loops.