|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2016-05-11 21:57 UTC] torsten dot burschka at gmail dot com
 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 } } PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 07:00:01 2025 UTC | 
Broken commit: commit 3ba4f8263d7940312668f4c364c988a67be2461a Author: Dmitry Stogov <dmitry@zend.com> Date: Tue May 13 16:00:44 2014 +0400 Fixed curl_close() behavior I'm not sure what this commit is supposed to fix, it looks wrong to me.