ID:               44866
 User updated by:  david at acz dot org
 Reported By:      david at acz dot org
 Status:           Bogus
 Bug Type:         cURL related
 Operating System: SLES 10 x86_64
 PHP Version:      5.2.5
 New Comment:

That does not help for long running (e.g. CLI) scripts.


Previous Comments:
------------------------------------------------------------------------

[2008-05-09 18:03:49] david at acz dot org

That does not help for long-running (e.g. CLI) scripts.

------------------------------------------------------------------------

[2008-05-05 23:04:03] [EMAIL PROTECTED]

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

The file will be closed at the end of the request.

------------------------------------------------------------------------

[2008-04-30 01:05:03] david at acz dot org

Description:
------------
File handles are normally closed automatically when the reference count
hits zero.  For example, if you fopen() something in a function and only
assign it to a local variable, the file is closed when the function
returns.

CURLOPT_INFILE breaks this behavior.  Presumably, the curl resource
destructor does not decrement the reference count for the file handle.  

Reproduce code:
---------------
<?
    $name = tempnam("/tmp", "phpbug");
    $n = count(scandir("/proc/self/fd"));

    test_simple($name);
    var_dump(count(scandir("/proc/self/fd")) == $n);

    test_curl($name, true);
    var_dump(count(scandir("/proc/self/fd")) == $n);

    test_curl($name, false);
    var_dump(count(scandir("/proc/self/fd")) == $n);

    function test_simple($name)
    {
        $fp = fopen($name, "r");
    }

    function test_curl($name, $close)
    {
        $fp = fopen($name, "r");
        $c = curl_init();
        curl_setopt($c, CURLOPT_PUT, true);
        curl_setopt($c, CURLOPT_INFILE, $fp);
        curl_setopt($c, CURLOPT_INFILESIZE, 0);
        curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
        curl_exec($c);
        curl_close($c);
        if ($close)
            fclose($fp);
    }
?>


Expected result:
----------------
bool(true)
bool(true)
bool(true)


Actual result:
--------------
bool(true)
bool(true)
bool(false)



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44866&edit=1

Reply via email to