mirror of
https://github.com/eclipse-mosquitto/mosquitto.git
synced 2026-09-26 12:27:28 +08:00
Don't rearrange leaves here until we are sure we have all the memory allocated.
This commit is contained in:
+7
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user