diff --git a/ChangeLog.txt b/ChangeLog.txt index f818c003ab..02ceae9a1a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,8 @@ Broker: - Add notes that libsystemd-dev or similar is needed if building with systemd support. Closes #2019. - Improve logging in obscure cases when a client disconnects. Closes #2017. +- Fix reloading of listeners where multiple listeners have been defined with + the same port but different bind addresses. Closes #2029. Apps: - Allow command line arguments to override config file options in diff --git a/src/conf.c b/src/conf.c index 611a62035b..9c9de4f479 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1417,8 +1417,21 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct { for(i=0; ilistener_count; i++){ if(config->listeners[i].port == tmp_int){ - cur_listener = &config->listeners[i]; - break; + /* Now check we have a matching bind address, if defined */ + if(config->listeners[i].host){ + if(token && !strcmp(config->listeners[i].host, token)){ + /* They both have a bind address, and they match */ + cur_listener = &config->listeners[i]; + break; + } + }else{ + if(token == NULL){ + /* Neither this config nor the new config have a bind address, + * so they match. */ + cur_listener = &config->listeners[i]; + break; + } + } } } }