Don't rearrange leaves here until we are sure we have all the memory allocated.

pull/211/merge
Roger A. Light 11 years ago
parent eb01459571
commit 02be4965ea

@ -276,13 +276,6 @@ static int _sub_add(struct mosquitto_db *db, struct mosquitto *context, int qos,
leaf->next = NULL;
leaf->context = context;
leaf->qos = qos;
if(last_leaf){
last_leaf->next = leaf;
leaf->prev = last_leaf;
}else{
subhier->subs = leaf;
leaf->prev = NULL;
}
if(context->subs){
for(i=0; i<context->sub_count; i++){
if(!context->subs[i]){
@ -309,6 +302,13 @@ static int _sub_add(struct mosquitto_db *db, struct mosquitto *context, int qos,
}
context->subs[0] = subhier;
}
if(last_leaf){
last_leaf->next = leaf;
leaf->prev = last_leaf;
}else{
subhier->subs = leaf;
leaf->prev = NULL;
}
#ifdef WITH_SYS_TREE
db->subscription_count++;
#endif

Loading…
Cancel
Save