Skip to content

Commit

Permalink
dispatcher: new param ds_attrs_none
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
miconda committed Jun 6, 2018
1 parent f3f14c6 commit d1cb264
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/modules/dispatcher/dispatch.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/modules/dispatcher/dispatcher.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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}
};

Expand Down

0 comments on commit d1cb264

Please sign in to comment.