diff --git a/ChangeLog.txt b/ChangeLog.txt index 5482e7ee..96b09dc3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,8 @@ - Fix inconsistent disconnect log message format, and add address:port. - Fix `plugin`/`global_plugin` option not allowing space characters. - Fix $SYS load values not being published initially. Closes #3459. +- Fix max_connections not being honoured on libwebsockets listeners. This does + not affect the built-in websockets support. Closes #3455. # Plugins - Fix incorrect linking of libmosquitto_common.so for the acl and password diff --git a/src/websockets.c b/src/websockets.c index e5c1b058..530b045a 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -170,12 +170,14 @@ static int callback_mqtt( u->mosq = NULL; return -1; } + mosq->listener->client_count++; if((mosq->listener->max_connections > 0 && mosq->listener->client_count > mosq->listener->max_connections) || (db.config->global_max_connections > 0 && HASH_CNT(hh_sock, db.contexts_by_sock) > (unsigned int)db.config->global_max_connections)){ if(db.config->connection_messages == true){ log__printf(NULL, MOSQ_LOG_NOTICE, "Client connection from %s denied: max_connections exceeded.", mosq->address); } + mosq->listener->client_count--; mosquitto_FREE(mosq->address); mosquitto_FREE(mosq); u->mosq = NULL; @@ -196,6 +198,7 @@ static int callback_mqtt( HASH_DELETE(hh_sock, db.contexts_by_sock, mosq); mosq->sock = INVALID_SOCKET; mux__delete(mosq); + mosq->listener->client_count--; } mosq->wsi = NULL; #ifdef WITH_TLS