diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c index 22441b5fa99..75b6d020784 100644 --- a/src/modules/topos/tps_msg.c +++ b/src/modules/topos/tps_msg.c @@ -773,12 +773,25 @@ int tps_request_received(sip_msg_t *msg, int dialog) } use_branch = 1; } else { - if(tps_storage_load_dialog(msg, &mtsd, &stsd)<0) { + if(tps_storage_load_dialog(msg, &mtsd, &stsd) < 0) { goto error; } - /* detect direction - via from-tag */ - if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) { - goto error; + if(((get_cseq(msg)->method_id) & (METHOD_BYE)) + && stsd.b_contact.len <= 0) { + /* BYE but not B-side contact, look for INVITE transaction record */ + memset(&stsd, 0, sizeof(tps_data_t)); + if(tps_storage_link_msg(msg, &mtsd, TPS_DIR_DOWNSTREAM) < 0) { + goto error; + } + if(tps_storage_load_branch(msg, &mtsd, &stsd, 1) < 0) { + goto error; + } + use_branch = 1; + } else { + /* detect direction - via from-tag */ + if(tps_dlg_detect_direction(msg, &stsd, &direction) < 0) { + goto error; + } } }