8
0
forked from pool/paho-mqtt-c
Files
paho-mqtt-c/fix-reason-code-handling.patch
Antonio Teixeira 783d86d01b - Update to 1.3.14:
* Mainly a service release. Issues fixed:
    https://github.com/eclipse-paho/paho.mqtt.c/milestone/21?closed=1
  * Unix domain socket support
  * HTTP proxy improvements
    * the environment variable PAHO_C_CLIENT_USE_HTTP_PROXY must be
      set to TRUE for http_proxy environment variable to be used
    * the http_proxy environment variable to be read is lower case only
    * the no_proxy environment variable can be set to exclude hosts from
      using an environment set proxy
- Fix builds with GCC15 (gh#eclipse-paho/paho.mqtt.c#1576)
  * fix-build-gcc15.patch
- Ensure argument for isprint and isxdigit is in the correct range
  (gh#eclipse-paho/paho.mqtt.c#1565)
  * fix-char-range.patch
- Fix handling of MQTT 5 reason codes (gh#eclipse-paho/paho.mqtt.c#1596)
  * fix-reason-code-handling.patch

OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/paho-mqtt-c?expand=0&rev=18
2025-07-15 17:12:41 +00:00

32 lines
1.1 KiB
Diff

From 9ef8f4d865657434ff36b24af2b8980c942bacaa Mon Sep 17 00:00:00 2001
From: Ian Craggs <icraggs@gmail.com>
Date: Tue, 6 May 2025 15:36:26 +0100
Subject: [PATCH] Put MQTT 5 reason code into the connect failure reason code
field #1596
---
src/MQTTAsyncUtils.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/MQTTAsyncUtils.c b/src/MQTTAsyncUtils.c
index c084a11e3..d8315514d 100644
--- a/src/MQTTAsyncUtils.c
+++ b/src/MQTTAsyncUtils.c
@@ -1703,7 +1703,15 @@ static void nextOrClose(MQTTAsyncs* m, int rc, char* message)
MQTTAsync_failureData5 data = MQTTAsync_failureData5_initializer;
data.token = 0;
- data.code = rc;
+ if (rc > 0) /* MQTT Reason Codes are > 0; C client return codes are < 0 */
+ {
+ /* MQTT 5 reason codes >= 0x00 and < 0x80 are successful,
+ * but in that case we should not get here but be calling
+ * onSuccess instead. */
+ data.reasonCode = rc;
+ data.code = MQTTASYNC_FAILURE;
+ } else
+ data.code = rc;
data.message = message;
Log(TRACE_MIN, -1, "Calling connect failure for client %s", m->c->clientID);
(*(m->connect.onFailure5))(m->connect.context, &data);