#50477 [Com]: curl_close() does not delete cURL handle as expected
ID: 50477
Comment by: pcdinh at gmail dot com
Reported By: pcdinh at gmail dot com
Status: No Feedback
Bug Type: cURL related
Operating System: Windows XP
PHP Version: 5.2.11
New Comment:
This bug still exists in 5.2.12
Previous Comments:
------------------------------------------------------------------------
[2009-12-23 01:00:01] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2009-12-15 11:34:08] jani@php.net
Please try using this snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
------------------------------------------------------------------------
[2009-12-15 11:05:06] pcdinh at gmail dot com
Description:
------------
As stated at http://php.net/manual/en/function.curl-close.php
an
invocation to curl_close($ch) will
"Closes a cURL session and frees all resources. The cURL handle, ch ,
is also deleted. "
However, it does not.
Curl seems to work differently than other functions that produce a
resource as well. Curl does not pass by reference implicitly
For example:
// create an image resource
$image = imagecreate(100, 100);
$im = new stdClass();
$im->res = $image; // pass by reference
var_dump($image);
var_dump($im->res);
imagedestroy($image);
var_dump($image); // will print resource(4) of type (Unknown)
var_dump($im->res); // will print resource(4) of type (Unknown)
After calling imagedestroy($image), $image and $im->res are deleted
Reproduce code:
---------------
$s = curl_init();
$im = new stdClass();
$im->res = $s; // resource is passed by reference
var_dump($s); // will print: resource(5) of type (curl)
var_dump($im->res); // will print: resource(5) of type (curl)
curl_close($s);
var_dump($s);
var_dump($im->res);
Expected result:
----------------
$s = curl_init();
$im = new stdClass();
$im->res = $s; // resource is passed by reference
var_dump($s); // will print: resource(5) of type (curl)
var_dump($im->res); // will print: resource(5) of type (curl)
curl_close($s);
var_dump($s); // (expected): resource(5) of type (Unknown)
var_dump($im->res); // (expected): resource(5) of type (Unknown)
Actual result:
--------------
$s = curl_init();
$im = new stdClass();
$im->res = $s; // resource is actually passed by value
var_dump($s); // will print: resource(5) of type (curl)
var_dump($im->res); // will print: resource(5) of type (curl)
curl_close($s);
var_dump($s); // (actual): resource(5) of type (curl)
var_dump($im->res); // (actual): resource(5) of type (curl)
$s becomes invalid but $im->res is still valid for subsequent
operations.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50477&edit=1
Thread (5 messages)