]> prime8.dev >> repos - ttyd.git/commitdiff
server: fix pthread_mutex_trylock usage
authorShuanglei Tao <tsl0922@gmail.com>
Sun, 4 Aug 2019 03:59:34 +0000 (11:59 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sun, 4 Aug 2019 03:59:34 +0000 (11:59 +0800)
src/protocol.c
src/server.c

index ebdb3e4bbfc8799bc391708b757a9ba23f79a71e..1b373b1d0cbb73b99f8ba281610254e4e7f59f75 100644 (file)
@@ -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);
index 09c9024cc4c8d7cecf2062fba17c3f2743ca1768..87454afa0fe643ca38b015f32c9d5a66468b6e78 100644 (file)
@@ -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