From 251ad41f4c025412b88248462fc17f32785a35bb Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Sun, 4 Aug 2019 11:59:34 +0800 Subject: [PATCH] server: fix pthread_mutex_trylock usage --- src/protocol.c | 2 +- src/server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 -- 2.43.4