Skip to content

Commit

Permalink
[b2b_logic] Do not try to re-evaluate the script params.
Browse files Browse the repository at this point in the history
The script parameters (provided from script level) are already evaluated (from the variable perspective), so there is no need to do it again.

Closes #1819

(cherry picked from commit f9bc3ce)
  • Loading branch information
bogdan-iancu committed Sep 19, 2019
1 parent 68a764c commit 7bb74db
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 50 deletions.
3 changes: 0 additions & 3 deletions modules/b2b_logic/b2b_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static str default_headers[HDR_DEFAULT_LEN]=
{"RSeq", 4},
};
int use_init_sdp = 0;
enum b2bl_caller_type b2bl_caller;
unsigned int max_duration = 12*3600;

int b2bl_key_avp_name;
Expand Down Expand Up @@ -1138,8 +1137,6 @@ mi_response_t *mi_trigger_scenario(const mi_params_t *params,
if (get_mi_array_param(params, "scenario_params", &params_arr, &no_args) < 0)
return init_mi_param_error();

b2bl_caller = CALLER_MI;

memset(args, 0, MAX_SCENARIO_PARAMS * sizeof(str));
memset(argsp, 0, MAX_SCENARIO_PARAMS * sizeof(str*));

Expand Down
7 changes: 0 additions & 7 deletions modules/b2b_logic/b2b_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@

extern b2b_api_t b2b_api;

enum b2bl_caller_type {
CALLER_MODULE,
CALLER_SCRIPT,
CALLER_MI
};
extern enum b2bl_caller_type b2bl_caller;

typedef struct b2b_rule
{
unsigned int id;
Expand Down
2 changes: 0 additions & 2 deletions modules/b2b_logic/logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -3604,7 +3604,6 @@ str* internal_init_scenario(struct sip_msg* msg, str* name,
return NULL;
}
}
b2bl_caller = CALLER_MODULE;
return init_request(msg, scf, args, cbf, cb_param, cb_mask, custom_hdrs);
}

Expand All @@ -3622,7 +3621,6 @@ int b2b_init_request(struct sip_msg* msg, struct b2b_scen_fl *scf,
destroy_avps( b2bl_key_avp_type, b2bl_key_avp_name, 1);

/* find the scenario with the corresponding id */
b2bl_caller = CALLER_SCRIPT;

/* process the arguments */
args[0] = arg2;
Expand Down
45 changes: 7 additions & 38 deletions modules/b2b_logic/records.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ b2bl_tuple_t* b2bl_insert_new(struct sip_msg* msg,
b2bl_tuple_t* tuple = NULL;
str* b2bl_key;
int i;
static char buf[256];
int buf_len= 255;
int size;
str extra_headers={0, 0};
str local_contact= server_address;
Expand Down Expand Up @@ -195,50 +193,21 @@ b2bl_tuple_t* b2bl_insert_new(struct sip_msg* msg,
{
for(i = 0; i< scenario->param_no; i++)
{
if(args[i]==NULL)
if (args[i]==NULL || args[i]->s==NULL || args[i]->len==0)
{
LM_DBG("Fewer parameters, expected [%d] received [%d]\n",
scenario->param_no, i);
break;
}
/* must print the value of the argument */
if(msg && b2bl_caller != CALLER_MODULE)
{
buf_len= 255;
if(pv_printf(msg, (pv_elem_t*)args[i], buf, &buf_len)<0)
{
LM_ERR("cannot print the format\n");
goto error;
}

tuple->scenario_params[i].s = (char*)shm_malloc(buf_len);
if(tuple->scenario_params[i].s == NULL)
{
LM_ERR("No more shared memory\n");
goto error;
}
memcpy(tuple->scenario_params[i].s, buf, buf_len);
tuple->scenario_params[i].len = buf_len;
LM_DBG("Printed parameter [%.*s]\n", buf_len, buf);
}
else
tuple->scenario_params[i].s = (char*)shm_malloc(args[i]->len);
if(tuple->scenario_params[i].s == NULL)
{
if(args[i]->s==NULL || args[i]->len==0)
{
LM_DBG("Fewer parameters, expected [%d] received [%d]\n",
scenario->param_no, i);
break;
}

tuple->scenario_params[i].s = (char*)shm_malloc(args[i]->len);
if(tuple->scenario_params[i].s == NULL)
{
LM_ERR("No more shared memory\n");
goto error;
}
memcpy(tuple->scenario_params[i].s, args[i]->s, args[i]->len);
tuple->scenario_params[i].len = args[i]->len;
LM_ERR("No more shared memory\n");
goto error;
}
memcpy(tuple->scenario_params[i].s, args[i]->s, args[i]->len);
tuple->scenario_params[i].len = args[i]->len;
}
}
tuple->scenario_state = B2B_NOTDEF_STATE;
Expand Down

0 comments on commit 7bb74db

Please sign in to comment.