From: Shuanglei Tao Date: Tue, 21 Mar 2017 15:10:22 +0000 (+0800) Subject: Fix client count calculation X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=35c97df863f6eff64796359703e42a5125bb147a;p=ttyd.git Fix client count calculation --- 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); }