Fix exeption handling of stub code of C generator
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 21 Jan 2022 05:33:54 +0000 (14:33 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 11 Feb 2022 01:19:40 +0000 (10:19 +0900)
- Add stub ptr check to the deregistration function
- Change function call to g_rec_mutex_clear() in the registeration function

Change-Id: I360083e4404e7935dd63eabbba540b3901ee9cd8
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
idlc/gen/c_stub_body_gen_cb.h

index 877485a..d9dc5e4 100644 (file)
@@ -1043,7 +1043,7 @@ int <PREFIX>_<NAME>_register(<PREFIX>_<NAME>_callback_s *callback, void *user_da
   ret = rpc_port_stub_create(&__<NAME>.stub, "<NAME>");
   if (ret != RPC_PORT_ERROR_NONE) {
     _E("Failed to create stub handle. error(%d)", ret);
-    <PREFIX>_<NAME>_unregister();
+    g_rec_mutex_clear(&__<NAME>.mutex);
     return ret;
   }
 
@@ -1087,6 +1087,9 @@ int <PREFIX>_<NAME>_register(<PREFIX>_<NAME>_callback_s *callback, void *user_da
 
 int <PREFIX>_<NAME>_unregister(void)
 {
+  if (__<NAME>.stub == nullptr)
+    return RPC_PORT_ERROR_NONE;
+
   g_rec_mutex_lock(&__<NAME>.mutex);
   g_rec_mutex_unlock(&__<NAME>.mutex);
   g_rec_mutex_clear(&__<NAME>.mutex);