private function doStop() : \Generator
{
assert($this->logDebug("stopping"));
$this->state = self::STOPPING;
foreach ($this->acceptWatcherIds as $watcherId) {
\Amp\cancel($watcherId);
}
$this->boundServers = [];
$this->acceptWatcherIds = [];
foreach ($this->pendingTlsStreams as list(, $socket)) {
$this->failCryptoNegotiation($socket, key($this->clientsPerIP));
}
$this->stopPromisor = new Deferred();
if (empty($this->clients)) {
$this->stopPromisor->succeed();
} else {
foreach ($this->clients as $client) {
if (empty($client->requestCycles)) {
$this->close($client);
} else {
$client->remainingKeepAlives = PHP_INT_MIN;
}
}
}
(yield all([$this->stopPromisor->promise(), $this->notify()]));
assert($this->logDebug("stopped"));
$this->state = self::STOPPED;
$this->stopPromisor = null;
(yield $this->notify());
}