|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-03-28 04:32 UTC] loony at loonybin dot org
Description: ------------ Tail for php. Open the file, output the current content... then wait for more - if no more content arrives, then return number of bytes read after a while... Running 1 execution of this code works fine. Executing it from two browsers at the same time blocks. Happens on Fedora Core 6 default 5.1.6 and also after upgrading to 5.2.1 Reproduce code: --------------- http://ns1.loonybin.org/php/tail.tar.gz - 45 lines Expected result: ---------------- See content of file printed immediately. If any content is appended to the file within 15 seconds from request start, that content should be printed as well. This works with 1 execution of the code. Should yield same result if executed multiple times. Actual result: -------------- 1 run of the code works. Multiple executions however block on semop / epoll_wait. semop(4358158, 0x15470c, 1) = 0 <2.194313> epoll_wait(16, {{EPOLLIN, {u32=2156798632, u64=13801426109869204136}}}, 2, -1) = 1 <3.738842> As soon as the first execution of the code has ended, the second will run as expected and finish successfully (as long as max_execution_time is not reached). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 17:00:01 2025 UTC |
This test script works for me with Apache 2.2 when I access it from two different machines: <html> <body> <pre> <?php function tail ($file, $timeout) { $f = fopen ($file, "r"); if (!$f) { return false; } if (!stream_set_blocking ($f, 0)) { return false; } $curDel = 0; while ($curDel < $timeout) { $s = fread ($f, 8192); if ($s) { // got data do { echo $s; } while ( $s = fread ($f, 8192) ); flush(); $curDel = 0; } else { // got no data sleep (1); $curDel += 1; } } fclose ($f); } echo getmypid() . " - " . date("s") . "\n"; flush(); tail ("/tmp/test", 15); ?> </pre> </body> </html> What SAPI are you using? I found problems with FastCGI and flush()..