Fix max_connections not being honoured on libwebsockets listeners.

Closes #3455. Thanks to FelixPopp.
This commit is contained in:
Roger A. Light
2026-02-03 23:20:44 +00:00
parent aa4bfa68ab
commit 578d30e90f
2 changed files with 5 additions and 0 deletions

View File

@@ -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

View File

@@ -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