فهرست منبع

updated to change in reference counters and CDS initialization

Vaclav Kubart 18 سال پیش
والد
کامیت
ccea4a04f7

+ 2 - 1
lib/presence/domain_maintainer.c

@@ -36,6 +36,7 @@ domain_maintainer_t *create_domain_maintainer()
 	if (dm) {
 		ptr_vector_init(&dm->registered_domains, 8);
 		cds_mutex_init(&dm->mutex);
+		dm->rc_grp = create_reference_counter_group(16);
 	}
 	return dm;
 }
@@ -79,7 +80,7 @@ static notifier_domain_t *find_domain_nolock(domain_maintainer_t *dm, const str_
 
 static notifier_domain_t *add_domain_nolock(domain_maintainer_t *dm, const str_t *name)
 {
-	notifier_domain_t *d = create_notifier_domain(name);
+	notifier_domain_t *d = create_notifier_domain(dm->rc_grp, name);
 	
 	if (d) {
 		DEBUG_LOG("created domain: \'%.*s\'\n", FMT_STR(d->name));

+ 1 - 0
lib/presence/domain_maintainer.h

@@ -36,6 +36,7 @@ extern "C" {
 
 typedef struct {
 	ptr_vector_t registered_domains;
+	reference_counter_group_t *rc_grp;
 	cds_mutex_t mutex;
 } domain_maintainer_t;
 

+ 4 - 3
lib/presence/notifier_domain.c

@@ -241,7 +241,7 @@ static void remove_notifier_from_subscription(qsa_subscription_t *s, notifier_t
 /* -------- Domain initialization/destruction functions -------- */
 
 /** Creates a new domain using cds memory functions. */
-notifier_domain_t *create_notifier_domain(const str_t *name)
+notifier_domain_t *create_notifier_domain(reference_counter_group_t *g, const str_t *name)
 {
 	notifier_domain_t *d = (notifier_domain_t*)cds_malloc(sizeof(notifier_domain_t));
 	if (d) {
@@ -249,6 +249,7 @@ notifier_domain_t *create_notifier_domain(const str_t *name)
 		d->last_package = NULL;
 		d->first_content_type = NULL;
 		d->last_content_type = NULL;
+		d->rc_grp = g;
 		if (str_dup(&d->name, name) < 0) {
 			cds_free(d);
 			ERROR_LOG("can't allocate memory\n");
@@ -256,7 +257,7 @@ notifier_domain_t *create_notifier_domain(const str_t *name)
 		}
 		cds_mutex_init(&d->mutex);
 		cds_mutex_init(&d->data_mutex);
-		init_reference_counter(&d->ref);
+		init_reference_counter(g, &d->ref);
 	}
 	return d;
 }
@@ -407,7 +408,7 @@ qsa_subscription_t *subscribe(notifier_domain_t *domain,
 	s->mutex = &domain->data_mutex;
 	s->data = data;
 	s->allow_notifications = 1;
-	init_reference_counter(&s->ref);
+	init_reference_counter(domain->rc_grp, &s->ref);
 
 	DOUBLE_LINKED_LIST_ADD(p->first_subscription, p->last_subscription, s);
 

+ 2 - 1
lib/presence/notifier_domain.h

@@ -107,12 +107,13 @@ struct _notifier_domain_t {
 	notifier_package_t *first_package, *last_package;
 	qsa_content_type_t *first_content_type, *last_content_type;
 	reference_counter_data_t ref;
+	reference_counter_group_t *rc_grp;
 };
 
 /* -------- Domain initialization/destruction functions -------- */
 
 /** Creates a new domain using cds memory functions. */
-notifier_domain_t *create_notifier_domain(const str_t *name);
+notifier_domain_t *create_notifier_domain(reference_counter_group_t *g, const str_t *name);
 
 /** Destroys domain and whole information stored in internal
  * structures. If there are any subscribers, they are unsubscribed,

+ 0 - 3
lib/presence/qsa.c

@@ -39,8 +39,6 @@ int qsa_initialize()
 {
 	int res = 0;
 
-	cds_initialize();
-	
 	/* initialization should be called from one process/thread 
 	 * it is not synchronized because it is impossible ! */
 	if (!init) {
@@ -81,7 +79,6 @@ void qsa_cleanup()
 			init = NULL;
 		}
 	}
-	cds_cleanup();
 }
 
 notifier_domain_t *qsa_register_domain(const str_t *name)