Ensure that all network requests are sent and all their responses are processed asynchronously.

This commit is contained in:
levlam 2022-10-02 01:53:56 +03:00
parent 08ce44a194
commit d29c86bb14
2 changed files with 4 additions and 4 deletions

View File

@ -77,7 +77,7 @@ void SequenceDispatcher::try_resend_query(Data &data, NetQueryPtr query) {
// TODO: if query is ok, use NetQueryCallback::on_result
if (data.callback_.empty()) {
do_finish(data);
send_closure(G()->td(), &Td::on_result, std::move(query));
send_closure_later(G()->td(), &Td::on_result, std::move(query));
loop();
return;
}
@ -385,7 +385,7 @@ class MultiSequenceDispatcherImpl final : public MultiSequenceDispatcher {
if (node.callback.empty()) {
auto query = std::move(node.net_query);
scheduler_.finish_task(task_id);
send_closure(G()->td(), &Td::on_result, std::move(query));
send_closure_later(G()->td(), &Td::on_result, std::move(query));
loop();
return;
}

View File

@ -60,7 +60,7 @@ void NetQueryDispatcher::dispatch(NetQueryPtr net_query) {
if (!net_query->in_sequence_dispatcher() && !net_query->get_chain_ids().empty()) {
net_query->debug("sent to main sequence dispatcher");
send_closure(sequence_dispatcher_, &MultiSequenceDispatcher::send, std::move(net_query));
send_closure_later(sequence_dispatcher_, &MultiSequenceDispatcher::send, std::move(net_query));
return;
}
@ -73,7 +73,7 @@ void NetQueryDispatcher::dispatch(NetQueryPtr net_query) {
net_query->resend();
} else if (code < 0 || code == 500 || code == 420) {
net_query->debug("sent to NetQueryDelayer");
return send_closure(delayer_, &NetQueryDelayer::delay, std::move(net_query));
return send_closure_later(delayer_, &NetQueryDelayer::delay, std::move(net_query));
}
}
}