Bug #72202 [NEW]: curl_close don't close cURL handle on curl_multi

From: Date: Wed, 11 May 2016 21:57:39 +0000
Subject: Bug #72202 [NEW]: curl_close don't close cURL handle on curl_multi
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201025@lists.php.net to get a copy of this message
From: torsten dot burschka at gmail dot com Operating system: ArchLinux PHP version: 7.0.6 Package: cURL related Bug Type: Bug Bug description:curl_close don't close cURL handle on curl_multi Description: ------------ A cURL ressource seem to be not closed correctly after using it with curl_multi_exec. According to this answer on stackoverflow http://stackoverflow.com/a/23007037/363323 the handle should be removed since the internal counter should be 0 after curl_multi_remove_handle and curl_close should do the rest... Test script: --------------- $ch1 = curl_init(); $ch2 = curl_init(); curl_setopt($ch1, CURLOPT_URL, 'http://lxr.php.net/'); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch2, CURLOPT_URL, 'http://www.php.net/'); curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1); $cmh = curl_multi_init(); curl_multi_add_handle($cmh, $ch1); curl_multi_add_handle($cmh, $ch2); $status = curl_multi_exec($cmh, $active); $innerSleepInt = $outerSleepInt = 1; while ($active && ($status === CURLM_OK || $status === CURLM_CALL_MULTI_PERFORM)) { usleep((int)$outerSleepInt); $outerSleepInt = (int) max(1, $outerSleepInt * 1.1); $multiSelect = curl_multi_select($cmh, 0); /* @see https://bugs.php.net/bug.php?id=63411 */ if ($multiSelect === -1) { usleep(100000); } /* @see https://curl.haxx.se/libcurl/c/libcurl-errors.html */ if ($multiSelect >= CURLM_CALL_MULTI_PERFORM) { do { $status = curl_multi_exec($cmh, $active); usleep((int) $innerSleepInt); $innerSleepInt = (int) max(1, $innerSleepInt * 1.1); } while ($status === CURLM_CALL_MULTI_PERFORM); $innerSleepInt = 1; } while ($done = curl_multi_info_read($cmh)) { $ch = $done['handle']; curl_multi_getcontent($ch); curl_multi_remove_handle($cmh, $ch); curl_close($ch); echo is_resource($ch); // this should be return false } } -- Edit bug report at https://bugs.php.net/bug.php?id=72202&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72202&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72202&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72202&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72202&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72202&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72202&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72202&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72202&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72202&r=support Expected behavior: https://bugs.php.net/fix.php?id=72202&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72202&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72202&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72202&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72202&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72202&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72202&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72202&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72202&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72202&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72202&r=mysqlcfg

« previous php.bugs (#201025) next »