8000 [HttpClient] Fix Failed to open stream: Too many open files · symfony/symfony@a548fe5 · GitHub
[go: up one dir, main page]

Skip to content

Commit a548fe5

Browse files
committed
[HttpClient] Fix Failed to open stream: Too many open files
1 parent d560800 commit a548fe5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Symfony/Component/HttpClient/Internal/CurlClientState.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ public function __construct(int $maxHostConnections, int $maxPendingPushes)
6565
return;
6666
}
6767

68-
curl_multi_setopt($this->handle, \CURLMOPT_PUSHFUNCTION, function ($parent, $pushed, array $requestHeaders) use ($maxPendingPushes) {
69-
return $this->handlePush($parent, $pushed, $requestHeaders, $maxPendingPushes);
68+
// Keep a dummy "onPush" reference to work around a refcount bug in PHP
69+
curl_multi_setopt($this->handle, \CURLMOPT_PUSHFUNCTION, $this->onPush = static function ($parent, $pushed, array $requestHeaders) use ($maxPendingPushes) {
70+
return self::handlePush($parent, $pushed, $requestHeaders, $maxPendingPushes);
7071
});
7172
}
7273

@@ -92,7 +93,7 @@ public function reset()
9293
}
9394
}
9495

95-
private function handlePush($parent, $pushed, array $requestHeaders, int $maxPendingPushes): int
96+
private static function handlePush($parent, $pushed, array $requestHeaders, int $maxPendingPushes): int
9697
{
9798
$headers = [];
9899
$origin = curl_getinfo($parent, \CURLINFO_EFFECTIVE_URL);

0 commit comments

Comments
 (0)
0