Skip to content

Commit ec4a1d6

Browse files
authored
Fixed bug that the recv channel cannot be found, because GrpcClient::runReceiveCoroutine will unset streamId before recv method. (#6350)
1 parent 4e25af5 commit ec4a1d6

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/GrpcClient.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,14 @@ public function recv(int $streamId, float $timeout = null)
238238
if ($response === false && $channel->errCode === SWOOLE_CHANNEL_TIMEOUT) {
239239
unset($this->recvChannelMap[$streamId]);
240240
}
241+
// Unset recvChannelMap arfter recv
242+
if (! $response->pipeline) {
243+
unset($this->recvChannelMap[$streamId]);
244+
if (! $channel->isEmpty()) {
245+
$channel->pop();
246+
}
247+
$this->channelPool->push($channel);
248+
}
241249

242250
return $response;
243251
}
@@ -303,13 +311,6 @@ private function runReceiveCoroutine()
303311
}
304312
$channel = $this->recvChannelMap[$streamId];
305313
$channel->push($response);
306-
if (! $response->pipeline) {
307-
unset($this->recvChannelMap[$streamId]);
308-
if (! $channel->isEmpty()) {
309-
$channel->pop();
310-
}
311-
$this->channelPool->push($channel);
312-
}
313314
// If wait status is equal to WAIT_CLOSE, and no coroutine is waiting, then break the recv loop.
314315
if ($this->waitStatus === Status::WAIT_CLOSE && empty($this->recvChannelMap)) {
315316
break;

0 commit comments

Comments
 (0)