File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -214,4 +214,21 @@ kphp::coro::task<> InstanceState::run_instance_epilogue() noexcept {
214214 web_state.session_is_finished = true ;
215215 web_state.session .reset ();
216216 }
217+
218+ /*
219+ * Unlike regular RPC requests whose results the user code waits for via rpc_fetch_responses,
220+ * thereby guaranteeing they are sent, the user code does not wait for requests sent with the
221+ * ignore_answer flag. Therefore, we can’t guarantee that the coroutines responsible for
222+ * sending ignore_answer requests have finished. This means the requests might not be sent
223+ * if the instance terminates.
224+ *
225+ * This await suspends the current coroutine until all pending ignore_answer requests are
226+ * fully sent. While suspended, other forks and coroutines may continue running.
227+ *
228+ * After this call completes, delivery of all ignore_answer requests is guaranteed.
229+ */
230+ const auto ignore_answer_tasks{RpcClientInstanceState::get ().ignore_answer_awaiter_tasks };
231+ for (const auto & [_, awaiter_task] : ignore_answer_tasks) {
232+ co_await awaiter_task.when_ready ();
233+ }
217234}
Original file line number Diff line number Diff line change @@ -28,20 +28,6 @@ inline kphp::coro::task<> f$exit(mixed v = 0) noexcept { // TODO: make it synchr
2828 }
2929 co_await kphp::forks::id_managed (instance_st.run_instance_epilogue ());
3030
31- /*
32- * Unlike regular RPC requests whose results the user code waits for via rpc_fetch_responses,
33- * thereby guaranteeing they are sent, the user code does not wait for requests sent with the
34- * ignore_answer flag. Therefore, we can’t guarantee that the coroutines responsible for
35- * sending ignore_answer requests have finished. This means the requests might not be sent
36- * if the instance terminates.
37- *
38- * This await suspends the current coroutine until all pending ignore_answer requests are
39- * fully sent. While suspended, other forks and coroutines may continue running.
40- *
41- * After this call completes, delivery of all ignore_answer requests is guaranteed.
42- */
43- co_await RpcClientInstanceState::get ().ensure_ignore_answer_requests_sent ();
44-
4531 k2::exit (static_cast <int32_t >(exit_code));
4632}
4733
Original file line number Diff line number Diff line change @@ -32,16 +32,6 @@ struct RpcClientInstanceState final : private vk::not_copyable {
3232 RpcClientInstanceState () noexcept = default ;
3333
3434 static RpcClientInstanceState& get () noexcept ;
35-
36- kphp::coro::task<void > ensure_ignore_answer_requests_sent () noexcept {
37- while (!ignore_answer_awaiter_tasks.empty ()) {
38- const auto it_ignore_answer_awaiter{ignore_answer_awaiter_tasks.begin ()};
39- const auto & [query_id, awaiter_task]{*it_ignore_answer_awaiter};
40-
41- ignore_answer_awaiter_tasks.erase (it_ignore_answer_awaiter);
42- co_await awaiter_task.when_ready ();
43- }
44- }
4535};
4636
4737// ================================================================================================
You can’t perform that action at this time.
0 commit comments