Re: Outputting File To The Browser Failed And Kill Apache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



if the problem is due to flow control issues between the script and the
httpd server then perhaps changing the approach could help.

i quit using this approach of writing files to the php output buffer a
little while ago. it seemed that it was better to leave the flow control
issues entirely to apache. so i wrote the file to a specific directory on
the server and redirected the client to it, using the apache directive on
that directory:
    Header set Content-Disposition attachment

you can use that directive to send whatever headers you need.


On 6/5/09 3:52 PM, "Nitsan Bin-Nun" <nitsan@xxxxxxxxxxxx> wrote:

> Hi List,
> 
> I'm using the following code to output a file to the browser. Each file size
> is in the range of 5-10MB, all of them are MP3.
> 
> header("Pragma: public");
>> header("Expires: 0");
>> header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
>> header("Cache-Control: public");
>> header("Content-Description: File Transfer");
>> header("Content-Type: {$info['mimetype']}");
>> header("Content-Disposition: attachment;
>> filename=\"{$info['filename']}\"");
>> header("Content-Transfer-Encoding: binary");
>> header("Content-Length: " . $info['size']);
>> 
>> set_time_limit(0);
>> 
>> $file =
>> @fopen($config['storage'][$config['current_storage']].$info['md5'].".".$info[
>> 'extension'],"rb");
>> if ($file) {
>>     while(!feof($file)) {
>>         print(fread($file, 1024*8));
>>         flush();
>>         if (connection_status()!=0) {
>>             @fclose($file);
>>             die();
>>         }
>>     }
>>     @fclose($file);
>> }
> 
> 
> 
> I'm running this script on a VPS which has a 10MBIT connection. When I
> posted a link to this download stream php file about 50 users started
> download it, then the script stopped from sending the whole file (for
> instance, the file is 5MB, the script sends 2MB, 1MB and it continue this
> way).
> 
> In the apache log file I have seen these lines, but I have no idea what are
> their meaning:
> 
> [Fri Jun 05 22:02:28 2009] [error] (12)Cannot allocate memory: fork: Unable
>> to fork new process
>> [Fri Jun 05 22:02:38 2009] [error] (12)Cannot allocate memory: fork: Unable
>> to fork new process
>> [Fri Jun 05 22:02:48 2009] [error] (12)Cannot allocate memory: fork: Unable
>> to fork new process
>> [Fri Jun 05 22:11:35 2009] [error] (12)Cannot allocate memory: fork: Unable
>> to fork new process
>> 
> 
> 
> I have no idea what's going on. Any ideas to solve this issue will be very
> appreciated. My 12K users are suffering right now, I would really really
> appreciate any idea in the right direction :) :) :)
> 
> Thank you!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux