Modify local execution mode 77/314577/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 15 Jul 2024 22:50:22 +0000 (07:50 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 15 Jul 2024 22:50:22 +0000 (07:50 +0900)
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 <h.jhun@samsung.com>
idlc/gen/version2/c_stub_body_generator_cb.hh
idlc/gen/version2/cpp_stub_body_generator_cb.hh

index cc4a53548c4c4995d3f0a831cbc5610382fb8431..9791525674e1fd84353c15b28b576404bd989c17 100644 (file)
@@ -2251,6 +2251,13 @@ EXPORT_API int rpc_port_stub_<INPUT_FILE>_lem_<IFACE_NAME>_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_<INPUT_FILE>_lem_<IFACE_NAME>_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_<INPUT_FILE>_lem_<IFACE_NAME>_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_<INPUT_FILE>_lem_<IFACE_NAME>_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");
index 03ee218d57a3837890dc315d4142fc2b6620827a..782bc212f59d768d6e08f1f454e26e24c5c294d6 100644 (file)
@@ -714,6 +714,11 @@ EXPORT_API int rpc_port_stub_<INPUT_FILE>_lem_<CLS_NAME>_connect(void* context,
 
   std::string sender_str(sender);
   std::string instance_str(instance);
+  if (gettid() == getpid()) {
+    <CLS_NAME>_context_->OnConnected(context, sender, instance, sync);
+    return RPC_PORT_ERROR_NONE;
+  }
+
   auto* func = new std::function<void()>([context, sender_str, instance_str, sync] {
         <CLS_NAME>_context_->OnConnected(context, sender_str, instance_str, sync);
       });
@@ -733,6 +738,11 @@ EXPORT_API int rpc_port_stub_<INPUT_FILE>_lem_<CLS_NAME>_disconnect(void* contex
 
   std::string sender_str(sender);
   std::string instance_str(instance);
+  if (gettid() == getpid()) {
+    <CLS_NAME>_context_->OnDisconnected(context, sender, instance);
+    return RPC_PORT_ERROR_NONE;
+  }
+
   auto* func = new std::function<void()>([context, sender_str, instance_str] {
         <CLS_NAME>_context_->OnDisconnected(context, sender_str, instance_str);
       });
@@ -751,6 +761,11 @@ EXPORT_API int rpc_port_stub_<INPUT_FILE>_lem_<CLS_NAME>_send(void* context, rpc
   }
 
   rpc_port_parcel_h cloned_parcel = Clone(parcel);
+  if (gettid() == getpid()) {
+    <CLS_NAME>_context_->OnReceived(context, cloned_parcel);
+    return RPC_PORT_ERROR_NONE;
+  }
+
   auto* func = new std::function<void()>([context, cloned_parcel] {
         <CLS_NAME>_context_->OnReceived(context, cloned_parcel);
       });