Skip to content

Commit b7f8191

Browse files
committed
small fix
1 parent 2de675d commit b7f8191

3 files changed

Lines changed: 17 additions & 24 deletions

File tree

runtime-light/state/instance-state.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

runtime-light/stdlib/exit/exit-functions.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff 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

runtime-light/stdlib/rpc/rpc-client-state.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff 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
// ================================================================================================

0 commit comments

Comments
 (0)