Fix max_connections not being honoured on websockets listeners.

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

View File

@@ -1,4 +1,4 @@
2.0.23 - 2026-01-14
2.0.23 - 2026-xx-xx
===================
Broker:
@@ -13,6 +13,7 @@ Broker:
- Fix potential crash on startup if a malicious/corrupt persistence file from
mosquitto 1.5 or earlier is loaded. Closes #3439.
- Limit auto_id_prefix to 50 characters. Closes #3440.
- Fix max_connections not being honoured on websockets listeners. Closes #3455.
Windows:
- Installer will not overwrite an existing mosquitto.conf

View File

@@ -170,10 +170,12 @@ 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){
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;
@@ -194,6 +196,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