Procházet zdrojové kódy

cnxcc: avoid duplicated call info

Don't store call if call-id is already registered for that client
Jose Luis Verdeguer před 5 roky
rodič
revize
fb8cc72f1b
1 změnil soubory, kde provedl 21 přidání a 0 odebrání
  1. 21 0
      src/modules/cnxcc/cnxcc_mod.c

+ 21 - 0
src/modules/cnxcc/cnxcc_mod.c

@@ -1488,6 +1488,7 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient, str *scredit,
 {
 	credit_data_t *credit_data = NULL;
 	call_t *call = NULL;
+	hash_tables_t *hts = NULL;
 
 	double credit = 0, connect_cost = 0, cost_per_second = 0;
 
@@ -1529,6 +1530,12 @@ static int ki_set_max_credit(sip_msg_t *msg, str *sclient, str *scredit,
 		return -1;
 	}
 
+	if(try_get_call_entry(&msg->callid->body, &call, &hts) == 0) {
+		LM_ERR("call-id[%.*s] already present\n",
+		msg->callid->body.len, msg->callid->body.s);
+		return -4;
+	}
+
 	LM_DBG("Setting up new call for client [%.*s], max-credit[%f], "
 		   "connect-cost[%f], cost-per-sec[%f], initial-pulse [%d], "
 		   "final-pulse [%d], call-id[%.*s]\n",
@@ -1706,6 +1713,7 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
 {
 	credit_data_t *credit_data = NULL;
 	call_t *call = NULL;
+	hash_tables_t *hts = NULL;
 
 	if(parse_headers(msg, HDR_CALLID_F, 0) != 0) {
 		LM_ERR("Error parsing Call-ID");
@@ -1736,6 +1744,12 @@ static int ki_set_max_channels(sip_msg_t *msg, str *sclient, int max_chan)
 		return -1;
 	}
 
+	if(try_get_call_entry(&msg->callid->body, &call, &hts) == 0) {
+		LM_ERR("call-id[%.*s] already present\n",
+		msg->callid->body.len, msg->callid->body.s);
+		return -4;
+	}
+
 	LM_DBG("Setting up new call for client [%.*s], max-chan[%d], "
 		   "call-id[%.*s]\n",
 			sclient->len, sclient->s, max_chan, msg->callid->body.len,
@@ -1792,6 +1806,7 @@ static int ki_set_max_time(sip_msg_t *msg, str *sclient, int max_secs)
 {
 	credit_data_t *credit_data = NULL;
 	call_t *call = NULL;
+	hash_tables_t *hts = NULL;
 
 	if(parse_headers(msg, HDR_CALLID_F, 0) != 0) {
 		LM_ERR("Error parsing Call-ID");
@@ -1823,6 +1838,12 @@ static int ki_set_max_time(sip_msg_t *msg, str *sclient, int max_secs)
 		return -1;
 	}
 
+	if(try_get_call_entry(&msg->callid->body, &call, &hts) == 0) {
+		LM_ERR("call-id[%.*s] already present\n",
+		msg->callid->body.len, msg->callid->body.s);
+		return -4;
+	}
+
 	LM_DBG("Setting up new call for client [%.*s], max-secs[%d], "
 		   "call-id[%.*s]\n",
 			sclient->len, sclient->s, max_secs, msg->callid->body.len,