[sr-dev] git:master:d1cb2644: dispatcher: new param ds_attrs_none

Daniel-Constantin Mierla miconda at gmail.com
Wed Jun 6 18:02:36 CEST 2018


Module: kamailio
Branch: master
Commit: d1cb26446742d1734eb8aac1b970e8128a1db041
URL: https://github.com/kamailio/kamailio/commit/d1cb26446742d1734eb8aac1b970e8128a1db041

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-06-06T17:56:46+02:00

dispatcher: new param ds_attrs_none

- if set to 1, "none=yes" is set in the attrs for those records that
have no attrs value, to ensure that corresponding avps for records don't
get mixed up

---

Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatcher.c

---

Diff:  https://github.com/kamailio/kamailio/commit/d1cb26446742d1734eb8aac1b970e8128a1db041.diff
Patch: https://github.com/kamailio/kamailio/commit/d1cb26446742d1734eb8aac1b970e8128a1db041.patch

---

diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index 740b678e51..fb095becea 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -89,6 +89,7 @@ extern int ds_force_dst;
 extern str ds_event_callback;
 extern int ds_ping_latency_stats;
 extern float ds_latency_estimator_alpha;
+extern int ds_attrs_none;
 
 static db_func_t ds_dbf;
 static db1_con_t *ds_db_handle = NULL;
@@ -241,27 +242,35 @@ int init_data(void)
 /**
  *
  */
-int ds_set_attrs(ds_dest_t *dest, str *attrs)
+int ds_set_attrs(ds_dest_t *dest, str *vattrs)
 {
 	param_t *params_list = NULL;
 	param_hooks_t phooks;
 	param_t *pit = NULL;
 	str param;
 	int tmp_rweight = 0;
+	str sattrs;
 
-	if(attrs == NULL || attrs->len <= 0)
-		return 0;
-	if(attrs->s[attrs->len - 1] == ';')
-		attrs->len--;
+	if(vattrs == NULL || vattrs->len <= 0) {
+		if(ds_attrs_none==0) {
+			return 0;
+		}
+		sattrs.s = "none=yes";
+		sattrs.len = 8;
+	} else {
+		sattrs = *vattrs;
+	}
+	if(sattrs.s[sattrs.len - 1] == ';')
+		sattrs.len--;
 	/* clone in shm */
-	dest->attrs.body.s = (char *)shm_malloc(attrs->len + 1);
+	dest->attrs.body.s = (char *)shm_malloc(sattrs.len + 1);
 	if(dest->attrs.body.s == NULL) {
 		LM_ERR("no more shm\n");
 		return -1;
 	}
-	memcpy(dest->attrs.body.s, attrs->s, attrs->len);
-	dest->attrs.body.s[attrs->len] = '\0';
-	dest->attrs.body.len = attrs->len;
+	memcpy(dest->attrs.body.s, sattrs.s, sattrs.len);
+	dest->attrs.body.s[sattrs.len] = '\0';
+	dest->attrs.body.len = sattrs.len;
 
 	param = dest->attrs.body;
 	if(parse_params(&param, CLASS_ANY, &phooks, &params_list) < 0)
diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c
index f6ab6b1d70..bcb085c624 100644
--- a/src/modules/dispatcher/dispatcher.c
+++ b/src/modules/dispatcher/dispatcher.c
@@ -120,6 +120,7 @@ int ds_hash_expire = 7200;
 int ds_hash_initexpire = 7200;
 int ds_hash_check_interval = 30;
 int ds_timer_mode = 0;
+int ds_attrs_none = 0;
 
 str ds_outbound_proxy = STR_NULL;
 
@@ -259,6 +260,7 @@ static param_export_t params[]={
 	{"ds_default_socket",  PARAM_STR, &ds_default_socket},
 	{"ds_timer_mode",      PARAM_INT, &ds_timer_mode},
 	{"event_callback",     PARAM_STR, &ds_event_callback},
+	{"ds_attrs_none",      PARAM_INT, &ds_attrs_none},
 	{0,0,0}
 };
 




More information about the sr-dev mailing list