retained_ and subscription_count only used with sys tree.

pull/211/merge
Roger A. Light 11 years ago
parent 7b1ee68ef1
commit 3eead8c507

@ -218,9 +218,9 @@ struct mosquitto_db{
struct mqtt3_config *config; struct mqtt3_config *config;
int persistence_changes; int persistence_changes;
struct _mosquitto_auth_plugin auth_plugin; struct _mosquitto_auth_plugin auth_plugin;
#ifdef WITH_SYS_TREE
int subscription_count; int subscription_count;
int retained_count; int retained_count;
#ifdef WITH_SYS_TREE
int connected_count; int connected_count;
int disconnected_count; int disconnected_count;
#endif #endif

@ -82,12 +82,16 @@ static int _subs_process(struct mosquitto_db *db, struct _mosquitto_subhier *hie
if(hier->retained){ if(hier->retained){
hier->retained->ref_count--; hier->retained->ref_count--;
/* FIXME - it would be nice to be able to remove the message from the store at this point if ref_count == 0 */ /* FIXME - it would be nice to be able to remove the message from the store at this point if ref_count == 0 */
#ifdef WITH_SYS_TREE
db->retained_count--; db->retained_count--;
#endif
} }
if(stored->msg.payloadlen){ if(stored->msg.payloadlen){
hier->retained = stored; hier->retained = stored;
hier->retained->ref_count++; hier->retained->ref_count++;
#ifdef WITH_SYS_TREE
db->retained_count++; db->retained_count++;
#endif
}else{ }else{
hier->retained = NULL; hier->retained = NULL;
} }
@ -271,7 +275,9 @@ static int _sub_add(struct mosquitto_db *db, struct mosquitto *context, int qos,
subhier->subs = leaf; subhier->subs = leaf;
leaf->prev = NULL; leaf->prev = NULL;
} }
#ifdef WITH_SYS_TREE
db->subscription_count++; db->subscription_count++;
#endif
} }
return MOSQ_ERR_SUCCESS; return MOSQ_ERR_SUCCESS;
} }
@ -309,7 +315,9 @@ static int _sub_remove(struct mosquitto_db *db, struct mosquitto *context, struc
leaf = subhier->subs; leaf = subhier->subs;
while(leaf){ while(leaf){
if(leaf->context==context){ if(leaf->context==context){
#ifdef WITH_SYS_TREE
db->subscription_count--; db->subscription_count--;
#endif
if(leaf->prev){ if(leaf->prev){
leaf->prev->next = leaf->next; leaf->prev->next = leaf->next;
}else{ }else{
@ -496,7 +504,9 @@ static int _subs_clean_session(struct mosquitto_db *db, struct mosquitto *contex
leaf = root->subs; leaf = root->subs;
while(leaf){ while(leaf){
if(leaf->context == context){ if(leaf->context == context){
#ifdef WITH_SYS_TREE
db->subscription_count--; db->subscription_count--;
#endif
if(leaf->prev){ if(leaf->prev){
leaf->prev->next = leaf->next; leaf->prev->next = leaf->next;
}else{ }else{

Loading…
Cancel
Save