From f7347f0f70716a17a1a122955262788ccc994fe5 Mon Sep 17 00:00:00 2001 From: Xpol Wan Date: Fri, 29 Apr 2016 12:37:52 +0800 Subject: [PATCH] Should not change outter lock. --- src/pc_pomelo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pc_pomelo.c b/src/pc_pomelo.c index 899c653..366f84c 100644 --- a/src/pc_pomelo.c +++ b/src/pc_pomelo.c @@ -350,6 +350,8 @@ int pc_client_poll(pc_client_t* client) return PC_RC_ERROR; } + pc_mutex_lock(&client->event_mutex); + /* * `is_in_poll` is used to avoid recursive invocation of pc_client_poll * by identical thread as `pc_mutex_t` is recursive. @@ -360,7 +362,6 @@ int pc_client_poll(pc_client_t* client) if (!client->is_in_poll) { client->is_in_poll = 1; - pc_mutex_lock(&client->event_mutex); while(!QUEUE_EMPTY(&client->pending_ev_queue)) { q = QUEUE_HEAD(&client->pending_ev_queue); ev = (pc_event_t*) QUEUE_DATA(q, pc_event_t, queue); @@ -375,10 +376,10 @@ int pc_client_poll(pc_client_t* client) pc__handle_event(client, ev); pc_mutex_lock(&client->event_mutex); } - pc_mutex_unlock(&client->event_mutex); client->is_in_poll = 0; } + pc_mutex_unlock(&client->event_mutex); return PC_RC_OK; }