Check for close status as early as possible.

This commit is contained in:
levlam 2022-08-10 14:04:36 +03:00
parent 12d852abc5
commit f342b65500
4 changed files with 12 additions and 10 deletions

View File

@ -352,10 +352,11 @@ void CallActor::on_save_debug_query_result(Result<NetQueryPtr> r_net_query) {
}
void CallActor::send_call_log(td_api::object_ptr<td_api::InputFile> log_file, Promise<Unit> promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
if (!call_state_.need_log) {
return promise.set_error(Status::Error(400, "Unexpected sendCallLog"));
}
TRY_STATUS_PROMISE(promise, G()->close_status());
auto *file_manager = G()->td().get_actor_unsafe()->file_manager_.get();
auto r_file_id = file_manager->get_input_file_id(FileType::CallLog, log_file, DialogId(), false, false);
@ -418,18 +419,19 @@ void CallActor::upload_log_file(FileId file_id, Promise<Unit> &&promise) {
void CallActor::on_upload_log_file(FileId file_id, Promise<Unit> &&promise,
tl_object_ptr<telegram_api::InputFile> input_file) {
LOG(INFO) << "Log file " << file_id << " has been uploaded";
TRY_STATUS_PROMISE(promise, G()->close_status());
LOG(INFO) << "Log file " << file_id << " has been uploaded";
do_upload_log_file(file_id, std::move(input_file), std::move(promise));
}
void CallActor::on_upload_log_file_error(FileId file_id, Promise<Unit> &&promise, Status status) {
TRY_STATUS_PROMISE(promise, G()->close_status());
LOG(WARNING) << "Log file " << file_id << " has upload error " << status;
CHECK(status.is_error());
TRY_STATUS_PROMISE(promise, G()->close_status());
promise.set_error(Status::Error(status.code() > 0 ? status.code() : 500,
status.message())); // TODO CHECK that status has always a code
}

View File

@ -8058,7 +8058,7 @@ void ContactsManager::reload_created_public_dialogs(PublicDialogType type,
void ContactsManager::finish_get_created_public_dialogs(PublicDialogType type, Result<Unit> &&result) {
if (G()->close_flag()) {
result = G()->close_status();
result = Global::request_aborted_error();
}
auto index = static_cast<int32>(type);

View File

@ -23747,10 +23747,10 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId
bool from_the_end, bool only_local,
vector<MessagesDbDialogMessage> &&messages,
Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
CHECK(-limit < offset && offset <= 0);
CHECK(offset < 0 || from_the_end);
CHECK(!from_message_id.is_scheduled());
TRY_STATUS_PROMISE(promise, G()->close_status());
if (!have_input_peer(dialog_id, AccessRights::Read)) {
LOG(WARNING) << "Ignore result of get_history_from_database in " << dialog_id;
@ -24008,8 +24008,8 @@ void MessagesManager::get_history_from_the_end(DialogId dialog_id, bool from_dat
void MessagesManager::get_history_from_the_end_impl(const Dialog *d, bool from_database, bool only_local,
Promise<Unit> &&promise, const char *source) {
CHECK(d != nullptr);
TRY_STATUS_PROMISE(promise, G()->close_status());
CHECK(d != nullptr);
auto dialog_id = d->dialog_id;
if (!have_input_peer(dialog_id, AccessRights::Read)) {
@ -24063,9 +24063,9 @@ void MessagesManager::get_history(DialogId dialog_id, MessageId from_message_id,
void MessagesManager::get_history_impl(const Dialog *d, MessageId from_message_id, int32 offset, int32 limit,
bool from_database, bool only_local, Promise<Unit> &&promise) {
TRY_STATUS_PROMISE(promise, G()->close_status());
CHECK(d != nullptr);
CHECK(from_message_id.is_valid());
TRY_STATUS_PROMISE(promise, G()->close_status());
auto dialog_id = d->dialog_id;
if (!have_input_peer(dialog_id, AccessRights::Read)) {

View File

@ -3882,7 +3882,7 @@ std::pair<vector<FileId>, vector<FileId>> StickersManager::split_stickers_by_pre
vector<FileId> StickersManager::get_stickers(StickerType sticker_type, string emoji, int32 limit, DialogId dialog_id,
bool force, Promise<Unit> &&promise) {
if (G()->close_flag()) {
promise.set_error(G()->close_status());
promise.set_error(Global::request_aborted_error());
return {};
}
@ -8619,7 +8619,7 @@ void StickersManager::on_get_emoji_keywords_difference(
const string &language_code, int32 from_version,
Result<telegram_api::object_ptr<telegram_api::emojiKeywordsDifference>> &&result) {
if (G()->close_flag()) {
result = G()->close_status();
result = Global::request_aborted_error();
}
if (result.is_error()) {
if (!G()->is_expected_error(result.error())) {