Don't use poll multi-timeouts while closing.
This commit is contained in:
parent
489e5dbc62
commit
4c390b4988
@ -388,7 +388,9 @@ void PollManager::on_load_poll_from_database(PollId poll_id, string value) {
|
||||
poll->is_closed = true;
|
||||
} else {
|
||||
CHECK(!is_local_poll_id(poll_id));
|
||||
close_poll_timeout_.set_timeout_in(poll_id.get(), poll->close_date - G()->server_time() + 1e-3);
|
||||
if (!G()->close_flag()) {
|
||||
close_poll_timeout_.set_timeout_in(poll_id.get(), poll->close_date - G()->server_time() + 1e-3);
|
||||
}
|
||||
}
|
||||
}
|
||||
polls_[poll_id] = std::move(poll);
|
||||
@ -652,7 +654,9 @@ void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id, c
|
||||
CHECK(have_poll(poll_id));
|
||||
if (full_message_id.get_message_id().is_scheduled() || !full_message_id.get_message_id().is_server()) {
|
||||
other_poll_messages_[poll_id].insert(full_message_id);
|
||||
unload_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
if (!G()->close_flag()) {
|
||||
unload_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
}
|
||||
return;
|
||||
}
|
||||
LOG(INFO) << "Register " << poll_id << " from " << full_message_id << " from " << source;
|
||||
@ -660,10 +664,12 @@ void PollManager::register_poll(PollId poll_id, FullMessageId full_message_id, c
|
||||
auto poll = get_poll(poll_id);
|
||||
CHECK(poll != nullptr);
|
||||
if (!td_->auth_manager_->is_bot() && !is_local_poll_id(poll_id) &&
|
||||
!(poll->is_closed && poll->is_updated_after_close)) {
|
||||
!(poll->is_closed && poll->is_updated_after_close) && !G()->close_flag()) {
|
||||
update_poll_timeout_.add_timeout_in(poll_id.get(), 0);
|
||||
}
|
||||
unload_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
if (!G()->close_flag()) {
|
||||
unload_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
}
|
||||
}
|
||||
|
||||
void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id, const char *source) {
|
||||
@ -693,14 +699,16 @@ void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id,
|
||||
}
|
||||
if (message_ids.empty()) {
|
||||
server_poll_messages_.erase(poll_id);
|
||||
update_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
if (!G()->close_flag()) {
|
||||
update_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
}
|
||||
|
||||
schedule_poll_unload(poll_id);
|
||||
}
|
||||
}
|
||||
|
||||
bool PollManager::can_unload_poll(PollId poll_id) {
|
||||
if (is_local_poll_id(poll_id) || server_poll_messages_.count(poll_id) != 0 ||
|
||||
if (G()->close_flag() || is_local_poll_id(poll_id) || server_poll_messages_.count(poll_id) != 0 ||
|
||||
other_poll_messages_.count(poll_id) != 0 || pending_answers_.count(poll_id) != 0 ||
|
||||
being_closed_polls_.count(poll_id) != 0) {
|
||||
return false;
|
||||
@ -830,7 +838,9 @@ void PollManager::do_set_poll_answer(PollId poll_id, FullMessageId full_message_
|
||||
binlog_erase(G()->td_db()->get_binlog(), log_event_id);
|
||||
return;
|
||||
}
|
||||
unload_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
if (!G()->close_flag()) {
|
||||
unload_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
}
|
||||
|
||||
auto &pending_answer = pending_answers_[poll_id];
|
||||
if (!pending_answer.promises_.empty() && pending_answer.options_ == options) {
|
||||
@ -1068,6 +1078,8 @@ void PollManager::get_poll_voters(PollId poll_id, FullMessageId full_message_id,
|
||||
|
||||
void PollManager::on_get_poll_voters(PollId poll_id, int32 option_id, string offset, int32 limit,
|
||||
Result<tl_object_ptr<telegram_api::messages_votesList>> &&result) {
|
||||
G()->ignore_result_if_closing(result);
|
||||
|
||||
auto poll = get_poll(poll_id);
|
||||
CHECK(poll != nullptr);
|
||||
if (option_id < 0 || static_cast<size_t>(option_id) >= poll->options.size()) {
|
||||
@ -1346,12 +1358,17 @@ void PollManager::on_unload_poll_timeout(PollId poll_id) {
|
||||
}
|
||||
|
||||
void PollManager::forget_local_poll(PollId poll_id) {
|
||||
if (G()->close_flag()) {
|
||||
return;
|
||||
}
|
||||
CHECK(is_local_poll_id(poll_id));
|
||||
unload_poll_timeout_.set_timeout_in(poll_id.get(), UNLOAD_POLL_DELAY);
|
||||
}
|
||||
|
||||
void PollManager::on_get_poll_results(PollId poll_id, uint64 generation,
|
||||
Result<tl_object_ptr<telegram_api::Updates>> result) {
|
||||
G()->ignore_result_if_closing(result);
|
||||
|
||||
auto poll = get_poll(poll_id);
|
||||
if (poll == nullptr) {
|
||||
return;
|
||||
@ -1598,10 +1615,10 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll
|
||||
if (close_date != 0) {
|
||||
if (close_date <= G()->server_time()) {
|
||||
poll->is_closed = true;
|
||||
} else {
|
||||
} else if (!G()->close_flag()) {
|
||||
close_poll_timeout_.set_timeout_in(poll_id.get(), close_date - G()->server_time() + 1e-3);
|
||||
}
|
||||
} else {
|
||||
} else if (!G()->close_flag()) {
|
||||
close_poll_timeout_.cancel_timeout(poll_id.get());
|
||||
}
|
||||
} else {
|
||||
@ -1767,7 +1784,7 @@ PollId PollManager::on_get_poll(PollId poll_id, tl_object_ptr<telegram_api::poll
|
||||
is_changed = true;
|
||||
}
|
||||
|
||||
if (!is_bot && !poll->is_closed) {
|
||||
if (!is_bot && !poll->is_closed && !G()->close_flag()) {
|
||||
auto timeout = get_polling_timeout();
|
||||
LOG(INFO) << "Schedule updating of " << poll_id << " in " << timeout;
|
||||
update_poll_timeout_.set_timeout_in(poll_id.get(), timeout);
|
||||
|
Loading…
x
Reference in New Issue
Block a user