Fix reloading of listeners where multiple listeners have the same port.

This is only possible where they have different bind addresses.

Closes #2029. Thanks to Simon Aldrich.
This commit is contained in:
Roger A. Light 2021-01-19 10:16:06 +00:00
parent c9a4ef402e
commit 4165224885
2 changed files with 17 additions and 2 deletions

View File

@ -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

View File

@ -1417,9 +1417,22 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
{
for(i=0; i<config->listener_count; i++){
if(config->listeners[i].port == tmp_int){
/* 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;
}
}
}
}
}
if(!cur_listener){