From 5f2a45d96a52e1e0135b48aec281d612aa1ecdea Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 10 Feb 2026 18:42:36 +0000 Subject: [PATCH] Fix MOSQ_EVT_DISCONNECT being called before MOSQ_EVT_ACL_CHECK This occurs for the will of that client. Closes #3487. Thanks to ChrisBFX. --- ChangeLog.txt | 8 ++++++++ src/context.c | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 7d6a92cf..fe12bb1d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +2.1.3 - 2026-02-xx +================== + +Broker: +- Fix MOSQ_EVT_DISCONNECT being called before MOSQ_EVT_ACL_CHECK for the will + of that client. Closes #3487. + + 2.1.2 - 2026-02-09 ================== diff --git a/src/context.c b/src/context.c index ca4784d9..6b397d47 100644 --- a/src/context.c +++ b/src/context.c @@ -269,13 +269,14 @@ void context__disconnect(struct mosquitto *context, int reason) } } + context__send_will(context); + if(context->session_expiry_interval == MQTT_SESSION_EXPIRY_IMMEDIATE){ plugin__handle_disconnect(context, reason); }else{ plugin__handle_client_offline(context, reason); } - context__send_will(context); net__socket_close(context); #ifdef WITH_BRIDGE if(context->bridge == NULL)