Skip to content

Commit 10b1e17

Browse files
committed
fix(imc): report streaming handlers in GetRpcInfo
GetRpcInfo now checks streaming_rpc_handlers when the regular handler map has no entry, so has_handler correctly returns BML_TRUE for streaming RPC registrations.
1 parent 9932e51 commit 10b1e17

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

src/Core/ImcBusRpc.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,12 @@ namespace BML::Core {
415415
out_info->total_latency_ns =
416416
it->second.stats->total_latency_ns.load(std::memory_order_relaxed);
417417
} else {
418-
out_info->has_handler = BML_FALSE;
418+
auto streaming_it = m_RpcState.streaming_rpc_handlers.find(rpc_id);
419+
out_info->has_handler =
420+
(streaming_it != m_RpcState.streaming_rpc_handlers.end() &&
421+
streaming_it->second.handler)
422+
? BML_TRUE
423+
: BML_FALSE;
419424
}
420425
return BML_RESULT_OK;
421426
}

tests/ImcBusTest.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ BML_Result CaptureCurrentModuleRpc(BML_Context,
245245
return BML_RESULT_OK;
246246
}
247247

248+
BML_Result NoopStreamingRpc(BML_Context,
249+
BML_RpcId,
250+
const BML_ImcMessage *,
251+
BML_RpcStream,
252+
void *) {
253+
return BML_RESULT_OK;
254+
}
255+
248256
void CaptureCurrentModuleFutureCallback(BML_Context,
249257
BML_Future,
250258
void *user_data) {
@@ -1374,6 +1382,22 @@ TEST_F(ImcBusTest, FutureAwaitRejectsMainThreadButWorkerThreadCanWait) {
13741382
EXPECT_EQ(BML_RESULT_OK, UnregisterRpc(rpc));
13751383
}
13761384

1385+
TEST_F(ImcBusTest, GetRpcInfoReportsRegisteredStreamingHandler) {
1386+
BML_RpcId rpc = BML_RPC_ID_INVALID;
1387+
ASSERT_EQ(BML_RESULT_OK, GetRpcId("streaming.rpc.info", &rpc));
1388+
1389+
ASSERT_EQ(BML_RESULT_OK,
1390+
ImcRegisterStreamingRpc(host_mod_, rpc, NoopStreamingRpc, nullptr));
1391+
1392+
BML_RpcInfo info = BML_RPC_INFO_INIT;
1393+
ASSERT_EQ(BML_RESULT_OK, GetRpcInfo(rpc, &info));
1394+
EXPECT_EQ(info.rpc_id, rpc);
1395+
EXPECT_EQ(info.has_handler, BML_TRUE);
1396+
EXPECT_STREQ(info.name, "streaming.rpc.info");
1397+
1398+
EXPECT_EQ(BML_RESULT_OK, ImcUnregisterRpc(host_mod_, rpc));
1399+
}
1400+
13771401
// ========================================================================
13781402
// Priority Message Ordering Tests
13791403
// ========================================================================

0 commit comments

Comments
 (0)