php5-curl not flushing files to disk correctly until script exits

Bug #497559 reported by Chuck
8
This bug affects 1 person
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-desktop 2.6.31-16-generic-pae #53-Ubuntu SMP Tue Dec 8 05:20:21 UTC 2009 i686 GNU/Linux

apt-cache policy php5-curl

php5-curl:
  Installed: 5.2.10.dfsg.1-2ubuntu6.3
  Candidate: 5.2.10.dfsg.1-2ubuntu6.3
  Version table:
 *** 5.2.10.dfsg.1-2ubuntu6.3 0
        500 http://us.archive.ubuntu.com karmic-updates/main Packages
        500 http://security.ubuntu.com karmic-security/main Packages
        100 /var/lib/dpkg/status
     5.2.10.dfsg.1-2ubuntu6 0
        500 http://us.archive.ubuntu.com karmic/main Packages

php5:
  Installed: 5.2.10.dfsg.1-2ubuntu6.3
  Candidate: 5.2.10.dfsg.1-2ubuntu6.3
  Version table:
 *** 5.2.10.dfsg.1-2ubuntu6.3 0
        500 http://us.archive.ubuntu.com karmic-updates/main Packages
        500 http://security.ubuntu.com karmic-security/main Packages
        100 /var/lib/dpkg/status
     5.2.10.dfsg.1-2ubuntu6 0
        500 http://us.archive.ubuntu.com karmic/main Packages

Ran the following script which uses curl to download file from a remote web server:

<?php
$ch = curl_init();
echo "Downloading....\n";
curl_setopt($ch, CURLOPT_TIMEOUT, '600');
curl_setopt($ch, CURLOPT_URL, "http://downloads.sourceforge.net/freeghost/Kernel-2.6.32.1.kitchensink" );
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_BINARYTRANSFER, 1 );
$fp = fopen("/tmp/bzImage", 'wb');
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.

Revision history for this message
Chuck (csyperski-gmail) wrote :
Revision history for this message
Chuck Short (zulcss) wrote :

I was not able to reproudce this on php 5.2.11.

Regards
chuck

Changed in php5 (Ubuntu):
status: New → Fix Released
Revision history for this message
Chuck (csyperski-gmail) wrote :

How can I test 5.2.11, I am not seeing it in the repo?

I am running:

PHP 5.2.10-2ubuntu6.3 with Suhosin-Patch 0.9.7 (cli) (built: Nov 26 2009 14:42:49)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies

Changed in php5 (Ubuntu):
status: Fix Released → Fix Committed
status: Fix Committed → In Progress
Revision history for this message
Neile Havens (neile-havens) wrote :

You can test with 5.2.11 by downloading the package from the lucid repository. It depends on php5-common, so you need to install both of these packages. Here are urls for downloading from a mirror:
http://mirrors.kernel.org/ubuntu/pool/main/p/php5/php5-common_5.2.11.dfsg.1-2ubuntu1_i386.deb
http://mirrors.kernel.org/ubuntu/pool/main/p/php5/php5-curl_5.2.11.dfsg.1-2ubuntu1_i386.deb

Install with:
sudo dpkg -i php5-c*

Rerunning the test script after installing 5.2.11 returns 4142832 as the file size (aka it works as expected). Any chance this version will be released to karmic?

Revision history for this message
Chuck Short (zulcss) wrote :

This is fixed in lucid.

Regards
chuck

Changed in php5 (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.