php5-curl not flushing files to disk correctly until script exits
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
php5 (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: php5
Package: php5-curl
Distribution: Ubuntu 9.10
uname -a:
Linux administrator-
apt-cache policy php5-curl
php5-curl:
Installed: 5.2.10.
Candidate: 5.2.10.
Version table:
*** 5.2.10.
500 http://
500 http://
100 /var/lib/
5.
500 http://
php5:
Installed: 5.2.10.
Candidate: 5.2.10.
Version table:
*** 5.2.10.
500 http://
500 http://
100 /var/lib/
5.
500 http://
Ran the following script which uses curl to download file from a remote web server:
<?php
$ch = curl_init();
echo "Downloading.
curl_setopt($ch, CURLOPT_TIMEOUT, '600');
curl_setopt($ch, CURLOPT_URL, "http://
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_
curl_setopt( $ch, CURLOPT_
$fp = fopen("
if ( $fp )
{
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec ($ch);
curl_close ($ch);
fclose($fp);
}
for( $i = 0; $i < 3; $i++ )
{
echo filesize( "/tmp/bzImage" ) . "\n";
sleep( 10 );
}
?>
Expected:
file size to report the real size of 4142832 bytes
using
ls -l
during the running of the script (before it terminates) returns a filesize of 4141056 but it should return 4142832 as it does when the script exits.
This was confirmed on two desktops, and functions correctly on Fedora 9
This is a problem is you are chain operations in the same script, because it appears as if the file doesn't get flushed to disk. So for example, we attempt to ftp the file off after download, but it is corrupted as only 4141056 bytes are sent.
Thanks in advance for any help you can provide.
I was not able to reproudce this on php 5.2.11.
Regards
chuck