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)