From a3295083398aaf006b84b9454c901381b26509f6 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 16 Jul 2024 07:50:22 +0900 Subject: [PATCH] Modify local execution mode If the thread ID is equal to the process ID, the callback function should be invoked. This patch is for backward compatibility. Change-Id: I3250fbc0db0b1969c754443a378ff1f57bf4a83e Signed-off-by: Hwankyu Jhun --- idlc/gen/version2/c_stub_body_generator_cb.hh | 22 +++++++++++++++++++++- idlc/gen/version2/cpp_stub_body_generator_cb.hh | 15 +++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/idlc/gen/version2/c_stub_body_generator_cb.hh b/idlc/gen/version2/c_stub_body_generator_cb.hh index cc4a535..9791525 100644 --- a/idlc/gen/version2/c_stub_body_generator_cb.hh +++ b/idlc/gen/version2/c_stub_body_generator_cb.hh @@ -2251,6 +2251,13 @@ EXPORT_API int rpc_port_stub__lem__connect(void *context return RPC_PORT_ERROR_IO_ERROR; } + if (gettid() == getpid()) { + if (handle->callback.connected) + handle->callback.connected(context, sender, instance, sync); + + return RPC_PORT_ERROR_NONE; + } + data = rpc_port_stub_lem_data_create(context, sender, instance, sync); if (data == nullptr) { _E("Ouf of memory"); @@ -2267,7 +2274,6 @@ EXPORT_API int rpc_port_stub__lem__connect(void *context g_source_set_callback(source, (GSourceFunc)rpc_port_stub_lem_on_connected, handle, nullptr); g_source_attach(source, handle->context); g_source_unref(source); - return RPC_PORT_ERROR_NONE; } @@ -2282,6 +2288,13 @@ EXPORT_API int rpc_port_stub__lem__disconnect(void *cont return RPC_PORT_ERROR_IO_ERROR; } + if (gettid() == getpid()) { + if (handle->callback.disconnected) + handle->callback.disconnected(context, sender, instance); + + return RPC_PORT_ERROR_NONE; + } + data = rpc_port_stub_lem_data_create(context, sender, instance, false); if (data == nullptr) { _E("Ouf of memory"); @@ -2312,6 +2325,13 @@ EXPORT_API int rpc_port_stub__lem__send(void *context, c return RPC_PORT_ERROR_IO_ERROR; } + if (gettid() == getpid()) { + if (handle->callback.received) + handle->callback.received(context, sender, instance, parcel); + + return RPC_PORT_ERROR_NONE; + } + data = rpc_port_stub_lem_data_create_with_parcel(context, sender, instance, parcel); if (data == nullptr) { _E("Ouf of memory"); diff --git a/idlc/gen/version2/cpp_stub_body_generator_cb.hh b/idlc/gen/version2/cpp_stub_body_generator_cb.hh index 03ee218..782bc21 100644 --- a/idlc/gen/version2/cpp_stub_body_generator_cb.hh +++ b/idlc/gen/version2/cpp_stub_body_generator_cb.hh @@ -714,6 +714,11 @@ EXPORT_API int rpc_port_stub__lem__connect(void* context, std::string sender_str(sender); std::string instance_str(instance); + if (gettid() == getpid()) { + _context_->OnConnected(context, sender, instance, sync); + return RPC_PORT_ERROR_NONE; + } + auto* func = new std::function([context, sender_str, instance_str, sync] { _context_->OnConnected(context, sender_str, instance_str, sync); }); @@ -733,6 +738,11 @@ EXPORT_API int rpc_port_stub__lem__disconnect(void* contex std::string sender_str(sender); std::string instance_str(instance); + if (gettid() == getpid()) { + _context_->OnDisconnected(context, sender, instance); + return RPC_PORT_ERROR_NONE; + } + auto* func = new std::function([context, sender_str, instance_str] { _context_->OnDisconnected(context, sender_str, instance_str); }); @@ -751,6 +761,11 @@ EXPORT_API int rpc_port_stub__lem__send(void* context, rpc } rpc_port_parcel_h cloned_parcel = Clone(parcel); + if (gettid() == getpid()) { + _context_->OnReceived(context, cloned_parcel); + return RPC_PORT_ERROR_NONE; + } + auto* func = new std::function([context, cloned_parcel] { _context_->OnReceived(context, cloned_parcel); }); -- 2.7.4