php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19485 Buffer output even when output_buffering = Off
Submitted: 2002-09-18 19:32 UTC Modified: 2002-09-19 14:25 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dnordenberg at users dot sourceforge dot net Assigned:
Status: Closed Package: Output Control
PHP Version: 4.2.3 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 2 = ?
Subscribe to this entry?

 
 [2002-09-18 19:32 UTC] dnordenberg at users dot sourceforge dot net
I have set output_buffering to Off and tried something as simple as this:
playmp3.php
<?
readfile("mymp3.mp3");
?>
And the entire output is buffered somewhere. I tried to open the url to the playmp3.php file in winamp and my server hdd LED lights up for about 8 seconds, after that winamp shows it is buffring for about 0.2 sec (LAN connection to the server) and then starts playing. Nothing is outputed from the server while the hdd LED is on and my slow server is terrible busy :( Sometimes the buffering takes more then 10 sec and winamp will time out. I'm using Apache 2.0.40 also.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-19 11:02 UTC] dnordenberg at users dot sourceforge dot net
Maybe I should add that if I try to listen to a mp3 file directly from a URL to my server without using a script like in my example, winamp will immediately start buffering for about 0,2 sec and then start playing, almost like it was from a local harddive so it is not my server that is that slow (p166, SCSI disks). The mp3 file I'm testing with is 6,6Mb, I don't want to think about how my server will suffer when trying to load a 100Mb mp3 :(
 [2002-09-19 14:25 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Since the file is local and your OS supports mmap, PHP will try mapping the file to memory before sending it out. Which, is what is responsible for the delay, if the file is very big or you have little memory this can take a while, since it may need to use swap to load the file. After the file has been loaded, PHP begin sending the file to the browser.
Apache by default does not use mmap, unless you use mmap_static module, so instead it opens the file and begins  to read it in chunks and immidiately send the read chunks to the browser.

In majority of cases using mmap will be faster then reading data in chunks.
 [2002-09-19 17:43 UTC] dnordenberg at users dot sourceforge dot net
Hi, thanks for your answere. So there is really no way of getting around this? Even if I really don't want to use memory mapping? It would be nice to be able to atleast temporary disable it since it is obviusly not suitable for all contents. I don't want to publish my entire mp3 archive online but I want a interface to it so it is accessible by the ones who should, therefor I want to stream the file trough PHP.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 22:01:31 2024 UTC