Fix possible temp auth key bind freeze.

This commit is contained in:
John Preston 2024-04-08 21:35:36 +04:00
parent c5febce548
commit 0152d2c48e
2 changed files with 12 additions and 2 deletions

View File

@ -18,7 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h"
#include "calls/calls_instance.h"
#include "main/main_account.h" // Account::configUpdated.
#include "apiwrap.h"
#include "core/application.h"
#include "core/core_settings.h"
#include "lang/lang_instance.h"

View File

@ -869,6 +869,7 @@ void SessionPrivate::tryToSend() {
false,
bindDcKeyRequest);
_bindMessageSent = crl::now();
sentIdsWrap.messages.push_back(_bindMsgId);
needAnyResponse = true;
}
if (pingRequest) {
@ -877,6 +878,7 @@ void SessionPrivate::tryToSend() {
bigMsgId,
forceNewMsgId,
pingRequest);
sentIdsWrap.messages.push_back(_pingMsgId);
needAnyResponse = true;
}
@ -1600,13 +1602,22 @@ SessionPrivate::HandleResult SessionPrivate::handleOneReceived(
correctUnixtimeWithBadLocal(info.serverTime);
info.badTime = false;
}
if (_bindMsgId) {
LOG(("Message Info: bad message notification received"
" while binding temp key, restarting."));
return HandleResult::RestartConnection;
}
LOG(("Message Info: bad message notification received, msgId %1, error_code %2").arg(data.vbad_msg_id().v).arg(errorCode));
return HandleResult::ResetSession;
}
} else { // fatal (except 48, but it must not get here)
const auto badMsgId = mtpMsgId(data.vbad_msg_id().v);
const auto requestId = wasSent(resendId);
if (requestId) {
if (_bindMsgId) {
LOG(("Message Error: fatal bad message notification received"
" while binding temp key, restarting."));
return HandleResult::RestartConnection;
} else if (requestId) {
LOG(("Message Error: "
"fatal bad message notification received, "
"msgId %1, error_code %2, requestId: %3"