ID: 34429 User updated by: zimage at icdsoft dot com Reported By: zimage at icdsoft dot com -Status: Feedback +Status: Open Bug Type: Output Control Operating System: Linux PHP Version: 4.4.0 New Comment:
This is how you could write a chat client for example. Connection is kept open for the duration of chat session and php script is looping over the client and server messages. Previous Comments: ------------------------------------------------------------------------ [2005-09-10 22:56:11] [EMAIL PROTECTED] How would it be useful to be able to turn it off? ------------------------------------------------------------------------ [2005-09-09 11:25:26] zimage at icdsoft dot com And strace of php process looks like: read(4, "<?php\n\tfor ($i=0; $i<4; $i++){\n\t"..., 8192) = 65 read(4, "", 4096) = 0 read(4, "", 8192) = 0 close(4) = 0 munmap(0x4056b000, 4096) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, {1, 0}) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, {1, 0}) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, {1, 0}) = 0 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, {1, 0}) = 0 setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0 write(3, "[EMAIL PROTECTED]: text/html\r"..., 96) = 96 I.e. there are 4 calls to sleep and the script output is writen at once. Any pointers to documentation or further tests that I should perform are welcome. ------------------------------------------------------------------------ [2005-09-08 21:23:38] zimage at icdsoft dot com Just tried with php5-200509081630: PHP 5.1.0-dev (cgi-fcgi) (built: Sep 8 2005 15:09:53) No luck either. Output still comes at once. Tried with apache2 + php-4.3.11 - the problem is present there too. ------------------------------------------------------------------------ [2005-09-08 17:30:22] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-09-08 16:12:16] zimage at icdsoft dot com Description: ------------ Output comes in chunks of about 8k and cannot be forced by using flush(), ob_flush() or output_buffering = Off I've tested with netcat to avoid browser buffering issues: echo -ne 'GET /buf.php HTTP/1.0\n\n' |nc 10.0.0.1 80 Reproduce code: --------------- <?php for ($i=0; $i<4; $i++){ echo "$i\n"; ob_flush(); flush(); sleep (1); } ?> Expected result: ---------------- When run under mod_php, cgi version or lighttpd+php/fastcgi there is one digit printed per second. Actual result: -------------- When run under apache 1.3.33 + php/fastcgi the entire output is printed at once. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34429&edit=1