SequenceDispatcher: set error to all NetQueries at tear_down
This commit is contained in:
parent
452f60be0b
commit
c202974d47
@ -319,7 +319,6 @@ class MultiSequenceDispatcherNewImpl final : public MultiSequenceDispatcherNew {
|
||||
send_closure(node.callback, &NetQueryCallback::on_result_resendable, std::move(query), std::move(promise));
|
||||
}
|
||||
|
||||
// TODO: without td::Result?
|
||||
void on_resend(td::Result<NetQueryPtr> query) {
|
||||
auto task_id = TaskId(get_link_token());
|
||||
auto &node = *scheduler_.get_task_extra(task_id);
|
||||
@ -337,6 +336,15 @@ class MultiSequenceDispatcherNewImpl final : public MultiSequenceDispatcherNew {
|
||||
void loop() override {
|
||||
flush_pending_queries();
|
||||
}
|
||||
void tear_down() override {
|
||||
// Leaves scheduler_ in an invalid state, but we are closing anyway
|
||||
scheduler_.for_each([&](Node &node) {
|
||||
if (node.net_query.empty()) {
|
||||
return;
|
||||
}
|
||||
node.net_query->set_error(Global::request_aborted_error());
|
||||
});
|
||||
}
|
||||
|
||||
void flush_pending_queries() {
|
||||
while (true) {
|
||||
|
@ -35,6 +35,13 @@ class ChainScheduler {
|
||||
template <class ExtraTT>
|
||||
friend td::StringBuilder &operator<<(StringBuilder &sb, ChainScheduler<ExtraTT> &scheduler);
|
||||
|
||||
template <class F>
|
||||
void for_each(F &&f) {
|
||||
tasks_.for_each([&f](auto, Task &task) {
|
||||
f(task.extra) ;
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
struct ChainNode : ListNode {
|
||||
TaskId task_id{};
|
||||
|
Loading…
Reference in New Issue
Block a user