Skip to content

Commit

Permalink
Fixed bug introduced by previous commit :
Browse files Browse the repository at this point in the history
	- downstream BYEs should go to 200OK leg in order to trigger dialog termination
	- upstream BYEs have no such limitation ( there's only one caller leg :) )
(cherry picked from commit e1ae01b)
  • Loading branch information
vladpaiu committed Sep 2, 2013
1 parent 3f8b4c9 commit 4c0b862
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions modules/dialog/dlg_handlers.c
Expand Up @@ -468,7 +468,8 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param)
else
event = DLG_EVENT_RPL3xx;

next_state_dlg( dlg, event, &old_state, &new_state, &unref);
last_dst_leg = DLG_CALLER_LEG;
next_state_dlg(dlg, event, DLG_DIR_UPSTREAM, &old_state, &new_state, &unref);

if (new_state==DLG_STATE_EARLY && old_state!=DLG_STATE_EARLY) {
run_dlg_callbacks(DLGCB_EARLY, dlg, rpl, DLG_DIR_UPSTREAM, 0);
Expand Down Expand Up @@ -1114,8 +1115,7 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
/* save last_dst_leg before running state machine
* helpful for logging various bogus cases according to the RFC */
last_dst_leg = dst_leg;

next_state_dlg( dlg, event, &old_state, &new_state, &unref);
next_state_dlg( dlg, event, dir, &old_state, &new_state, &unref);

/* set current dialog - it will keep a ref! */
set_current_dialog(dlg);
Expand Down Expand Up @@ -1403,7 +1403,9 @@ void dlg_ontimeout( struct dlg_tl *tl)
return ;
}

next_state_dlg( dlg, DLG_EVENT_REQBYE, &old_state, &new_state, &unref);
/* act like as if we've received a BYE from caller */
last_dst_leg = dlg->legs_no[DLG_LEG_200OK];
next_state_dlg( dlg, DLG_EVENT_REQBYE, DLG_DIR_DOWNSTREAM, &old_state, &new_state, &unref);

if (new_state==DLG_STATE_DELETED && old_state!=DLG_STATE_DELETED) {
LM_DBG("timeout for dlg with CallID '%.*s' and tags '%.*s' '%.*s'\n",
Expand Down
4 changes: 2 additions & 2 deletions modules/dialog/dlg_hash.c
Expand Up @@ -759,7 +759,7 @@ static inline void log_next_state_dlg(const int event,


void next_state_dlg(struct dlg_cell *dlg, int event,
int *old_state, int *new_state, int *unref)
int dir, int *old_state, int *new_state, int *unref)
{
struct dlg_entry *d_entry;

Expand Down Expand Up @@ -851,7 +851,7 @@ void next_state_dlg(struct dlg_cell *dlg, int event,
switch (dlg->state) {
case DLG_STATE_CONFIRMED_NA:
case DLG_STATE_CONFIRMED:
if ( last_dst_leg!=dlg->legs_no[DLG_LEG_200OK] )
if (dir == DLG_DIR_DOWNSTREAM && last_dst_leg!=dlg->legs_no[DLG_LEG_200OK] )
/* to end the call, the BYE must be received
* on the same leg as the 200 OK for INVITE */
break;
Expand Down
2 changes: 1 addition & 1 deletion modules/dialog/dlg_hash.h
Expand Up @@ -272,7 +272,7 @@ void unref_dlg(struct dlg_cell *dlg, unsigned int cnt);
void ref_dlg(struct dlg_cell *dlg, unsigned int cnt);

void next_state_dlg(struct dlg_cell *dlg, int event,
int *old_state, int *new_state, int *unref);
int dir, int *old_state, int *new_state, int *unref);

struct mi_root * mi_print_dlgs(struct mi_root *cmd, void *param );
struct mi_root * mi_print_dlgs_ctx(struct mi_root *cmd, void *param );
Expand Down
3 changes: 2 additions & 1 deletion modules/dialog/dlg_req_within.c
Expand Up @@ -212,7 +212,8 @@ static void dual_bye_event(struct dlg_cell* dlg, struct sip_msg *req, int extra_
int event, old_state, new_state, unref, ret;

event = DLG_EVENT_REQBYE;
next_state_dlg(dlg, event, &old_state, &new_state, &unref);
last_dst_leg = dlg->legs_no[DLG_LEG_200OK];
next_state_dlg(dlg, event, DLG_DIR_DOWNSTREAM, &old_state, &new_state, &unref);
unref += extra_unref;

if(new_state == DLG_STATE_DELETED && old_state != DLG_STATE_DELETED){
Expand Down

0 comments on commit 4c0b862

Please sign in to comment.