Fix saving of persistence messages that start with a '/'.

Closes #151. Thanks to Andrew Chambers.

Signed-off-by: Roger A. Light <roger@atchoo.org>
pull/198/head
Roger A. Light 10 years ago
parent 3048c5ba0d
commit 57da586703

@ -12,6 +12,7 @@ Broker:
- Fix incorrect $SYS heap memory reporting when using ACLs.
- Bridge config parameters couldn't contain a space, this has been fixed.
Closes #150.
- Fix saving of persistence messages that start with a '/'. Closes #151.
- Fix reconnecting for bridges that use TLS on Windows. Closes #154.
Client library:

@ -248,7 +248,7 @@ error:
return 1;
}
static int _db_subs_retain_write(struct mosquitto_db *db, FILE *db_fptr, struct _mosquitto_subhier *node, const char *topic)
static int _db_subs_retain_write(struct mosquitto_db *db, FILE *db_fptr, struct _mosquitto_subhier *node, const char *topic, int level)
{
struct _mosquitto_subhier *subhier;
struct _mosquitto_subleaf *sub;
@ -261,7 +261,7 @@ static int _db_subs_retain_write(struct mosquitto_db *db, FILE *db_fptr, struct
slen = strlen(topic) + strlen(node->topic) + 2;
thistopic = _mosquitto_malloc(sizeof(char)*slen);
if(!thistopic) return MOSQ_ERR_NOMEM;
if(strlen(topic)){
if(level > 1 || strlen(topic)){
snprintf(thistopic, slen, "%s/%s", topic, node->topic);
}else{
snprintf(thistopic, slen, "%s", node->topic);
@ -306,7 +306,7 @@ static int _db_subs_retain_write(struct mosquitto_db *db, FILE *db_fptr, struct
subhier = node->children;
while(subhier){
_db_subs_retain_write(db, db_fptr, subhier, thistopic);
_db_subs_retain_write(db, db_fptr, subhier, thistopic, level+1);
subhier = subhier->next;
}
_mosquitto_free(thistopic);
@ -322,7 +322,7 @@ static int mqtt3_db_subs_retain_write(struct mosquitto_db *db, FILE *db_fptr)
subhier = db->subs.children;
while(subhier){
_db_subs_retain_write(db, db_fptr, subhier, "");
_db_subs_retain_write(db, db_fptr, subhier->children, "", 0);
subhier = subhier->next;
}

@ -462,12 +462,12 @@ int mqtt3_sub_add(struct mosquitto_db *db, struct mosquitto *context, const char
child->subs = NULL;
child->children = NULL;
child->retained = NULL;
if(db->subs.children){
child->next = db->subs.children;
if(root->children){
child->next = root->children;
}else{
child->next = NULL;
}
db->subs.children = child;
root->children = child;
rc = _sub_add(db, context, qos, child, tokens);
}

Loading…
Cancel
Save