[HttpClient] Fix a crash when calling CurlHttpClient::__destruct()

This commit is contained in:
Kévin Dunglas 2019-11-08 00:12:08 +01:00 committed by Nicolas Grekas
parent 4056baf0f4
commit d2c5ffda52

View File

@ -301,15 +301,20 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
public function __destruct()
{
$this->multi->pushedResponses = [];
if (\defined('CURLMOPT_PUSHFUNCTION')) {
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
if (\is_resource($this->multi->handle)) {
if (\defined('CURLMOPT_PUSHFUNCTION')) {
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
}
$active = 0;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
}
$active = 0;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
foreach ($this->multi->openHandles as [$ch]) {
curl_setopt($ch, CURLOPT_VERBOSE, false);
if (\is_resource($ch)) {
curl_setopt($ch, CURLOPT_VERBOSE, false);
}
}
}