From 2db9aecac42df7d184189871089e88c711117930 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Sun, 20 Dec 2020 17:21:17 +0000 Subject: [PATCH] Do not reset bind address option if passed NULL. mosquitto_connect_bind_async() and mosquitto_connect_bind_v5() should not reset the bind address option if called with bind_address == NULL. Otherwise calling mosquitto_connect_async() will *force* the bind address to be reset, even if previously set with mosquitto_string_option(). --- ChangeLog.txt | 2 ++ lib/connect.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8e8c6d8f..8e2572e3 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,8 @@ Broker: - Fix $SYS/broker/publish/messages/+ counters not being updated for QoS 1, 2 messages. Closes #1968. +- mosquitto_connect_bind_async() and mosquitto_connect_bind_v5() should not + reset the bind address option if called with bind_address == NULL. 2.0.3 - 2020-12-17 diff --git a/lib/connect.c b/lib/connect.c index 4a0d1eec..f5669924 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -96,8 +96,10 @@ int mosquitto_connect_bind_v5(struct mosquitto *mosq, const char *host, int port { int rc; - rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); - if(rc) return rc; + if(bind_address){ + rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); + if(rc) return rc; + } mosquitto_property_free_all(&mosq->connect_properties); if(properties){ @@ -128,8 +130,10 @@ int mosquitto_connect_bind_async(struct mosquitto *mosq, const char *host, int p { int rc; - rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); - if(rc) return rc; + if(bind_address){ + rc = mosquitto_string_option(mosq, MOSQ_OPT_BIND_ADDRESS, bind_address); + if(rc) return rc; + } rc = mosquitto__connect_init(mosq, host, port, keepalive); if(rc) return rc;