mirror of
https://github.com/danog/MadelineProto.git
synced 2025-01-22 18:11:24 +01:00
Fix race condition
This commit is contained in:
parent
757f7dbf9e
commit
25267a0ea8
@ -250,9 +250,16 @@ class API extends InternalDoc
|
|||||||
[$result] = yield from Serialization::tryConnect($this->session->getIpcPath(), $cancel->promise());
|
[$result] = yield from Serialization::tryConnect($this->session->getIpcPath(), $cancel->promise());
|
||||||
if ($result instanceof ChannelledSocket) {
|
if ($result instanceof ChannelledSocket) {
|
||||||
try {
|
try {
|
||||||
|
if (!$this->API instanceof Client) {
|
||||||
|
$this->logger->logger("Restarting to full instance (again): the bot is already running!");
|
||||||
|
yield $result->disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
$API = new Client($result, $this->session, Logger::$default, $this->async);
|
$API = new Client($result, $this->session, Logger::$default, $this->async);
|
||||||
if (yield from $API->hasEventHandler()) {
|
if (yield from $API->hasEventHandler()) {
|
||||||
$this->logger->logger("Restarting to full instance (again): the bot is already running!");
|
$this->logger->logger("Restarting to full instance (again): the bot is already running!");
|
||||||
|
yield $API->disconnect();
|
||||||
|
$API->unreference();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->logger->logger("Restarting to full instance: stopping another IPC server...");
|
$this->logger->logger("Restarting to full instance: stopping another IPC server...");
|
||||||
@ -310,6 +317,7 @@ class API extends InternalDoc
|
|||||||
// Success, full session
|
// Success, full session
|
||||||
if ($this->API) {
|
if ($this->API) {
|
||||||
$this->API->unreference();
|
$this->API->unreference();
|
||||||
|
$this->API = null;
|
||||||
}
|
}
|
||||||
$unserialized->storage = $unserialized->storage ?? [];
|
$unserialized->storage = $unserialized->storage ?? [];
|
||||||
$unserialized->session = $this->session;
|
$unserialized->session = $this->session;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user