Add support for the --max-clients option

This commit is contained in:
Shuanglei Tao
2017-04-06 21:24:19 +08:00
parent 9cc5e4a03b
commit 3580e80783
7 changed files with 22 additions and 2 deletions

View File

@@ -188,6 +188,10 @@ callback_tty(struct lws *wsi, enum lws_callback_reasons reason,
lwsl_warn("refuse to serve WS client due to the --once option.\n");
return 1;
}
if (server->max_clients > 0 && server->client_count == server->max_clients) {
lwsl_warn("refuse to serve WS client due to the --max-clients option.\n");
return 1;
}
if (lws_hdr_copy(wsi, buf, sizeof(buf), WSI_TOKEN_GET_URI) <= 0 || strcmp(buf, WS_PATH)) {
lwsl_warn("refuse to serve WS client for illegal ws path: %s\n", buf);
return 1;