diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c index d9ff5d6d64..705fdc7681 100644 --- a/modules/dialog/dialog.c +++ b/modules/dialog/dialog.c @@ -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) @@ -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; @@ -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; diff --git a/modules/dialog/dlg_handlers.c b/modules/dialog/dlg_handlers.c index d2d1e756b9..94c492176a 100644 --- a/modules/dialog/dlg_handlers.c +++ b/modules/dialog/dlg_handlers.c @@ -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; @@ -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;