Skip to content

Commit

Permalink
Fix reloading of listeners where multiple listeners have the same port.
Browse files Browse the repository at this point in the history
This is only possible where they have different bind addresses.

Closes #2029. Thanks to Simon Aldrich.
  • Loading branch information
ralight committed Jan 19, 2021
1 parent c9a4ef4 commit 4165224
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions src/conf.c
Expand Up @@ -1417,8 +1417,21 @@ 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){
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;
}
}
}
}
}
Expand Down

0 comments on commit 4165224

Please sign in to comment.