From: Junghoon Park Date: Fri, 8 Jun 2018 02:36:24 +0000 (+0900) Subject: Use try_lock() to get lock X-Git-Tag: submit/tizen/20180612.050900~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c8355c5f817f0293f0a4df9a33e7dc099e7dc72f;p=platform%2Fcore%2Fappfw%2Ftidl.git Use try_lock() to get lock - Ignore event when other threads are sending something Change-Id: I2eba4d0b9f49992dae5232173d68171b7aeb592b Signed-off-by: Junghoon Park --- diff --git a/idlc/c_gen/c_proxy_body_gen_cb.h b/idlc/c_gen/c_proxy_body_gen_cb.h index 94c43e31..86529ccc 100644 --- a/idlc/c_gen/c_proxy_body_gen_cb.h +++ b/idlc/c_gen/c_proxy_body_gen_cb.h @@ -253,7 +253,8 @@ static void __##_on_received(const char *endpoint, const char *port_name, void * rpc_port_parcel_h parcel_received; int cmd = -1; - g_rec_mutex_lock(&handle->mutex); + if (g_rec_mutex_trylock(&handle->mutex) == FALSE) + return; rpc_port_parcel_create_from_port(&parcel_received, handle->port); rpc_port_parcel_read_int32(parcel_received, &cmd); if (cmd != ##_METHOD_Callback) { diff --git a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h index e24a069b..32080113 100644 --- a/idlc/cpp_gen/cpp_proxy_body_gen_cb.h +++ b/idlc/cpp_gen/cpp_proxy_body_gen_cb.h @@ -141,12 +141,15 @@ void ##::OnReceivedCB(const char *ep, const char *port_name, void *data) { int cmd; rpc_port_parcel_h parcel_received; - do { - std::lock_guard lock(l->mutex_); - if (rpc_port_parcel_create_from_port(&parcel_received, l->port_) != 0) - return; - } while (false); + if (!l->mutex_.try_lock()) + return; + + if (rpc_port_parcel_create_from_port(&parcel_received, l->port_) != 0) { + l->mutex_.unlock(); + return; + } + l->mutex_unlock(); rpc_port_parcel_read_int32(parcel_received, &cmd); if (cmd != static_cast(MethodId::__Callback)) { rpc_port_parcel_destroy(parcel_received);