10000 bug #60806 [HttpClient] Limit curl's connection cache size (nicolas-g… · symfony/symfony@c69616d · GitHub
[go: up one dir, main page]

Skip to content

Commit c69616d

Browse files
bug #60806 [HttpClient] Limit curl's connection cache size (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [HttpClient] Limit curl's connection cache size | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | #60513 | License | MIT Trying to accommodate for both #58278 and #60513 By default, $maxHostConnections is 6, so that this allows 50x6 = 300 connections max, which means one third of the typical `ulimit -n` (max open file descriptors), which is 1024. We could allow setting both options separately, but for now, as a bugfix, this might be enough. Commits ------- dfbe6c8 [HttpClient] Limit curl's connection cache size
2 parents f8cca42 + dfbe6c8 commit c69616d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct(int $maxHostConnections, int $maxPendingPushes)
5050
curl_multi_setopt($this->handle, \CURLMOPT_PIPELINING, \CURLPIPE_MULTIPLEX);
5151
}
5252
if (\defined('CURLMOPT_MAX_HOST_CONNECTIONS') && 0 < $maxHostConnections) {
53-
$maxHostConnections = curl_multi_setopt($this->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, $maxHostConnections) ? 4294967295 : $maxHostConnections;
53+
$maxHostConnections = curl_multi_setopt($this->handle, \CURLMOPT_MAX_HOST_CONNECTIONS, $maxHostConnections) ? min(50 * $maxHostConnections, 4294967295) : $maxHostConnections;
5454
}
5555
if (\defined('CURLMOPT_MAXCONNECTS') && 0 < $maxHostConnections) {
5656
curl_multi_setopt($this->handle, \CURLMOPT_MAXCONNECTS, $maxHostConnections);

0 commit comments

Comments
 (0)
0