From 13dc2c8502675c079ecd892759d84b845f395002 Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Thu, 23 May 2024 07:44:28 +0200 Subject: [PATCH] sipsess/connect: set sess->established immediately on 200 receival Otherwise, if something in invite_resp_handler fails and sipsess_terminate is called, no BYE will be sent. --- src/sipsess/connect.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sipsess/connect.c b/src/sipsess/connect.c index 6280ed005..12d5d11a9 100644 --- a/src/sipsess/connect.c +++ b/src/sipsess/connect.c @@ -148,13 +148,18 @@ static void invite_resp_handler(int err, const struct sip_msg *msg, void *arg) } else if (msg->scode < 300) { + sess->established = true; + sess->hdrs = mem_deref(sess->hdrs); err = sip_dialog_established(sess->dlg) ? sip_dialog_update(sess->dlg, msg) : sip_dialog_create(sess->dlg, msg); - if (err) + if (err) { + (void)sipsess_ack(sess->sock, sess->dlg, msg->cseq.num, + sess->auth, sess->ctype, desc); goto out; + } if (sdp) { if (sess->neg_state == SDP_NEG_LOCAL_OFFER) { @@ -179,7 +184,6 @@ static void invite_resp_handler(int err, const struct sip_msg *msg, void *arg) && mbuf_get_left(desc)) sess->neg_state = SDP_NEG_DONE; - sess->established = true; mem_deref(desc); if (err || sess->terminated)