From: Hwankyu Jhun Date: Wed, 6 Dec 2023 06:32:27 +0000 (+0900) Subject: [v2] Add locking and unlocking mutex X-Git-Tag: accepted/tizen/8.0/unified/20231208.171926~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5a5e5a7da22489bec0b17f46b283fbf7f2254a2f;p=platform%2Fcore%2Fappfw%2Ftidl.git [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 --- diff --git a/idlc/gen/version2/c_proxy_body_generator_cb.hh b/idlc/gen/version2/c_proxy_body_generator_cb.hh index b2b377f0..40602f53 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 ___dispose(__h 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); ___destroy(h); g_list_free(found); + g_rec_mutex_unlock(&proxy->mutex); return RPC_PORT_ERROR_NONE; } @@ -627,7 +630,9 @@ static void ____received(const char *endpoint, const char *port_na return; } + g_rec_mutex_lock(&h->mutex); ____process_received_event(&h->delegates, map); + g_rec_mutex_unlock(&h->mutex); rpc_port_unit_map_destroy(map); } )__c_cb";