Example #1
0
int rl_stats(struct mi_node *rpl, str * value)
{
	rl_pipe_t **pipe;
	int i;

	if (value && value->s && value->len) {
		i = RL_GET_INDEX(*value);
		RL_GET_LOCK(i);
		pipe = RL_FIND_PIPE(i, *value);
		if (!pipe || !*pipe) {
			LM_DBG("pipe %.*s not found\n", value->len, value->s);
			goto error;
		}
		if (rl_map_print(rpl, *value, *pipe)) {
			LM_ERR("cannot print value for key %.*s\n",
					value->len, value->s);
			goto error;
		}
		RL_RELEASE_LOCK(i);
	} else {
		/* iterate through each map */
		for (i = 0; i < rl_htable.size; i++) {
			RL_GET_LOCK(i);
			if (map_for_each(rl_htable.maps[i], rl_map_print, rpl)) {
				LM_ERR("cannot print values\n");
				goto error;
			}
			RL_RELEASE_LOCK(i);
		}
	}
	return 0;
error:
	RL_RELEASE_LOCK(i);
	return -1;
}
Example #2
0
int rl_stats(mi_item_t *resp_obj, str * value)
{
	mi_item_t *pipe_item, *pipe_arr;
	rl_pipe_t **pipe;
	int i;

	if (value && value->s && value->len) {
		i = RL_GET_INDEX(*value);
		RL_GET_LOCK(i);
		pipe = RL_FIND_PIPE(i, *value);
		if (!pipe || !*pipe) {
			LM_DBG("pipe %.*s not found\n", value->len, value->s);
			goto error;
		}
		pipe_item = add_mi_object(resp_obj, MI_SSTR("Pipe"));
		if (!pipe_item)
			goto error;
		if (rl_map_print(pipe_item, *value, *pipe)) {
			LM_ERR("cannot print value for key %.*s\n",
				value->len, value->s);
			goto error;
		}
		RL_RELEASE_LOCK(i);
	} else {
		/* iterate through each map */
		pipe_arr = add_mi_array(resp_obj, MI_SSTR("Pipes"));
		if (!pipe_arr)
			return -1;
		for (i = 0; i < rl_htable.size; i++) {
			pipe_item = add_mi_object(pipe_arr, NULL, 0);
			if (!pipe_item)
				return -1;
			RL_GET_LOCK(i);
			if (map_for_each(rl_htable.maps[i], rl_map_print, pipe_item)) {
				LM_ERR("cannot print values\n");
				goto error;
			}
			RL_RELEASE_LOCK(i);
		}
	}
	return 0;
error:
	RL_RELEASE_LOCK(i);
	return -1;
}
Example #3
0
int rl_stats(struct mi_root *rpl_tree, str * value)
{
	rl_pipe_t **pipe;
	struct rl_param_t param;
	int i;

	memset(&param, 0, sizeof(struct rl_param_t));
	param.node = &rpl_tree->node;
	param.root = rpl_tree;

	if (value && value->s && value->len) {
		i = RL_GET_INDEX(*value);
		RL_GET_LOCK(i);
		pipe = RL_FIND_PIPE(i, *value);
		if (!pipe || !*pipe) {
			LM_DBG("pipe %.*s not found\n", value->len, value->s);
			goto error;
		}
		if (rl_map_print(&param, *value, *pipe)) {
			LM_ERR("cannot print value for key %.*s\n",
					value->len, value->s);
			goto error;
		}
		RL_RELEASE_LOCK(i);
	} else {
		/* iterate through each map */
		for (i = 0; i < rl_htable.size; i++) {
			RL_GET_LOCK(i);
			if (map_for_each(rl_htable.maps[i], rl_map_print, &param)) {
				LM_ERR("cannot print values\n");
				goto error;
			}
			RL_RELEASE_LOCK(i);
		}
	}
	return 0;
error:
	RL_RELEASE_LOCK(i);
	return -1;
}