From: Shuanglei Tao Date: Wed, 17 Apr 2019 10:28:10 +0000 (+0800) Subject: server: do not block main thread when acquiring lock X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=e954cb5481cf43aa08cb618cae9301c50ba5f0ee;p=ttyd.git server: do not block main thread when acquiring lock --- 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