Skip to content

Commit a5a467b

Browse files
committed
Merge branch '5.3' into 5.4
* 5.3: Throw exception if incompatible version of psr/simple-cache is used [DependencyInjection] copy synthetic status when resolving child definitions [HttpClient] Fix Failed to open stream: Too many open files [Console] use STDOUT/ERR in ConsoleOutput to save opening too many file descriptors [Cache] Set mtime of cache files 1 year into future if they do not expire [DependencyInjection] remove arbitratry limitation to exclude inline services from bindings
2 parents 1a407eb + 692eace commit a5a467b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Internal/CurlClientState.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
*/
2424
final class CurlClientState extends ClientState
2525
{
26-
/** @var \CurlMultiHandle|resource */
26+
/** @var \CurlMultiHandle|resource|null */
2727
public $handle;
28-
/** @var \CurlShareHandle|resource */
28+
/** @var \CurlShareHandle|resource|null */
2929
public $share;
3030
/** @var PushedResponse[] */
3131
public $pushedResponses = [];
@@ -68,8 +68,17 @@ public function __construct(int $maxHostConnections, int $maxPendingPushes)
6868
return;
6969
}
7070

71-
curl_multi_setopt($this->handle, \CURLMOPT_PUSHFUNCTION, function ($parent, $pushed, array $requestHeaders) use ($maxPendingPushes) {
72-
return $this->handlePush($parent, $pushed, $requestHeaders, $maxPendingPushes);
71+
// Clone to prevent a circular reference
72+
$multi = clone $this;
73+
$multi->handle = null;
74+
$multi->share = null;
75+
$multi->pushedResponses = &$this->pushedResponses;
76+
$multi->logger = &$this->logger;
77+
$multi->handlesActivity = &$this->handlesActivity;
78+
$multi->openHandles = &$this->openHandles;
79+
80+
curl_multi_setopt($this->handle, \CURLMOPT_PUSHFUNCTION, static function ($parent, $pushed, array $requestHeaders) use ($multi, $maxPendingPushes) {
81+
return $multi->handlePush($parent, $pushed, $requestHeaders, $maxPendingPushes);
7382
});
7483
}
7584

0 commit comments

Comments
 (0)