Skip to content

Commit 1f4a222

Browse files
committed
Do not set $this->promise on connection creation
1 parent 294ad69 commit 1f4a222

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

lib/AbstractPool.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ private function pop(): \Generator {
110110
}
111111

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

120116
while ($this->idle->isEmpty()) { // While loop to ensure an idle connection is available after promises below are resolved.
@@ -125,20 +121,15 @@ private function pop(): \Generator {
125121
yield $this->promise = $this->deferred->promise(); // May be resolved with defunct connection.
126122
} finally {
127123
$this->deferred = null;
128-
if ($this->pending === 0) {
129-
$this->promise = null;
130-
}
124+
$this->promise = null;
131125
}
132126
} else {
133127
// Max connection count has not been reached, so open another connection.
134128
++$this->pending;
135129
try {
136-
$this->promise = $this->createConnection();
137-
$connection = yield $this->promise;
130+
$connection = yield $this->createConnection();
138131
} finally {
139-
if (--$this->pending === 0) {
140-
$this->promise = null;
141-
}
132+
--$this->pending;
142133
}
143134

144135
$this->connections->attach($connection);

0 commit comments

Comments
 (0)