diff --git a/builtin-functions/kphp-light/stdlib/rpc.txt b/builtin-functions/kphp-light/stdlib/rpc.txt index 6f440baa13..c88b464163 100644 --- a/builtin-functions/kphp-light/stdlib/rpc.txt +++ b/builtin-functions/kphp-light/stdlib/rpc.txt @@ -76,6 +76,9 @@ function fetch_byte () ::: int; /** @kphp-extern-func-info can_throw */ function fetch_long () ::: int; +/** @kphp-extern-func-info can_throw */ +function fetch_float () ::: float; + /** @kphp-extern-func-info can_throw */ function fetch_double () ::: float; diff --git a/builtin-functions/kphp-light/stdlib/vkext-functions.txt b/builtin-functions/kphp-light/stdlib/vkext-functions.txt index 18a68e6f0c..7f963d48c5 100644 --- a/builtin-functions/kphp-light/stdlib/vkext-functions.txt +++ b/builtin-functions/kphp-light/stdlib/vkext-functions.txt @@ -18,6 +18,7 @@ function vk_whitespace_pack ($str ::: string, $html_opt ::: bool = false) ::: st function vk_sp_full_simplify ($str ::: string) ::: string; +/** @kphp-extern-func-info can_throw */ function vk_json_encode_safe ($v ::: mixed) ::: string; function vk_stats_hll_merge($str ::: mixed) ::: string | false; diff --git a/runtime-light/stdlib/fork/fork-functions.h b/runtime-light/stdlib/fork/fork-functions.h index f528e988a6..fdcaf52b65 100644 --- a/runtime-light/stdlib/fork/fork-functions.h +++ b/runtime-light/stdlib/fork/fork-functions.h @@ -18,6 +18,7 @@ #include "runtime-light/coroutine/shared-task.h" #include "runtime-light/coroutine/task.h" #include "runtime-light/coroutine/type-traits.h" +#include "runtime-light/stdlib/diagnostics/exception-functions.h" #include "runtime-light/stdlib/diagnostics/logs.h" #include "runtime-light/stdlib/fork/fork-state.h" #include "runtime-light/stdlib/fork/fork-storage.h" @@ -145,7 +146,7 @@ template kphp::coro::task f$wait_multi(array fork_ids) noexcept { T res{}; for (const auto& it : std::as_const(fork_ids)) { - res.set_value(it.get_key(), co_await f$wait(it.get_value())); + res.set_value(it.get_key(), TRY_CALL_CORO(typename T::value_type, T, co_await f$wait(it.get_value()))); } co_return std::move(res); } diff --git a/runtime-light/stdlib/rpc/rpc-api.cpp b/runtime-light/stdlib/rpc/rpc-api.cpp index 2e3720f107..23d2c73458 100644 --- a/runtime-light/stdlib/rpc/rpc-api.cpp +++ b/runtime-light/stdlib/rpc/rpc-api.cpp @@ -183,8 +183,12 @@ kphp::coro::task> rpc_tl_query_result_one_impl(int64_t query_id) no const auto it_response_fetcher{rpc_client_instance_st.response_fetcher_instances.find(query_id)}; const auto it_fork_task{rpc_client_instance_st.response_awaiter_tasks.find(query_id)}; const vk::final_action finalizer{[&rpc_client_instance_st, it_response_fetcher, it_fork_task] noexcept { - rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); - rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + if (it_response_fetcher != rpc_client_instance_st.response_fetcher_instances.end()) [[likely]] { + rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); + } + if (it_fork_task != rpc_client_instance_st.response_awaiter_tasks.end()) [[likely]] { + rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + } }}; if (it_response_fetcher == rpc_client_instance_st.response_fetcher_instances.end() || it_fork_task == rpc_client_instance_st.response_awaiter_tasks.end()) @@ -236,8 +240,12 @@ kphp::coro::task> typed_rpc_tl_query_result_ const auto it_response_fetcher{rpc_client_instance_st.response_fetcher_instances.find(query_id)}; const auto it_fork_task{rpc_client_instance_st.response_awaiter_tasks.find(query_id)}; const vk::final_action finalizer{[&rpc_client_instance_st, it_response_fetcher, it_fork_task] noexcept { - rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); - rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + if (it_response_fetcher != rpc_client_instance_st.response_fetcher_instances.end()) [[likely]] { + rpc_client_instance_st.response_fetcher_instances.erase(it_response_fetcher); + } + if (it_fork_task != rpc_client_instance_st.response_awaiter_tasks.end()) [[likely]] { + rpc_client_instance_st.response_awaiter_tasks.erase(it_fork_task); + } }}; if (it_response_fetcher == rpc_client_instance_st.response_fetcher_instances.end() || it_fork_task == rpc_client_instance_st.response_awaiter_tasks.end())