Fix listener not being reassociated with client.

This occurred when reloading a persistence file and
`per_listener_settings true` is set and the client did not set a
username.

Closes #1891. Thanks to Mikkel Nepper-Christensen.
pull/1811/head
Roger A. Light 5 years ago
parent 1666ed5f31
commit 29830ef6f1

@ -1,5 +1,8 @@
Broker: Broker:
- Fix crash on Windows if loading a plugin fails. Closes #1866. - Fix crash on Windows if loading a plugin fails. Closes #1866.
- Fix listener not being reassociated with client when reloading a persistence
file and `per_listener_settings true` is set and the client did not set a
username. Closes #1891.
1.6.12 - 2020-08-19 1.6.12 - 2020-08-19

@ -199,13 +199,13 @@ static int persist__client_chunk_restore(struct mosquitto_db *db, FILE *db_fptr)
/* username is not freed here, it is now owned by context */ /* username is not freed here, it is now owned by context */
context->username = chunk.username; context->username = chunk.username;
chunk.username = NULL; chunk.username = NULL;
/* in per_listener_settings mode, try to find the listener by persisted port */ }
if(db->config->per_listener_settings && !context->listener && chunk.F.listener_port > 0){ /* in per_listener_settings mode, try to find the listener by persisted port */
for(i=0; i < db->config->listener_count; i++){ if(db->config->per_listener_settings && !context->listener && chunk.F.listener_port > 0){
if(db->config->listeners[i].port == chunk.F.listener_port){ for(i=0; i < db->config->listener_count; i++){
context->listener = &db->config->listeners[i]; if(db->config->listeners[i].port == chunk.F.listener_port){
break; context->listener = &db->config->listeners[i];
} break;
} }
} }
} }

@ -177,9 +177,9 @@ static int persist__client_save(struct mosquitto_db *db, FILE *db_fptr)
if(context->username){ if(context->username){
chunk.F.username_len = strlen(context->username); chunk.F.username_len = strlen(context->username);
chunk.username = context->username; chunk.username = context->username;
if(context->listener){ }
chunk.F.listener_port = context->listener->port; if(context->listener){
} chunk.F.listener_port = context->listener->port;
} }
rc = persist__chunk_client_write_v6(db_fptr, &chunk); rc = persist__chunk_client_write_v6(db_fptr, &chunk);

Loading…
Cancel
Save