From 2763f18cd3e5ef0f49e11e144d01d8cd7d2d0547 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 17 Jan 2024 10:39:06 +0100 Subject: [PATCH] MT#59022 Handle faked legs during B2BTerminateLeg properly If the leg during the `B2BEvent::B2BTerminateLeg` event handling turns out to be in the 183/200 faked state, then handle the leg termination with CANCEL, instead of BYE. This is because this leg has never seen the real 200OK response, and hence remains indeed in the early stage. Change-Id: I4a9d4197a6ea42f1cfbbcdc5fb306c48684e64bf --- core/AmSipDialog.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp index 23fa4dcd..96bbcc37 100644 --- a/core/AmSipDialog.cpp +++ b/core/AmSipDialog.cpp @@ -688,6 +688,26 @@ int AmSipDialog::bye(const string& hdrs, int flags) send_200_ack(*it); } + /* handle case with force early announce (leg is in pseudo-connected state), + * but indeed on the SIP level, leg has never seen 2XX response */ + if (getFaked183As200()) { + setFaked183As200(false); /* reset faked state */ + + for (TransMap::reverse_iterator t = uac_trans.rbegin(); + t != uac_trans.rend(); + t++) + { + if (t->second.method == SIP_METH_INVITE || t->second.method == SIP_METH_BYE) { + setStatus(Cancelling); + return SipCtrlInterface::cancel(&t->second.tt, local_tag, + t->first, t->second.hdrs + hdrs); + } + } + /* if faked state doesn't find required transaction, + * it's going to a usual way of handling with BYE */ + } + + /* usual handling */ if (status != Disconnecting) { setStatus(Disconnected); return sendRequest(SIP_METH_BYE, NULL, hdrs, flags);