From: Shuanglei Tao Date: Sun, 4 Aug 2019 03:59:34 +0000 (+0800) Subject: server: fix pthread_mutex_trylock usage X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=251ad41f4c025412b88248462fc17f32785a35bb;p=ttyd.git server: fix pthread_mutex_trylock usage --- diff --git a/src/protocol.c b/src/protocol.c index ebdb3e4..1b373b1 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -130,7 +130,7 @@ tty_client_destroy(struct tty_client *client) { client->running = false; - if (pthread_mutex_trylock(&client->mutex)) { + if (pthread_mutex_trylock(&client->mutex) == 0) { client->state = STATE_DONE; pthread_cond_signal(&client->cond); pthread_mutex_unlock(&client->mutex); diff --git a/src/server.c b/src/server.c index 09c9024..87454af 100644 --- a/src/server.c +++ b/src/server.c @@ -478,7 +478,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_trylock(&client->mutex)) { + if (client->running && pthread_mutex_trylock(&client->mutex) == 0) { if (client->state != STATE_DONE) lws_callback_on_writable(client->wsi); else