From 35c97df863f6eff64796359703e42a5125bb147a Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Tue, 21 Mar 2017 23:10:22 +0800 Subject: [PATCH] Fix client count calculation --- src/protocol.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/protocol.c b/src/protocol.c index b580d2c..15a82ab 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -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); } -- 2.43.4