Skip to content

Commit

Permalink
Do not set $this->promise on connection creation
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Dec 15, 2017
1 parent 294ad69 commit 1f4a222
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lib/AbstractPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ private function pop(): \Generator {
}

while ($this->promise !== null && $this->connections->count() + $this->pending >= $this->getMaxConnections()) {
try {
yield $this->promise; // Prevent simultaneous connection creation when connection count is at maximum - 1.
} catch (\Throwable $exception) {
// Ignore failure or cancellation of other operations.
}
yield $this->promise; // Prevent simultaneous connection creation when connection count is at maximum - 1.
}

while ($this->idle->isEmpty()) { // While loop to ensure an idle connection is available after promises below are resolved.
Expand All @@ -125,20 +121,15 @@ private function pop(): \Generator {
yield $this->promise = $this->deferred->promise(); // May be resolved with defunct connection.
} finally {
$this->deferred = null;
if ($this->pending === 0) {
$this->promise = null;
}
$this->promise = null;
}
} else {
// Max connection count has not been reached, so open another connection.
++$this->pending;
try {
$this->promise = $this->createConnection();
$connection = yield $this->promise;
$connection = yield $this->createConnection();
} finally {
if (--$this->pending === 0) {
$this->promise = null;
}
--$this->pending;
}

$this->connections->attach($connection);
Expand Down

0 comments on commit 1f4a222

Please sign in to comment.