Skip to content

Commit

Permalink
Close channels when close socket. (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo authored Mar 14, 2023
1 parent f154746 commit cf93625
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Client/SwooleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function connect(): void
public function close(): bool
{
$this->connected = false;
foreach ($this->recvChannels as $channel) {
$channel->close();
}

$this->recvChannels = [];

return $this->socket->close();
Expand Down
4 changes: 4 additions & 0 deletions src/Consumer/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ protected function fetchMessages(): void
}
$nodeId = key($this->fetchOptions);
next($this->fetchOptions);
if (empty($this->fetchOptions)) {
// avoid dead cycle.
sleep(1);
}
if (!$currentList) {
return;
}
Expand Down

0 comments on commit cf93625

Please sign in to comment.