Improve socket management

This commit is contained in:
Daniil Gentili 2019-09-13 17:24:52 +02:00
parent aff46a1cc3
commit 4d599e017b
2 changed files with 6 additions and 7 deletions

View File

@ -83,8 +83,8 @@ class ReadLoop extends SignalLoop
}
$API->logger->logger($e);
$API->logger->logger("Got nothing in the socket in DC {$datacenter}, reconnecting...", Logger::ERROR);
yield $connection->reconnect();
continue;
Tools::callForkDefer($connection->reconnect());
return;
}
if (\is_int($error)) {
@ -206,10 +206,9 @@ class ReadLoop extends SignalLoop
*/
$session_id = \substr($decrypted_data, 8, 8);
if ($session_id != $connection->session_id) {
$API->logger->logger("Session ID mismatch", Logger::FATAL_ERROR);
$connection->resetSession();
Tools::callForkDefer($connection->reconnect());
return;
throw new \danog\MadelineProto\Exception('Session id mismatch');
throw new NothingInTheSocketException();
}
$message_id = \substr($decrypted_data, 16, 8);
$connection->check_message_id($message_id, ['outgoing' => false, 'container' => false]);

View File

@ -91,8 +91,8 @@ class WriteLoop extends ResumableSignalLoop
}
$API->logger($e);
$API->logger->logger("Got nothing in the socket in DC {$datacenter}, reconnecting...", Logger::ERROR);
yield $connection->reconnect();
continue;
Tools::callForkDefer($connection->reconnect());
return;
} finally {
$connection->writing(false);
}