Skip to content

Commit

Permalink
Should not change outter lock.
Browse files Browse the repository at this point in the history
  • Loading branch information
xpol committed Apr 29, 2016
1 parent 5ebf2e4 commit f7347f0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pc_pomelo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit f7347f0

Please sign in to comment.