From e954cb5481cf43aa08cb618cae9301c50ba5f0ee Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Wed, 17 Apr 2019 18:28:10 +0800 Subject: [PATCH] server: do not block main thread when acquiring lock --- src/server.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/server.c b/src/server.c index ff848aa..413d9b9 100644 --- a/src/server.c +++ b/src/server.c @@ -475,8 +475,7 @@ main(int argc, char **argv) { if (!LIST_EMPTY(&server->clients)) { struct tty_client *client; LIST_FOREACH(client, &server->clients, list) { - if (client->running) { - pthread_mutex_lock(&client->mutex); + if (client->running && pthread_mutex_trylock(&client->mutex)) { if (client->state != STATE_DONE) lws_callback_on_writable(client->wsi); else -- 2.43.4