Fix: session handling when per_listener_settings is set to true

Closes #2618
Closes #2526

Thanks to Reuben Miller and llamaonaskateboard.
This commit is contained in:
Roger A. Light
2025-09-17 17:00:07 +01:00
parent 53f5ab2ea0
commit 84aeb282e3

View File

@@ -240,6 +240,9 @@ int net__socket_close(struct mosquitto *mosq)
mosquitto__set_state(mosq, mosq_cs_disconnect_ws);
}
lws_callback_on_writable(mosq->wsi);
if(mosq->listener){
mosq->listener->client_count--;
}
}else
#endif
{
@@ -249,19 +252,15 @@ int net__socket_close(struct mosquitto *mosq)
if(mosq_found){
HASH_DELETE(hh_sock, db.contexts_by_sock, mosq_found);
}
if(mosq->listener && mosq->state != mosq_cs_disused){
mosq->listener->client_count--;
}
#endif
rc = COMPAT_CLOSE(mosq->sock);
mosq->sock = INVALID_SOCKET;
}
}
#ifdef WITH_BROKER
if(mosq->listener){
mosq->listener->client_count--;
mosq->listener = NULL;
}
#endif
return rc;
}