Fixes
This commit is contained in:
parent
45067af046
commit
a6fdf813c4
@ -479,6 +479,12 @@ class DataCenterConnection implements JsonSerializable
|
|||||||
$count = \count($backup);
|
$count = \count($backup);
|
||||||
$this->API->logger->logger("Restoring {$count} messages to DC {$this->datacenter}");
|
$this->API->logger->logger("Restoring {$count} messages to DC {$this->datacenter}");
|
||||||
foreach ($backup as $message) {
|
foreach ($backup as $message) {
|
||||||
|
if (isset($message['seqno'])) {
|
||||||
|
unset($message['seqno']);
|
||||||
|
}
|
||||||
|
if (isset($message['msg_id'])) {
|
||||||
|
unset($message['msg_id']);
|
||||||
|
}
|
||||||
if (isset($message['body'])) {
|
if (isset($message['body'])) {
|
||||||
Tools::callFork($this->getConnection()->sendMessage($message, false));
|
Tools::callFork($this->getConnection()->sendMessage($message, false));
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,10 @@ namespace danog\MadelineProto\Ipc;
|
|||||||
use Amp\Deferred;
|
use Amp\Deferred;
|
||||||
use Amp\Ipc\Sync\ChannelledSocket;
|
use Amp\Ipc\Sync\ChannelledSocket;
|
||||||
use danog\MadelineProto\API;
|
use danog\MadelineProto\API;
|
||||||
use danog\MadelineProto\Async\AsyncConstruct;
|
|
||||||
use danog\MadelineProto\Exception;
|
use danog\MadelineProto\Exception;
|
||||||
use danog\MadelineProto\Logger;
|
use danog\MadelineProto\Logger;
|
||||||
use danog\MadelineProto\Tools;
|
use danog\MadelineProto\Tools;
|
||||||
|
|
||||||
use function Amp\Ipc\connect;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IPC client.
|
* IPC client.
|
||||||
*/
|
*/
|
||||||
|
@ -35,7 +35,7 @@ final class ExitFailure
|
|||||||
$this->message = $exception->getMessage();
|
$this->message = $exception->getMessage();
|
||||||
$this->code = $exception->getCode();
|
$this->code = $exception->getCode();
|
||||||
$this->trace = flattenThrowableBacktrace($exception);
|
$this->trace = flattenThrowableBacktrace($exception);
|
||||||
if (method_exists($exception, 'getTLTrace')) {
|
if (\method_exists($exception, 'getTLTrace')) {
|
||||||
$this->tlTrace = $exception->getTLTrace();
|
$this->tlTrace = $exception->getTLTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\Ipc\Runner;
|
namespace danog\MadelineProto\Ipc\Runner;
|
||||||
|
|
||||||
use Amp\Process\Process as BaseProcess;
|
|
||||||
use Amp\Promise;
|
|
||||||
use danog\MadelineProto\Magic;
|
|
||||||
|
|
||||||
final class ProcessRunner extends RunnerAbstract
|
final class ProcessRunner extends RunnerAbstract
|
||||||
{
|
{
|
||||||
/** @var string|null Cached path to located PHP binary. */
|
/** @var string|null Cached path to located PHP binary. */
|
||||||
@ -41,7 +37,7 @@ final class ProcessRunner extends RunnerAbstract
|
|||||||
\escapeshellarg($session),
|
\escapeshellarg($session),
|
||||||
'&>/dev/null &'
|
'&>/dev/null &'
|
||||||
]);
|
]);
|
||||||
shell_exec($command);
|
\shell_exec($command);
|
||||||
}
|
}
|
||||||
private static function locateBinary(): string
|
private static function locateBinary(): string
|
||||||
{
|
{
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace danog\MadelineProto\Ipc\Runner;
|
namespace danog\MadelineProto\Ipc\Runner;
|
||||||
|
|
||||||
use Amp\Promise;
|
|
||||||
|
|
||||||
abstract class RunnerAbstract
|
abstract class RunnerAbstract
|
||||||
{
|
{
|
||||||
const SCRIPT_PATH = __DIR__."/entry.php";
|
const SCRIPT_PATH = __DIR__."/entry.php";
|
||||||
|
@ -4,7 +4,6 @@ namespace danog\MadelineProto\Ipc\Runner;
|
|||||||
|
|
||||||
use Amp\ByteStream\ResourceOutputStream;
|
use Amp\ByteStream\ResourceOutputStream;
|
||||||
use Amp\Parallel\Context\ContextException;
|
use Amp\Parallel\Context\ContextException;
|
||||||
use Amp\Promise;
|
|
||||||
use danog\MadelineProto\Magic;
|
use danog\MadelineProto\Magic;
|
||||||
|
|
||||||
final class WebRunner extends RunnerAbstract
|
final class WebRunner extends RunnerAbstract
|
||||||
@ -95,7 +94,7 @@ final class WebRunner extends RunnerAbstract
|
|||||||
|
|
||||||
// We don't care for results or timeouts here, PHP doesn't count IOwait time as execution time anyway
|
// We don't care for results or timeouts here, PHP doesn't count IOwait time as execution time anyway
|
||||||
// Technically should use amphp/socket, but I guess it's OK to not introduce another dependency just for a socket that will be used once.
|
// Technically should use amphp/socket, but I guess it's OK to not introduce another dependency just for a socket that will be used once.
|
||||||
fwrite($res = \fsockopen($address, $port), $payload);
|
\fwrite($res = \fsockopen($address, $port), $payload);
|
||||||
fclose($res);
|
\fclose($res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ use danog\MadelineProto\Tools;
|
|||||||
class Server extends SignalLoop
|
class Server extends SignalLoop
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Session not initialized, should initialize
|
* Session not initialized, should initialize.
|
||||||
*/
|
*/
|
||||||
const NOT_INITED = 'not inited';
|
const NOT_INITED = 'not inited';
|
||||||
/**
|
/**
|
||||||
* Session uses event handler, should start from main event handler file
|
* Session uses event handler, should start from main event handler file.
|
||||||
*/
|
*/
|
||||||
const EVENT_HANDLER = 'event';
|
const EVENT_HANDLER = 'event';
|
||||||
/**
|
/**
|
||||||
@ -99,9 +99,10 @@ class Server extends SignalLoop
|
|||||||
$id = 0;
|
$id = 0;
|
||||||
try {
|
try {
|
||||||
while ($payload = yield $socket->receive()) {
|
while ($payload = yield $socket->receive()) {
|
||||||
Tools::callFork($this->clientRequest($socket, $id++, $payload));
|
Tools::callFork($this->clientRequest($socket, $id++, $payload));
|
||||||
}
|
}
|
||||||
} catch (\Throwable $e) {}
|
} catch (\Throwable $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Handle client request.
|
* Handle client request.
|
||||||
|
@ -50,8 +50,8 @@ trait CallHandler
|
|||||||
foreach ($message_ids as $message_id) {
|
foreach ($message_ids as $message_id) {
|
||||||
if (isset($this->outgoing_messages[$message_id]['body'])) {
|
if (isset($this->outgoing_messages[$message_id]['body'])) {
|
||||||
if ($datacenter) {
|
if ($datacenter) {
|
||||||
unset($this->outgoing_messages[$message_id]['msg_id']);
|
unset($this->outgoing_messages[$message_id]['msg_id'], $this->outgoing_messages[$message_id]['seqno']);
|
||||||
unset($this->outgoing_messages[$message_id]['seqno']);
|
|
||||||
Tools::call($this->API->datacenter->waitGetConnection($datacenter))->onResolve(function ($e, $r) use ($message_id) {
|
Tools::call($this->API->datacenter->waitGetConnection($datacenter))->onResolve(function ($e, $r) use ($message_id) {
|
||||||
Tools::callFork($r->sendMessage($this->outgoing_messages[$message_id], false));
|
Tools::callFork($r->sendMessage($this->outgoing_messages[$message_id], false));
|
||||||
});
|
});
|
||||||
|
@ -112,6 +112,14 @@ abstract class Session
|
|||||||
$this->session_in_seq_no = 0;
|
$this->session_in_seq_no = 0;
|
||||||
$this->session_out_seq_no = 0;
|
$this->session_out_seq_no = 0;
|
||||||
$this->msgIdHandler = MsgIdHandler::createInstance($this);
|
$this->msgIdHandler = MsgIdHandler::createInstance($this);
|
||||||
|
foreach ($this->outgoing_messages as &$msg) {
|
||||||
|
if (isset($msg['msg_id'])) {
|
||||||
|
unset($msg['msg_id']);
|
||||||
|
}
|
||||||
|
if (isset($msg['seqno'])) {
|
||||||
|
unset($msg['seqno']);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create MTProto session if needed.
|
* Create MTProto session if needed.
|
||||||
|
@ -275,7 +275,9 @@ class Magic
|
|||||||
}
|
}
|
||||||
self::$initedLight = true;
|
self::$initedLight = true;
|
||||||
if ($light) {
|
if ($light) {
|
||||||
if (!\defined(\AMP_WORKER::class)) \define(\AMP_WORKER::class, true);
|
if (!\defined(\AMP_WORKER::class)) {
|
||||||
|
\define(\AMP_WORKER::class, true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +329,9 @@ class Magic
|
|||||||
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && !(\class_exists(\Phar::class) && \Phar::running())) {
|
if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && !(\class_exists(\Phar::class) && \Phar::running())) {
|
||||||
try {
|
try {
|
||||||
$back = \debug_backtrace(0);
|
$back = \debug_backtrace(0);
|
||||||
if (!defined('AMP_WORKER')) \define('AMP_WORKER', 1);
|
if (!\defined('AMP_WORKER')) {
|
||||||
|
\define('AMP_WORKER', 1);
|
||||||
|
}
|
||||||
$promise = \Amp\File\get(\end($back)['file']);
|
$promise = \Amp\File\get(\end($back)['file']);
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
|
@ -61,7 +61,7 @@ class RPCErrorException extends \Exception
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get localized error name
|
* Get localized error name.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@ -71,7 +71,7 @@ class RPCErrorException extends \Exception
|
|||||||
return $this->localized;
|
return $this->localized;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set localized error name
|
* Set localized error name.
|
||||||
*
|
*
|
||||||
* @param string $localization
|
* @param string $localization
|
||||||
* @return void
|
* @return void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user