diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2023-12-06 15:32:27 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2023-12-06 15:32:57 +0900 |
commit | 06904b1154a797ece7834bc710b79ae7cf6b0c90 (patch) | |
tree | a8daceff779881ce9c6ecaf89a2f08264bdbe672 | |
parent | 297042c4d78bbad8e2107136ba4690bf93ee106c (diff) | |
download | tidl-06904b1154a797ece7834bc710b79ae7cf6b0c90.tar.gz tidl-06904b1154a797ece7834bc710b79ae7cf6b0c90.tar.bz2 tidl-06904b1154a797ece7834bc710b79ae7cf6b0c90.zip |
[v2] Add locking and unlocking mutex
It is problematic if a callback invoke event is delivered to the main thread
while calling callback dispose() in the sub-thread.
To fix the thread safe issue, this patch adds locking & unlocking mutex.
Change-Id: I3617a0896463ea2bea3574e00812a937b179b6ec
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
-rw-r--r-- | idlc/gen/version2/c_proxy_body_generator_cb.hh | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/idlc/gen/version2/c_proxy_body_generator_cb.hh b/idlc/gen/version2/c_proxy_body_generator_cb.hh index b2b377f..40602f5 100644 --- a/idlc/gen/version2/c_proxy_body_generator_cb.hh +++ b/idlc/gen/version2/c_proxy_body_generator_cb.hh @@ -366,15 +366,18 @@ int <PREFIX>_<NAME>_<DELEGATE_NAME>_dispose(<PREFIX>_<NAME>_h proxy, <PREFIX>_<N return RPC_PORT_ERROR_INVALID_PARAMETER; } + g_rec_mutex_lock(&proxy->mutex); found = g_list_find(proxy->delegates, h); if (found == nullptr) { _E("Invalid parameter"); + g_rec_mutex_unlock(&proxy->mutex); return RPC_PORT_ERROR_INVALID_PARAMETER; } proxy->delegates = g_list_remove_link(proxy->delegates, found); <PREFIX>_<NAME>_<DELEGATE_NAME>_destroy(h); g_list_free(found); + g_rec_mutex_unlock(&proxy->mutex); return RPC_PORT_ERROR_NONE; } @@ -627,7 +630,9 @@ static void __<PREFIX>_<NAME>_received(const char *endpoint, const char *port_na return; } + g_rec_mutex_lock(&h->mutex); __<PREFIX>_<NAME>_process_received_event(&h->delegates, map); + g_rec_mutex_unlock(&h->mutex); rpc_port_unit_map_destroy(map); } )__c_cb"; |