summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunghoon Park <jh9216.park@samsung.com>2018-06-08 11:36:24 +0900
committerJunghoon Park <jh9216.park@samsung.com>2018-06-08 11:36:24 +0900
commitc8355c5f817f0293f0a4df9a33e7dc099e7dc72f (patch)
tree3de328f3646127f5235835c170d8e098ca7b0100
parente75f1bf740b1b927845089f894324a8ecf87a1ff (diff)
downloadtidl-c8355c5f817f0293f0a4df9a33e7dc099e7dc72f.tar.gz
tidl-c8355c5f817f0293f0a4df9a33e7dc099e7dc72f.tar.bz2
tidl-c8355c5f817f0293f0a4df9a33e7dc099e7dc72f.zip
Use try_lock() to get lock
- Ignore event when other threads are sending something Change-Id: I2eba4d0b9f49992dae5232173d68171b7aeb592b Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
-rw-r--r--idlc/c_gen/c_proxy_body_gen_cb.h3
-rw-r--r--idlc/cpp_gen/cpp_proxy_body_gen_cb.h13
2 files changed, 10 insertions, 6 deletions
diff --git a/idlc/c_gen/c_proxy_body_gen_cb.h b/idlc/c_gen/c_proxy_body_gen_cb.h
index 94c43e3..86529cc 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 e24a069..3208011 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<std::recursive_mutex> 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<int>(MethodId::__Callback)) {
rpc_port_parcel_destroy(parcel_received);