Ejemplo n.º 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();
}
Ejemplo n.º 2
0
END_TEST

START_TEST(test_check_normal)
{
	uint64_t res;
	uint32_t last;
	qb_util_stopwatch_t *sw = qb_util_stopwatch_create();

	qb_util_stopwatch_split_ctl(sw, 3, 0);

	qb_util_stopwatch_start(sw);
	usleep(33000);
	/* 1 */
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 30000, 36000);
	last = qb_util_stopwatch_split_last(sw);
	ck_assert_int_eq(last, 0);

	usleep(10000);
	/* 2 */
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 9000, 11000);

	usleep(20000);
	/* 3 */
	res = qb_util_stopwatch_split(sw);
	assert_int_between(res, 19000, 21000);

	/* no more space */
	res = qb_util_stopwatch_split(sw);
	ck_assert_int_eq(res, 0);

	/*
	 * split should be 30000 (10000 + 20000) usec
	 */
	last = qb_util_stopwatch_split_last(sw);
	ck_assert_int_eq(last, 2);
	res = qb_util_stopwatch_time_split_get(sw, last, 0);
	assert_int_between(res, 25000, 35000);

	/* ask for a split that has beyond the max.
	 */
	res = qb_util_stopwatch_time_split_get(sw, 3, 2);
	ck_assert_int_eq(res, 0);

	/* iterating
	 */
	last = qb_util_stopwatch_split_last(sw);
	do {
		res = qb_util_stopwatch_time_split_get(sw, last, last);
		qb_log(LOG_INFO, "normal split %d is %"PRIu64"", last, res);
		last--;
	} while (res > 0);

	qb_util_stopwatch_free(sw);
}
Ejemplo n.º 3
0
static void
test_this_one(const char *name, snprintf_like_func func)
{
	int i;
	qb_util_stopwatch_t *sw = qb_util_stopwatch_create();
	float elapsed = 452.245252343;
	float ops_per_sec = 0.345624523;

	qb_util_stopwatch_start(sw);
	for (i = 0; i < ITERATIONS; i++) {
		func("%d %s %llu %9.3f", i, "hello", 3425ULL, elapsed);
		func("[%10s] %.32x -> %p", "hello", i, func);
		func("Client %s.%.9s wants to fence (%s) '%s' with device '%3.5f'",
		     "bla", "foooooooooooooooooo",
		     name, "target", ops_per_sec);
		func("Node %s now has process list: %.32x (was %.32x)",
		     "18builder", 2, 0);
	}
	qb_util_stopwatch_stop(sw);
	elapsed = qb_util_stopwatch_sec_elapsed_get(sw);
	ops_per_sec = ((float)ITERATIONS) / elapsed;
	printf("%s] Duration: %9.3f OPs/sec: %9.3f\n", name, elapsed, ops_per_sec);
	qb_util_stopwatch_free(sw);
}
Ejemplo n.º 4
0
static void bmc_disconnect(struct bm_ctx *ctx)
{
	qb_ipcc_disconnect(ctx->conn);
	qb_util_stopwatch_free(ctx->sw);
}