Check close_flag() first.

This commit is contained in:
levlam 2024-02-18 20:55:41 +03:00
parent 516e2e8a07
commit acef6e61a0
6 changed files with 9 additions and 9 deletions

View File

@ -381,7 +381,7 @@ void DeviceTokenManager::dec_sync_cnt() {
}
void DeviceTokenManager::loop() {
if (sync_cnt_ != 0 || G()->close_flag()) {
if (G()->close_flag() || sync_cnt_ != 0) {
return;
}
for (int32 token_type = 1; token_type < TokenType::Size; token_type++) {

View File

@ -5907,7 +5907,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message,
DialogId owner_dialog_id, int32 message_date, bool is_content_read,
UserId via_bot_user_id, MessageSelfDestructType *ttl,
bool *disable_web_page_preview, const char *source) {
if (!td->auth_manager_->was_authorized() && !G()->close_flag() && media_ptr != nullptr &&
if (!G()->close_flag() && !td->auth_manager_->was_authorized() && media_ptr != nullptr &&
media_ptr->get_id() != telegram_api::messageMediaEmpty::ID) {
LOG(ERROR) << "Receive without authorization from " << source << ": " << to_string(media_ptr);
media_ptr = nullptr;

View File

@ -23885,7 +23885,7 @@ void MessagesManager::on_message_media_uploaded(DialogId dialog_id, const Messag
actor_id(this), &MessagesManager::on_media_message_ready_to_send, dialog_id, message_id,
PromiseCreator::lambda([this, dialog_id, input_media = std::move(input_media), file_id,
thumbnail_file_id](Result<Message *> result) mutable {
if (result.is_error() || G()->close_flag()) {
if (G()->close_flag() || result.is_error()) {
return;
}
@ -23968,7 +23968,7 @@ void MessagesManager::on_secret_message_media_uploaded(DialogId dialog_id, const
send_closure_later(actor_id(this), &MessagesManager::on_media_message_ready_to_send, dialog_id, m->message_id,
PromiseCreator::lambda([this, dialog_id, secret_input_media = std::move(secret_input_media)](
Result<Message *> result) mutable {
if (result.is_error() || G()->close_flag()) {
if (G()->close_flag() || result.is_error()) {
return;
}
@ -24158,7 +24158,7 @@ void MessagesManager::on_upload_message_media_finished(int64 media_album_id, Dia
for (auto request_message_id : message_ids) {
LOG(INFO) << "Send on_media_message_ready_to_send for " << request_message_id << " in " << dialog_id;
auto promise = PromiseCreator::lambda([this, media_album_id](Result<Message *> result) {
if (result.is_error() || G()->close_flag()) {
if (G()->close_flag() || result.is_error()) {
return;
}
@ -27891,7 +27891,7 @@ void MessagesManager::remove_message_notifications_by_message_ids(DialogId dialo
void MessagesManager::do_remove_message_notification(DialogId dialog_id, bool from_mentions,
NotificationId notification_id,
vector<MessageDbDialogMessage> result) {
if (result.empty() || G()->close_flag()) {
if (G()->close_flag() || result.empty()) {
return;
}
CHECK(result.size() == 1);

View File

@ -166,7 +166,7 @@ void NotificationManager::on_flush_pending_updates_timeout_callback(void *notifi
}
bool NotificationManager::is_disabled() const {
return !td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot() || G()->close_flag();
return G()->close_flag() || !td_->auth_manager_->is_authorized() || td_->auth_manager_->is_bot();
}
StringBuilder &operator<<(StringBuilder &string_builder, const NotificationManager::ActiveNotificationsUpdate &update) {

View File

@ -208,7 +208,7 @@ void PrivacyManager::do_update_privacy(UserPrivacySetting user_privacy_setting,
info.is_synchronized_ = true;
if (!(info.rules_ == privacy_rules)) {
if ((from_update || was_synchronized) && !G()->close_flag()) {
if (!G()->close_flag() && (from_update || was_synchronized)) {
switch (user_privacy_setting.type()) {
case UserPrivacySetting::Type::UserStatus: {
send_closure_later(G()->contacts_manager(), &ContactsManager::on_update_online_status_privacy);

View File

@ -620,7 +620,7 @@ void TopDialogManager::on_first_sync() {
}
void TopDialogManager::loop() {
if (td_->auth_manager_->is_bot() || G()->close_flag()) {
if (G()->close_flag() || td_->auth_manager_->is_bot()) {
return;
}