From b3c50e65da54a3f03aa9e8152c4255fc824e72ff Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Mon, 27 May 2024 12:54:43 +0200 Subject: [PATCH] sipsess/connect: set sess->established immediately on 200 receival (#1128) Otherwise, if something in invite_resp_handler fails and sipsess_terminate is called, no BYE will be sent. --- src/sipsess/connect.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sipsess/connect.c b/src/sipsess/connect.c index 6280ed005..27a12358d 100644 --- a/src/sipsess/connect.c +++ b/src/sipsess/connect.c @@ -148,15 +148,15 @@ 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) - goto out; - if (sdp) { + if (sdp && !err) { if (sess->neg_state == SDP_NEG_LOCAL_OFFER) { sess->neg_state = SDP_NEG_DONE; err = sess->answerh(msg, sess->arg); @@ -179,7 +179,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)