Add missing checks for close_flag in Timeout callbacks.

This commit is contained in:
levlam 2021-11-13 22:37:41 +03:00
parent 85c30e5dd2
commit 60907279fd
7 changed files with 27 additions and 9 deletions

View File

@ -213,6 +213,9 @@ void AuthManager::set_login_token_expires_at(double login_token_expires_at) {
}
void AuthManager::on_update_login_token_static(void *td) {
if (G()->close_flag()) {
return;
}
static_cast<Td *>(td)->auth_manager_->on_update_login_token();
}

View File

@ -173,6 +173,9 @@ void InlineQueriesManager::tear_down() {
void InlineQueriesManager::on_drop_inline_query_result_timeout_callback(void *inline_queries_manager_ptr,
int64 query_hash) {
if (G()->close_flag()) {
return;
}
auto inline_queries_manager = static_cast<InlineQueriesManager *>(inline_queries_manager_ptr);
auto it = inline_queries_manager->inline_query_results_.find(query_hash);
CHECK(it != inline_queries_manager->inline_query_results_.end());

View File

@ -995,6 +995,7 @@ void NotificationManager::add_update_notification(NotificationGroupId notificati
}
void NotificationManager::flush_pending_updates(int32 group_id, const char *source) {
// no check for G()->close_flag() to flush pending notifications even while closing
auto it = pending_updates_.find(group_id);
if (it == pending_updates_.end()) {
return;
@ -1370,6 +1371,7 @@ void NotificationManager::flush_all_pending_updates(bool include_delayed_chats,
bool NotificationManager::do_flush_pending_notifications(NotificationGroupKey &group_key, NotificationGroup &group,
vector<PendingNotification> &pending_notifications) {
// no check for G()->close_flag() to flush pending notifications even while closing
if (pending_notifications.empty()) {
return false;
}

View File

@ -1151,12 +1151,12 @@ double PollManager::get_polling_timeout() const {
}
void PollManager::on_update_poll_timeout(PollId poll_id) {
CHECK(!td_->auth_manager_->is_bot());
CHECK(!is_local_poll_id(poll_id));
if (G()->close_flag()) {
return;
}
CHECK(!td_->auth_manager_->is_bot());
CHECK(!is_local_poll_id(poll_id));
auto poll = get_poll(poll_id);
CHECK(poll != nullptr);
if (poll->is_closed && poll->is_updated_after_close) {
@ -1182,11 +1182,10 @@ void PollManager::on_update_poll_timeout(PollId poll_id) {
}
void PollManager::on_close_poll_timeout(PollId poll_id) {
CHECK(!is_local_poll_id(poll_id));
if (G()->close_flag()) {
return;
}
CHECK(!is_local_poll_id(poll_id));
auto poll = get_poll_editable(poll_id);
CHECK(poll != nullptr);

View File

@ -4691,6 +4691,10 @@ void StickersManager::view_featured_sticker_sets(const vector<StickerSetId> &sti
}
void StickersManager::read_featured_sticker_sets(void *td_void) {
if (G()->close_flag()) {
return;
}
CHECK(td_void != nullptr);
auto td = static_cast<Td *>(td_void);

View File

@ -1341,12 +1341,18 @@ const WebPagesManager::WebPageInstantView *WebPagesManager::get_web_page_instant
return &web_page->instant_view;
}
void WebPagesManager::on_pending_web_page_timeout_callback(void *web_pages_manager_ptr, int64 web_page_id) {
static_cast<WebPagesManager *>(web_pages_manager_ptr)->on_pending_web_page_timeout(WebPageId(web_page_id));
void WebPagesManager::on_pending_web_page_timeout_callback(void *web_pages_manager_ptr, int64 web_page_id_int) {
if (G()->close_flag()) {
return;
}
auto web_pages_manager = static_cast<WebPagesManager *>(web_pages_manager_ptr);
send_closure_later(web_pages_manager->actor_id(web_pages_manager), &WebPagesManager::on_pending_web_page_timeout,
WebPageId(web_page_id_int));
}
void WebPagesManager::on_pending_web_page_timeout(WebPageId web_page_id) {
if (have_web_page(web_page_id)) {
if (G()->close_flag() || have_web_page(web_page_id)) {
return;
}

View File

@ -127,7 +127,8 @@ class WebPagesManager final : public Actor {
tl_object_ptr<td_api::webPageInstantView> get_web_page_instant_view_object(
WebPageId web_page_id, const WebPageInstantView *web_page_instant_view) const;
static void on_pending_web_page_timeout_callback(void *web_pages_manager_ptr, int64 web_page_id);
static void on_pending_web_page_timeout_callback(void *web_pages_manager_ptr, int64 web_page_id_int);
void on_pending_web_page_timeout(WebPageId web_page_id);
void on_get_web_page_preview_success(int64 request_id, const string &url, WebPageId web_page_id,