예제 #1
0
void pe_resource_unref(struct pe_operation *op)
{
	qb_enter();

	op->refcount--;

	qb_log(LOG_TRACE, "unref %s_%s_%d refcount:%d",
	       op->rname, op->method, op->interval,
	       op->refcount);
	if (op->refcount == 0) {
		crm_free(op->hostname);
		crm_free(op->rprovider);
		crm_free(op->rtype);
		crm_free(op->rclass);
		crm_free(op->node_uuid);
		crm_free(op->op_digest);
		free(op->method);
		free(op->rname);
                qb_map_foreach(op->params, qb_map_transverse_rm, op->params);
		qb_map_destroy(op->params);

		qb_util_stopwatch_free(op->time_execed);
		free(op);
	}

	qb_leave();
}
예제 #2
0
파일: mapnotify.c 프로젝트: AnchorCat/libqb
int
main(void)
{
	qb_map_t *trie;
	int *i1, *i2, *i3;
	qb_map_iter_t *iter;
	const char *key;
	void *val;
	uint32_t revents = (QB_MAP_NOTIFY_DELETED |
			    QB_MAP_NOTIFY_REPLACED |
			    QB_MAP_NOTIFY_INSERTED |
			    QB_MAP_NOTIFY_RECURSIVE);

	trie = qb_trie_create();
	assert(trie != NULL);
	qb_trie_dump(trie);
	add_cs_keys(trie);

	i1 = malloc(sizeof(int));
	assert(i1 != NULL);
	*i1 = 1;

	i2 = malloc(sizeof(int));
	assert(i2 != NULL);
	*i2 = 2;

	i3 = malloc(sizeof(int));
	assert(i3 != NULL);
	*i3 = 3;

	qb_map_notify_add(trie, NULL, notify_fn, QB_MAP_NOTIFY_FREE, NULL);

	qb_map_put(trie, "test.key1", i1);
	qb_map_put(trie, "test.key2", i2);

	qb_map_notify_add(trie, "test.", notify_fn, revents, NULL);
	qb_trie_dump(trie);

	qb_map_put(trie, "test.key1", i3);

	iter = qb_map_pref_iter_create(trie, "test.");
	while ((key = qb_map_iter_next(iter, &val)) != NULL) {
		fprintf(stderr, "Iter %s [%d]\n", key, *(int *)val);
		qb_map_rm(trie, key);
	}
	qb_map_iter_free(iter);
	qb_map_notify_del_2(trie, "test.", notify_fn, revents, NULL);
	qb_map_destroy(trie);

	return (0);
}
예제 #3
0
void icmap_fini(void)
{
	icmap_del_all_track();
	/*
	 * catch 22 warning:
	 * We need to drop this notify but we can't because it calls icmap_map_free_cb
	 * while destroying the tree to free icmap_item(s).
	 * -> qb_map_notify_del_2(icmap_map, NULL, icmap_map_free_cb, QB_MAP_NOTIFY_FREE, NULL);
	 * and we cannot call it after map_destroy. joy! :)
	 */
	qb_map_destroy(icmap_map);
	icmap_set_ro_access_free();
	return;
}