mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 10:38:59 +01:00
Fix some issues + memory leak
This commit is contained in:
parent
8e24ce92a3
commit
df04c79111
@ -430,7 +430,7 @@ final class API extends InternalDoc
|
||||
$this->report("Surfaced: $e");
|
||||
}
|
||||
);
|
||||
$this->startAndLoopAsync($eventHandler, $started);
|
||||
$this->startAndLoopInternal($eventHandler, $started);
|
||||
}
|
||||
/**
|
||||
* Start multiple instances of MadelineProto and the event handlers (enables async).
|
||||
@ -476,7 +476,7 @@ final class API extends InternalDoc
|
||||
foreach ($instances as $k => $instance) {
|
||||
$instance->start();
|
||||
$promises []= async(function () use ($k, $instance, $eventHandler, &$started): void {
|
||||
$instance->startAndLoopAsync($eventHandler[$k], $started[$k]);
|
||||
$instance->startAndLoopInternal($eventHandler[$k], $started[$k]);
|
||||
});
|
||||
}
|
||||
await($promises);
|
||||
@ -489,7 +489,7 @@ final class API extends InternalDoc
|
||||
*
|
||||
* @param string $eventHandler Event handler class name
|
||||
*/
|
||||
private function startAndLoopAsync(string $eventHandler, bool &$started): void
|
||||
private function startAndLoopInternal(string $eventHandler, bool &$started): void
|
||||
{
|
||||
$this->start();
|
||||
if (!$this->reconnectFull()) {
|
||||
|
@ -28,6 +28,7 @@ use danog\MadelineProto\SecurityException;
|
||||
use danog\MadelineProto\SessionPaths;
|
||||
use danog\MadelineProto\Settings\Ipc;
|
||||
use danog\MadelineProto\Shutdown;
|
||||
use Revolt\EventLoop;
|
||||
use Revolt\EventLoop\UncaughtThrowable;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
@ -114,7 +115,6 @@ use Webmozart\Assert\Assert;
|
||||
while (true) {
|
||||
try {
|
||||
Server::waitShutdown();
|
||||
Shutdown::removeCallback('restarter');
|
||||
Logger::log('A restart was triggered!', Logger::FATAL_ERROR);
|
||||
return;
|
||||
} catch (Throwable $e) {
|
||||
|
@ -68,6 +68,9 @@ trait UpdateHandler
|
||||
$this->updateHandlerType = UpdateHandlerType::NOOP;
|
||||
$this->updates = [];
|
||||
$this->updates_key = 0;
|
||||
$this->event_handler = null;
|
||||
$this->event_handler_instance = null;
|
||||
$this->eventHandlerMethods = [];
|
||||
$this->startUpdateSystem();
|
||||
}
|
||||
/**
|
||||
@ -86,6 +89,9 @@ trait UpdateHandler
|
||||
\array_map($this->handleUpdate(...), $this->updates);
|
||||
$this->updates = [];
|
||||
$this->updates_key = 0;
|
||||
$this->event_handler = null;
|
||||
$this->event_handler_instance = null;
|
||||
$this->eventHandlerMethods = [];
|
||||
$this->startUpdateSystem();
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace danog\MadelineProto\Wrappers;
|
||||
|
||||
use __PHP_Incomplete_Class;
|
||||
use danog\MadelineProto\EventHandler;
|
||||
use danog\MadelineProto\Exception;
|
||||
use danog\MadelineProto\Settings;
|
||||
@ -118,7 +119,7 @@ trait Events
|
||||
/**
|
||||
* Get event handler.
|
||||
*/
|
||||
public function getEventHandler(): ?EventHandler
|
||||
public function getEventHandler(): EventHandler|__PHP_Incomplete_Class|null
|
||||
{
|
||||
return $this->event_handler_instance;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user