Skip to content

Commit

Permalink
dialog: always check if create dialog was called on initial INVITE
Browse files Browse the repository at this point in the history
(cherry picked from commit 2a2027a)
  • Loading branch information
razvancrainea committed Apr 18, 2018
1 parent 03e852b commit 6b6d541
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
19 changes: 1 addition & 18 deletions modules/dialog/dialog.c
Expand Up @@ -1062,9 +1062,6 @@ static void mod_destroy(void)
static int w_create_dialog(struct sip_msg *req)
{
struct cell *t;
/* is the dialog already created? */
if (get_current_dialog()!=NULL)
return 1;

t = d_tmb.t_gett();
if (dlg_create_dialog( (t==T_UNDEFINED)?NULL:t, req,0)!=0)
Expand All @@ -1075,7 +1072,6 @@ static int w_create_dialog(struct sip_msg *req)

static int w_create_dialog2(struct sip_msg *req,char *param)
{
struct dlg_cell *dlg;
struct cell *t;
str res = {0,0};
int flags;
Expand All @@ -1089,20 +1085,7 @@ static int w_create_dialog2(struct sip_msg *req,char *param)
flags = parse_create_dlg_flags(res);

t = d_tmb.t_gett();
if (t == T_UNDEFINED)
t = NULL;
/* is the dialog already created? */
if ( (dlg=get_current_dialog())!=NULL )
{
/*Clear current flags before setting new ones*/
dlg->flags &= ~(DLG_FLAG_PING_CALLER | DLG_FLAG_PING_CALLEE |
DLG_FLAG_BYEONTIMEOUT | DLG_FLAG_REINVITE_PING_CALLER | DLG_FLAG_REINVITE_PING_CALLEE);
dlg->flags |= flags;
dlg_setup_reinvite_callbacks(t, req, dlg);
return 1;
}

if (dlg_create_dialog(t, req, flags)!=0)
if (dlg_create_dialog( (t==T_UNDEFINED)?NULL:t, req, flags)!=0)
return -1;

return 1;
Expand Down
14 changes: 13 additions & 1 deletion modules/dialog/dlg_handlers.c
Expand Up @@ -1145,7 +1145,7 @@ static void dlg_onreq_out(struct cell* t, int type, struct tmcb_params *ps)
/* extract the contact address */
if (!msg->contact&&(parse_headers(msg,HDR_CONTACT_F,0)<0||!msg->contact)){
LM_ERR("No outgoing contact in the initial INVITE \n");
} else {
} else {
contact.s = msg->contact->name.s;
contact.len = msg->contact->len;

Expand Down Expand Up @@ -1240,6 +1240,18 @@ int dlg_create_dialog(struct cell* t, struct sip_msg *req,unsigned int flags)
if (s.s!=0 && s.len!=0)
return -1;

dlg = get_current_dialog();
if (dlg) {
/* a dialog is already created - just update flags, if provisioned */
if (flags) {
dlg->flags &= ~(DLG_FLAG_PING_CALLER | DLG_FLAG_PING_CALLEE |
DLG_FLAG_BYEONTIMEOUT | DLG_FLAG_REINVITE_PING_CALLER | DLG_FLAG_REINVITE_PING_CALLEE);
dlg->flags |= flags;
dlg_setup_reinvite_callbacks(t, req, dlg);
}
return 0;
}

if ( parse_from_header(req)) {
LM_ERR("bad request or missing FROM hdr :-/\n");
return -1;
Expand Down

0 comments on commit 6b6d541

Please sign in to comment.