From 0aecb51fcdb0f2e8e8075585d49c592483ad97e0 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 14 Jan 2021 00:22:59 +0000 Subject: [PATCH] Rename reload_type -> bridge_reload_type, plus doc updates. --- man/mosquitto.conf.5.xml | 36 ++++++++++---------- mosquitto.conf | 12 +++++++ src/conf.c | 46 +++++++++++++------------- test/broker/06-bridge-config-reload.py | 2 +- 4 files changed, 54 insertions(+), 42 deletions(-) diff --git a/man/mosquitto.conf.5.xml b/man/mosquitto.conf.5.xml index 08037c76..37ec14eb 100644 --- a/man/mosquitto.conf.5.xml +++ b/man/mosquitto.conf.5.xml @@ -2037,6 +2037,24 @@ topic clients/total in 0 test/mosquitto/org/ $SYS/broker/ can be used on one bridge at once. + + [ lazy | immediate ] + + If you change bridge options in the configuration file, + those configuration changes are applied during a bridge + reconnection. The + + lazy is the default, and means + that any connected bridge will remain in its current state until + a natural reconnection happens, at which point the new configuration + will be used. + + immediate forces a reconnection and so + uses the new configuration straight away. + + [ true | false ] @@ -2057,24 +2075,6 @@ topic clients/total in 0 test/mosquitto/org/ $SYS/broker/ connection to succeed. - - [ lazy | immediate ] - - Configuration changes are applied during a bridge - reconnection. This option helps deciding when that - reconnection happens. It can be one of two types: - lazy and immediate. - - - lazy is the default, - and means that any connected bridge will remain in - that state. The configuration changes will be taken - during a later, natural reconnection. - - immediate forces a - reconnection in order to take the new values. - - diff --git a/mosquitto.conf b/mosquitto.conf index 4e407417..d7c2cb06 100644 --- a/mosquitto.conf +++ b/mosquitto.conf @@ -806,6 +806,18 @@ # Set to 0 for "unlimited". #bridge_max_packet_size 0 +# If you change bridge options in the configuration file, those configuration +# changes are applied during a bridge reconnection. The bridge_reload_type +# option determines when that reconnection happens, and can be set to either +# lazy or immediate. +# +# lazy is the default, and means that any connected bridge will remain in its +# current state until a natural reconnection happens, at which point the new +# configuration is used. +# +# immediate forces a reconnection and so uses the new configuration straight +# away. +#bridge_reload_type lazy # ----------------------------------------------------------------- # Certificate based SSL/TLS support diff --git a/src/conf.c b/src/conf.c index 97c35891..a7bb0e76 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1145,6 +1145,29 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct if(conf__parse_string(&token, "bridge_psk", &cur_bridge->tls_psk, saveptr)) return MOSQ_ERR_INVAL; #else log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge and/or TLS-PSK support not available."); +#endif + }else if(!strcmp(token, "bridge_reload_type")){ +#ifdef WITH_BRIDGE + if(!cur_bridge){ + log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration."); + return MOSQ_ERR_INVAL; + } + token = strtok_r(NULL, " ", &saveptr); + if(token){ + if(!strcmp(token, "lazy")){ + cur_bridge->reload_type = brt_lazy; + }else if(!strcmp(token, "immediate")){ + cur_bridge->reload_type = brt_immediate; + }else{ + log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge_reload_type value in configuration (%s).", token); + return MOSQ_ERR_INVAL; + } + }else{ + log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty bridge_reload_type value in configuration."); + return MOSQ_ERR_INVAL; + } +#else + log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available."); #endif }else if(!strcmp(token, "bridge_tls_version")){ #if defined(WITH_BRIDGE) && defined(WITH_TLS) @@ -1940,29 +1963,6 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct } #else log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available."); -#endif - }else if(!strcmp(token, "reload_type")){ -#ifdef WITH_BRIDGE - if(!cur_bridge){ - log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid bridge configuration."); - return MOSQ_ERR_INVAL; - } - token = strtok_r(NULL, " ", &saveptr); - if(token){ - if(!strcmp(token, "lazy")){ - cur_bridge->reload_type = brt_lazy; - }else if(!strcmp(token, "immediate")){ - cur_bridge->reload_type = brt_immediate; - }else{ - log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid reload_type value in configuration (%s).", token); - return MOSQ_ERR_INVAL; - } - }else{ - log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty reload_type value in configuration."); - return MOSQ_ERR_INVAL; - } -#else - log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Bridge support not available."); #endif }else if(!strcmp(token, "socket_domain")){ if(reload) continue; /* Listeners not valid for reloading. */ diff --git a/test/broker/06-bridge-config-reload.py b/test/broker/06-bridge-config-reload.py index bf523f11..281579a8 100755 --- a/test/broker/06-bridge-config-reload.py +++ b/test/broker/06-bridge-config-reload.py @@ -17,7 +17,7 @@ def write_config(filename, port1, port2, subtopic, reload_immediate=False): f.write("notifications false\n") f.write("restart_timeout 1\n") if reload_immediate: - f.write("reload_type immediate") + f.write("bridge_reload_type immediate") def accept_new_connection(sock):