]> prime8.dev >> repos - ttyd.git/commitdiff
Fix client count calculation
authorShuanglei Tao <tsl0922@gmail.com>
Tue, 21 Mar 2017 15:10:22 +0000 (23:10 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Tue, 21 Mar 2017 15:14:48 +0000 (23:14 +0800)
src/protocol.c

index b580d2c53d815438c00148884f9c3fbb3c2e8939..15a82ab2ae177335780787557aed90683503f79d 100644 (file)
@@ -80,8 +80,14 @@ check_host_origin(struct lws *wsi) {
 void
 tty_client_remove(struct tty_client *client) {
     pthread_mutex_lock(&server->lock);
-    LIST_REMOVE(client, list);
-    server->client_count--;
+    struct tty_client *iterator;
+    LIST_FOREACH(iterator, &server->clients, list) {
+        if (iterator == client) {
+            LIST_REMOVE(iterator, list);
+            server->client_count--;
+            break;
+        }
+    }
     pthread_mutex_unlock(&server->lock);
 }