当前位置: 首页>>代码示例>>C++>>正文


C++ cachedb_funcs::add方法代码示例

本文整理汇总了C++中cachedb_funcs::add方法的典型用法代码示例。如果您正苦于以下问题:C++ cachedb_funcs::add方法的具体用法?C++ cachedb_funcs::add怎么用?C++ cachedb_funcs::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cachedb_funcs的用法示例。


在下文中一共展示了cachedb_funcs::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: rl_change_counter

/* NOTE: assumes that the pipe has been locked. If fails, releases the lock */
static int rl_change_counter(str *name, rl_pipe_t *pipe, int c)
{
	int new_counter;

	if (rl_set_name(name) < 0)
		return -1;

	if (pipe->my_counter + c <= 0) {
		LM_DBG("Counter going negative\n");
		return 1;
	}

	if (cdbf.add(cdbc, &rl_name_buffer, c ? c : -(pipe->my_counter),
				rl_expire_time, &new_counter) < 0){
		LM_ERR("cannot change counter for pipe %.*s with %d\n",
				name->len, name->s, c);
		return -1;
	}

	pipe->my_counter = c ? pipe->my_counter + c : 0;
	pipe->counter = new_counter;
	LM_DBG("changed with %d; my_counter: %d; counter: %d\n",
			c, pipe->my_counter, new_counter);

	return 0;
}
开发者ID:MayamaTakeshi,项目名称:opensips,代码行数:27,代码来源:ratelimit_helper.c

示例2: rl_change_counter

/* NOTE: assumes that the pipe has been locked. If fails, releases the lock */
static int rl_change_counter(str *name, rl_pipe_t *pipe, int c)
{
	unsigned int hid = RL_GET_INDEX(*name);
	int new_counter;

	RL_SET_PENDING(pipe);
	RL_RELEASE_LOCK(hid);
	if (rl_set_name(name) < 0)
		return -1;

	/* if the command should be reset */
	/* XXX: This is not needed since add takes also negative numbers 
	if (c > 0) {
		if (cdbf.add(cdbc, &rl_name_buffer, c, rl_expire_time, &new_counter)<0){
			LM_ERR("cannot increase buffer for pipe %.*s\n",
					name->len, name->s);
			return -1;
		}
	} else {
		if (cdbf.sub(cdbc, &rl_name_buffer, c ? c : pipe->my_counter,
					rl_expire_time, &new_counter) < 0){
			LM_ERR("cannot change counter for pipe %.*s with %d\n",
					name->len, name->s, c);
			return -1;
		}
	}
	*/
	if (cdbf.add(cdbc, &rl_name_buffer, c ? c : -(pipe->my_counter),
				rl_expire_time, &new_counter) < 0){
		LM_ERR("cannot change counter for pipe %.*s with %d\n",
				name->len, name->s, c);
		return -1;
	}

	RL_GET_LOCK(hid);
	RL_RESET_PENDING(pipe);
	pipe->my_counter = c ? pipe->my_counter + c : 0;
	pipe->counter = new_counter;
	LM_DBG("changed with %d; my_counter: %d; counter: %d\n",
			c, pipe->my_counter, new_counter);

	return 0;
}
开发者ID:UIKit0,项目名称:OpenSIPS,代码行数:44,代码来源:ratelimit_helper.c


注:本文中的cachedb_funcs::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。