Ensure that poll is removed from being_closed_polls_ after request is completed.

This commit is contained in:
levlam 2022-07-24 12:19:51 +03:00
parent 3afbce24b3
commit 6c98bec686
2 changed files with 18 additions and 1 deletions

View File

@ -1214,11 +1214,26 @@ void PollManager::do_stop_poll(PollId poll_id, FullMessageId full_message_id, un
bool is_inserted = being_closed_polls_.insert(poll_id).second;
CHECK(is_inserted);
auto new_promise = get_erase_log_event_promise(log_event_id, std::move(promise));
auto new_promise = PromiseCreator::lambda(
[actor_id = actor_id(this), poll_id, log_event_id, promise = std::move(promise)](Result<Unit> result) mutable {
send_closure(actor_id, &PollManager::on_stop_poll_finished, poll_id, log_event_id, std::move(result),
std::move(promise));
});
td_->create_handler<StopPollQuery>(std::move(new_promise))->send(full_message_id, std::move(reply_markup), poll_id);
}
void PollManager::on_stop_poll_finished(PollId poll_id, uint64 log_event_id, Result<Unit> &&result,
Promise<Unit> &&promise) {
being_closed_polls_.erase(poll_id);
if (log_event_id != 0 && !G()->close_flag()) {
binlog_erase(G()->td_db()->get_binlog(), log_event_id);
}
promise.set_result(std::move(result));
}
void PollManager::stop_local_poll(PollId poll_id) {
CHECK(is_local_poll_id(poll_id));
auto poll = get_poll_editable(poll_id);

View File

@ -213,6 +213,8 @@ class PollManager final : public Actor {
void do_stop_poll(PollId poll_id, FullMessageId full_message_id, unique_ptr<ReplyMarkup> &&reply_markup,
uint64 log_event_id, Promise<Unit> &&promise);
void on_stop_poll_finished(PollId poll_id, uint64 log_event_id, Result<Unit> &&result, Promise<Unit> &&promise);
void forget_local_poll(PollId poll_id);
MultiTimeout update_poll_timeout_{"UpdatePollTimeout"};