mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 09:58:59 +01:00
Some sanity checks
This commit is contained in:
parent
e54689d9aa
commit
5c91a6e39f
@ -339,7 +339,9 @@ final class API extends InternalDoc
|
||||
*/
|
||||
public static function finalize(): void
|
||||
{
|
||||
await(self::$destructors);
|
||||
if (self::$destructors) {
|
||||
await(self::$destructors);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Destruct function.
|
||||
|
@ -35,6 +35,7 @@ use danog\MadelineProto\Stream\ConnectionContext;
|
||||
use danog\MadelineProto\Stream\MTProtoBufferInterface;
|
||||
use danog\MadelineProto\Stream\MTProtoTransport\HttpsStream;
|
||||
use danog\MadelineProto\Stream\MTProtoTransport\HttpStream;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
/**
|
||||
* Connection class.
|
||||
@ -280,14 +281,14 @@ final class Connection
|
||||
unset($this->new_outgoing[$message_id], $this->outgoing_messages[$message_id]);
|
||||
}
|
||||
}
|
||||
$this->writer->start();
|
||||
$this->reader->start();
|
||||
if (!$this->checker->start()) {
|
||||
$this->checker->resume();
|
||||
Assert::true($this->writer->start());
|
||||
Assert::true($this->reader->start());
|
||||
Assert::true($this->checker->start());
|
||||
Assert::true($this->cleanup->start());
|
||||
Assert::true($this->waiter->start());
|
||||
if ($this->pinger) {
|
||||
Assert::true($this->pinger?->start());
|
||||
}
|
||||
$this->cleanup->start();
|
||||
$this->waiter->start();
|
||||
$this->pinger?->start();
|
||||
}
|
||||
/**
|
||||
* Apply method abstractions.
|
||||
|
@ -131,14 +131,31 @@ final class GarbageCollector
|
||||
$memory = \round(\memory_get_usage()/1024/1024, 1);
|
||||
if (!Magic::$suspendPeriodicLogging) {
|
||||
Logger::log("Memory consumption: $memory Mb", Logger::ULTRA_VERBOSE);
|
||||
/*$fibers = self::$map->count();
|
||||
Logger::log("Running fibers: $fibers", Logger::ULTRA_VERBOSE);
|
||||
/*foreach (self::$map as $fiber => $_) {
|
||||
if ($fiber->isTerminated()) continue;
|
||||
if (!$fiber->isStarted()) continue;
|
||||
/*$k = 0;
|
||||
foreach (self::$map as $fiber => $_) {
|
||||
if ($k++ === 0) {
|
||||
continue;
|
||||
}
|
||||
if ($fiber->isTerminated()) {
|
||||
continue;
|
||||
}
|
||||
if (!$fiber->isStarted()) {
|
||||
continue;
|
||||
}
|
||||
$reflection = new ReflectionFiber($fiber);
|
||||
Logger::log($reflection->getExecutingFile(), Logger::ULTRA_VERBOSE);
|
||||
}*/
|
||||
|
||||
$tlTrace = '';
|
||||
foreach ($reflection->getTrace() as $k => $frame) {
|
||||
$tlTrace .= isset($frame['file']) ? \str_pad(\basename($frame['file']).'('.$frame['line'].'):', 20)."\t" : '';
|
||||
$tlTrace .= isset($frame['function']) ? $frame['function'].'(' : '';
|
||||
$tlTrace .= isset($frame['args']) ? \substr(\json_encode($frame['args']) ?: '', 1, -1) : '';
|
||||
$tlTrace .= ')';
|
||||
$tlTrace .= "\n";
|
||||
}
|
||||
\var_dump($tlTrace);
|
||||
}
|
||||
$fibers = self::$map->count();
|
||||
Logger::log("Running fibers: $fibers", Logger::ULTRA_VERBOSE);*/
|
||||
}
|
||||
return (int) $memory;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ final class Connection extends SettingsAbstract
|
||||
/**
|
||||
* Connection timeout.
|
||||
*/
|
||||
protected float $timeout = 2.0;
|
||||
protected float $timeout = 5.0;
|
||||
/**
|
||||
* Ping interval.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user