Fix race in on_alarm_timeout.

GitOrigin-RevId: 0a940296688cf4b743c85fa4513504483cd357df
This commit is contained in:
levlam 2018-12-18 10:43:28 +03:00
parent b5e95821ad
commit 47c67479b3

View File

@ -3062,9 +3062,13 @@ void Td::on_alarm_timeout(int64 alarm_id) {
} }
return; return;
} }
if (close_flag_ >= 2) {
// pending_alarms_ was already cleared
return;
}
auto it = pending_alarms_.find(alarm_id); auto it = pending_alarms_.find(alarm_id);
CHECK(it != pending_alarms_.end()) << alarm_id << ' ' << close_flag_ << ' ' << G()->close_flag(); CHECK(it != pending_alarms_.end());
uint64 request_id = it->second; uint64 request_id = it->second;
pending_alarms_.erase(alarm_id); pending_alarms_.erase(alarm_id);
send_result(request_id, make_tl_object<td_api::ok>()); send_result(request_id, make_tl_object<td_api::ok>());