From 4471ee9e470ba6ca4a2d5a4b17048787fd666d69 Mon Sep 17 00:00:00 2001 From: doragasu Date: Thu, 16 Sep 2021 17:06:55 +0200 Subject: [PATCH] Call disconnect callback on TLS error. When using the library asynchronously, TLS errors caused e.g. because of the date/time not set correctly, cause the connection to be silently dropped without the disconnection callback being invoked, as described in issue #1052. This commit fixes the issue, returning the behavior to the one the library had previous to version 1.5.4, if a TLS error occurs, the disconnect callback will be invoked for the client to get notified of the error. Signed-off-by: doragasu --- lib/loop.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/loop.c b/lib/loop.c index 04cf6d49..155b5e11 100644 --- a/lib/loop.c +++ b/lib/loop.c @@ -373,7 +373,11 @@ int mosquitto_loop_read(struct mosquitto *mosq, int max_packets) #ifdef WITH_TLS if(mosq->want_connect){ - return net__socket_connect_tls(mosq); + rc = net__socket_connect_tls(mosq); + if (MOSQ_ERR_TLS == rc){ + rc = mosquitto__loop_rc_handle(mosq, rc); + } + return rc; } #endif