]> prime8.dev >> repos - ttyd.git/commitdiff
server: do not block main thread when acquiring lock
authorShuanglei Tao <tsl0922@gmail.com>
Wed, 17 Apr 2019 10:28:10 +0000 (18:28 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Wed, 17 Apr 2019 10:28:10 +0000 (18:28 +0800)
src/server.c

index ff848aa13938ea9378eec429667e0eeb62ab89e1..413d9b9166294132d8f45b449e68deccb574e8de 100644 (file)
@@ -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