Skip to content

Commit f02575a

Browse files
committed
[k2] fix error with double store of tl::mask in tl::rpcReqResultExtra
1 parent b61435f commit f02575a

File tree

4 files changed

+6
-34
lines changed

4 files changed

+6
-34
lines changed

runtime-light/server/rpc/init-functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void init_server(kphp::component::stream&& request_stream, kphp::stl::vector<std
210210
superglobals.v$_SERVER.set_value(string{RPC_ACTOR_ID.data(), RPC_ACTOR_ID.size()}, (*invoke_rpc.opt_actor_id).value);
211211
}
212212
if (invoke_rpc.opt_extra) {
213-
superglobals.v$_SERVER.set_value(string{RPC_EXTRA_FLAGS.data(), RPC_EXTRA_FLAGS.size()}, static_cast<int64_t>((*invoke_rpc.opt_extra).get_flags().value));
213+
superglobals.v$_SERVER.set_value(string{RPC_EXTRA_FLAGS.data(), RPC_EXTRA_FLAGS.size()}, static_cast<int64_t>((*invoke_rpc.opt_extra).flags.value));
214214
process_rpc_invoke_req_extra(*invoke_rpc.opt_extra, superglobals);
215215
}
216216
kphp::log::info("rpc server initialized with: "
@@ -222,7 +222,7 @@ void init_server(kphp::component::stream&& request_stream, kphp::stl::vector<std
222222
"request -> {:#x}",
223223
invoke_rpc.net_pid.get_pid(), invoke_rpc.net_pid.get_port(), invoke_rpc.query_id.value,
224224
invoke_rpc.opt_actor_id.has_value() ? (*invoke_rpc.opt_actor_id).value : 0,
225-
invoke_rpc.opt_extra.has_value() ? (*invoke_rpc.opt_extra).get_flags().value : 0, request_magic.value);
225+
invoke_rpc.opt_extra.has_value() ? (*invoke_rpc.opt_extra).flags.value : 0, request_magic.value);
226226
}
227227

228228
} // namespace kphp::rpc

runtime-light/stdlib/rpc/rpc-api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ inline kphp::coro::task<> f$rpc_server_store_response(class_instance<C$VK$TL$Rpc
269269
// as we are in a coroutine, we must own the data to prevent it from being overwritten by another coroutine,
270270
// so create a TLBuffer owned by this coroutine
271271
auto& rpc_server_instance_st{RpcServerInstanceState::get()};
272-
tl::K2RpcResponse rpc_response{.value = tl::k2RpcResponseHeader{.flags = {}, .extra = {}, .result = rpc_server_instance_st.tl_storer.view()}};
272+
tl::K2RpcResponse rpc_response{.value = tl::k2RpcResponseHeader{.extra = {}, .result = rpc_server_instance_st.tl_storer.view()}};
273273
tl::storer tls{rpc_response.footprint()};
274274
rpc_response.store(tls);
275275

runtime-light/tl/tl-types.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ bool CertInfoItem::fetch(tl::fetcher& tlf) noexcept {
147147
// ===== RPC =====
148148

149149
bool rpcInvokeReqExtra::fetch(tl::fetcher& tlf) noexcept {
150-
tl::mask flags{};
151150
bool ok{flags.fetch(tlf)};
152151
if (ok && static_cast<bool>(flags.value & WAIT_BINLOG_POS_FLAG)) {
153152
ok &= opt_wait_binlog_pos.emplace().fetch(tlf);
@@ -194,31 +193,6 @@ bool rpcInvokeReqExtra::fetch(tl::fetcher& tlf) noexcept {
194193
return ok;
195194
}
196195

197-
tl::mask rpcInvokeReqExtra::get_flags() const noexcept {
198-
tl::mask flags{.value = static_cast<tl::mask::underlying_type>(return_binlog_pos)};
199-
200-
flags.value |= static_cast<tl::mask::underlying_type>(return_binlog_time) << 1;
201-
flags.value |= static_cast<tl::mask::underlying_type>(return_pid) << 2;
202-
flags.value |= static_cast<tl::mask::underlying_type>(return_request_sizes) << 3;
203-
flags.value |= static_cast<tl::mask::underlying_type>(return_failed_subqueries) << 4;
204-
flags.value |= static_cast<tl::mask::underlying_type>(return_query_stats) << 6;
205-
flags.value |= static_cast<tl::mask::underlying_type>(no_result) << 7;
206-
flags.value |= static_cast<tl::mask::underlying_type>(return_view_number) << 27;
207-
208-
flags.value |= static_cast<tl::mask::underlying_type>(opt_wait_binlog_pos.has_value()) << 16;
209-
flags.value |= static_cast<tl::mask::underlying_type>(opt_string_forward_keys.has_value()) << 18;
210-
flags.value |= static_cast<tl::mask::underlying_type>(opt_int_forward_keys.has_value()) << 19;
211-
flags.value |= static_cast<tl::mask::underlying_type>(opt_string_forward.has_value()) << 20;
212-
flags.value |= static_cast<tl::mask::underlying_type>(opt_int_forward.has_value()) << 21;
213-
flags.value |= static_cast<tl::mask::underlying_type>(opt_custom_timeout_ms.has_value()) << 23;
214-
flags.value |= static_cast<tl::mask::underlying_type>(opt_supported_compression_version.has_value()) << 25;
215-
flags.value |= static_cast<tl::mask::underlying_type>(opt_random_delay.has_value()) << 26;
216-
flags.value |= static_cast<tl::mask::underlying_type>(opt_persistent_query.has_value()) << 28;
217-
flags.value |= static_cast<tl::mask::underlying_type>(opt_trace_context.has_value()) << 29;
218-
flags.value |= static_cast<tl::mask::underlying_type>(opt_execution_context.has_value()) << 30;
219-
return flags;
220-
}
221-
222196
void rpcReqResultExtra::store(tl::storer& tls) const noexcept {
223197
flags.store(tls);
224198
if (static_cast<bool>(flags.value & BINLOG_POS_FLAG)) {

runtime-light/tl/tl-types.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,7 @@ class rpcInvokeReqExtra final {
10941094
static constexpr uint32_t EXECUTION_CONTEXT_FLAG = vk::tl::common::rpc_invoke_req_extra_flags::execution_context;
10951095

10961096
public:
1097+
tl::mask flags{};
10971098
bool return_binlog_pos{};
10981099
bool return_binlog_time{};
10991100
bool return_pid{};
@@ -1115,8 +1116,6 @@ class rpcInvokeReqExtra final {
11151116
bool return_view_number{};
11161117

11171118
bool fetch(tl::fetcher& tlf) noexcept;
1118-
1119-
tl::mask get_flags() const noexcept;
11201119
};
11211120

11221121
struct RpcInvokeReqExtra final {
@@ -1180,16 +1179,15 @@ struct k2RpcResponseError final {
11801179
};
11811180

11821181
struct k2RpcResponseHeader final {
1183-
tl::mask flags{};
11841182
tl::rpcReqResultExtra extra{};
11851183
std::span<const std::byte> result;
11861184

11871185
void store(tl::storer& tls) const noexcept {
1188-
flags.store(tls), extra.store(tls), tls.store_bytes(result);
1186+
extra.store(tls), tls.store_bytes(result);
11891187
}
11901188

11911189
constexpr size_t footprint() const noexcept {
1192-
return flags.footprint() + extra.footprint() + result.size();
1190+
return extra.footprint() + result.size();
11931191
}
11941192
};
11951193

0 commit comments

Comments
 (0)