Exemplo n.º 1
0
static int rediswho_accounting_all(REDISSOCK **dissocket_p,
				   rlm_rediswho_t *inst, REQUEST *request,
				   const char *insert,
				   const char *trim,
				   const char *expire)
{
	REDISSOCK *dissocket;

	if (!insert || !trim || !expire) return 0;

	if (rediswho_command(insert, dissocket_p, inst, request) < 0) {
		return -1;
	}

	/* Only trim if necessary */
	dissocket = *dissocket_p;
	if (dissocket->reply->type == REDIS_REPLY_INTEGER) {
		if (dissocket->reply->integer > inst->trim_count) {
			if (rediswho_command(trim, dissocket_p,
					     inst, request) < 0) {
				return -1;
			}
		}
	}

	rediswho_command(expire, dissocket_p, inst, request);

	return RLM_MODULE_OK;
}
Exemplo n.º 2
0
static int mod_accounting_all(REDISSOCK **dissocket_p,
				   rlm_rediswho_t *inst, REQUEST *request,
				   char const *insert,
				   char const *trim,
				   char const *expire)
{
	int result;

	result = rediswho_command(insert, dissocket_p, inst, request);
	if (result < 0) {
		return RLM_MODULE_FAIL;
	}

	/* Only trim if necessary */
	if (inst->trim_count >= 0 && result > inst->trim_count) {
		if (rediswho_command(trim, dissocket_p,
				     inst, request) < 0) {
			return RLM_MODULE_FAIL;
		}
	}

	if (rediswho_command(expire, dissocket_p, inst, request) < 0) {
		return RLM_MODULE_FAIL;
	}

	return RLM_MODULE_OK;
}
Exemplo n.º 3
0
static int rediswho_accounting_alive(REDISSOCK *dissocket,
				     rlm_rediswho_t *data, REQUEST *request)
{
	rediswho_command(data->alive_insert, dissocket, data, request);

	/* Only trim if necessary */
	if (dissocket->reply->type == REDIS_REPLY_INTEGER) {
		if (dissocket->reply->integer > data->trim_count) {
			rediswho_command(data->alive_trim, dissocket, data, request);
		}
	}

	rediswho_command(data->alive_expire, dissocket, data, request);

	return RLM_MODULE_OK;
}