static void __subscription_cb(redisAsyncContext *c, void *r, void *privdata) { redisReply *reply = r; str key; credit_data_t *credit_data; if(reply == NULL) { LM_ERR("reply is NULL\n"); return; } if(reply->type != REDIS_REPLY_ARRAY || reply->elements != 3) return; if(strcmp(reply->element[1]->str, "cnxcc:kill_list") != 0) return; if(!reply->element[2]->str) return; key.len = strlen(reply->element[2]->str); if(key.len <= 0) { LM_ERR("Invalid credit_data key\n"); return; } key.s = reply->element[2]->str; if(try_get_credit_data_entry(&key, &credit_data) < 0) return; cnxcc_lock(credit_data->lock); if(credit_data->deallocating) goto done; // no need to terminate the calls. They are already being terminated LM_ALERT("Got kill list entry for key [%.*s]\n", key.len, key.s); terminate_all_calls(credit_data); done: cnxcc_unlock(credit_data->lock); }
int sel_channels_count(str* res, select_t* s, struct sip_msg* msg) { LM_DBG("sel_channels_count for [%.*s]\n", s->params[2].v.s.len, s->params[2].v.s.s); credit_data_t *credit_data = NULL; int value = 0; if (s->params[2].v.s.len <= 0) { LM_ERR("Client must be specified\n"); return -1; } if (try_get_credit_data_entry(&s->params[2].v.s, &credit_data) >= 0) value = credit_data->number_of_calls; else LM_DBG("Client [%.*s] not found\n", s->params[2].v.s.len, s->params[2].v.s.s); res->s = int2str(value, &res->len); return 0; }