Skip to content

Commit 9d8c013

Browse files
Merge branch '4.4' into 5.0
* 4.4: Fixed #35084 Add missing use statement [HttpClient] fix scheduling pending NativeResponse do not overwrite variable value [Profiler] wording Use spaces correctly to display options in DebugCommand X-Accel Nginx URL updated ticket-30197 [Validator] Add the missing translations for the Chinese (Taiwan) ("zh_TW") locale Fixed test added in #35022 Use locale_parse for computing fallback locales [Console] Fix filtering out identical alternatives when there is a command loader add note about HTTP status code change Migrate server:log command away from WebServerBundle [DependencyInjection][CheckTypeDeclarationsPass] Handle \Closure for callable [Security] Fix missing defaults for auto-migrating encoders bumped Symfony version to 4.4.3 updated VERSION for 4.4.2 updated CHANGELOG for 4.4.2
2 parents 14e77c6 + 54da8d5 commit 9d8c013

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

Internal/NativeClientState.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\HttpClient\Internal;
1313

14-
use Symfony\Component\HttpClient\Response\NativeResponse;
15-
1614
/**
1715
* Internal representation of the native client's state.
1816
*
@@ -24,8 +22,6 @@ final class NativeClientState extends ClientState
2422
{
2523
/** @var int */
2624
public $id;
27-
/** @var NativeResponse[] */
28-
public $pendingResponses = [];
2925
/** @var int */
3026
public $maxHostConnections = PHP_INT_MAX;
3127
/** @var int */

Response/NativeResponse.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,7 @@ private static function schedule(self $response, array &$runningResponses): void
230230
$runningResponses[$i] = [$response->multi, []];
231231
}
232232

233-
if (null === $response->remaining) {
234-
$response->multi->pendingResponses[] = $response;
235-
} else {
236-
$runningResponses[$i][1][$response->id] = $response;
237-
}
233+
$runningResponses[$i][1][$response->id] = $response;
238234

239235
if (null === $response->buffer) {
240236
// Response already completed
@@ -336,25 +332,30 @@ private static function perform(NativeClientState $multi, array &$responses = nu
336332
return;
337333
}
338334

339-
if ($multi->pendingResponses && \count($multi->handles) < $multi->maxHostConnections) {
340-
// Open the next pending request - this is a blocking operation so we do only one of them
341-
/** @var self $response */
342-
$response = array_shift($multi->pendingResponses);
343-
$response->open();
344-
$responses[$response->id] = $response;
345-
$multi->sleep = false;
346-
self::perform($response->multi);
347-
348-
if (null !== $response->handle) {
349-
$multi->handles[] = $response->handle;
335+
// Create empty activity lists to tell ResponseTrait::stream() we still have pending requests
336+
foreach ($responses as $i => $response) {
337+
if (null === $response->remaining && null !== $response->buffer) {
338+
$multi->handlesActivity[$i] = [];
350339
}
351340
}
352341

353-
if ($multi->pendingResponses) {
354-
// Create empty activity list to tell ResponseTrait::stream() we still have pending requests
355-
$response = $multi->pendingResponses[0];
356-
$responses[$response->id] = $response;
357-
$multi->handlesActivity[$response->id] = [];
342+
if (\count($multi->handles) >= $multi->maxHostConnections) {
343+
return;
344+
}
345+
346+
// Open the next pending request - this is a blocking operation so we do only one of them
347+
foreach ($responses as $i => $response) {
348+
if (null === $response->remaining && null !== $response->buffer) {
349+
$response->open();
350+
$multi->sleep = false;
351+
self::perform($multi);
352+
353+
if (null !== $response->handle) {
354+
$multi->handles[] = $response->handle;
355+
}
356+
357+
break;
358+
}
358359
}
359360
}
360361

0 commit comments

Comments
 (0)