From 3b8301217faf0a0e969f036233af2d3c21fe0611 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 7 Apr 2021 21:58:48 +0200 Subject: [PATCH] Final fix --- src/danog/MadelineProto/Ipc/Runner/entry.php | 2 ++ src/danog/MadelineProto/Wrappers/Loop.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/danog/MadelineProto/Ipc/Runner/entry.php b/src/danog/MadelineProto/Ipc/Runner/entry.php index 5e760dba8..065bea5ae 100644 --- a/src/danog/MadelineProto/Ipc/Runner/entry.php +++ b/src/danog/MadelineProto/Ipc/Runner/entry.php @@ -23,6 +23,7 @@ use danog\MadelineProto\Logger; use danog\MadelineProto\Magic; use danog\MadelineProto\SessionPaths; use danog\MadelineProto\Settings\Ipc; +use danog\MadelineProto\Shutdown; use danog\MadelineProto\Tools; (static function (): void { @@ -108,6 +109,7 @@ use danog\MadelineProto\Tools; try { Tools::wait($session->storeIpcState(new IpcState($runnerId))); Tools::wait(Server::waitShutdown()); + Shutdown::removeCallback('restarter'); return; } catch (\Throwable $e) { Logger::log((string) $e, Logger::FATAL_ERROR); diff --git a/src/danog/MadelineProto/Wrappers/Loop.php b/src/danog/MadelineProto/Wrappers/Loop.php index 12bd45c36..ef786e8d5 100644 --- a/src/danog/MadelineProto/Wrappers/Loop.php +++ b/src/danog/MadelineProto/Wrappers/Loop.php @@ -72,14 +72,13 @@ trait Loop $url = \explode('?', $uri, 2)[0] ?? ''; $query = \http_build_query($params); $uri = \implode('?', [$url, $query]); - $payload = $_SERVER['REQUEST_METHOD'].' '.$uri.' '.$_SERVER['SERVER_PROTOCOL']."\r\n".'Host: '.$_SERVER['SERVER_NAME']."\r\n\r\n"; + $payload = $_SERVER['REQUEST_METHOD'].' '.$uri." HTTP/1.1\r\n".'Host: '.$_SERVER['SERVER_NAME']."\r\n\r\n"; $logger->logger("Connecting to {$address}:{$port}"); $a = \fsockopen($address, $port); $logger->logger("Sending self-restart payload"); $logger->logger($payload); \fwrite($a, $payload); $logger->logger("Payload sent with token {$params['MadelineSelfRestart']}, waiting for self-restart"); - \sleep(10); \fclose($a); $logger->logger("Shutdown of self-restart callback"); }, 'restarter');