Fix client count calculation

This commit is contained in:
Shuanglei Tao
2017-03-21 23:10:22 +08:00
parent f5333551ed
commit 35c97df863

View File

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