From 984b27c68d6f919740ea431e11c35c1fa76a9c21 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Fri, 31 Aug 2012 14:49:21 -0500
Subject: [PATCH] add sip_wait_for_aleg_ack var

---
 src/mod/endpoints/mod_sofia/sofia.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c
index 41ae399691..eb49ecb304 100644
--- a/src/mod/endpoints/mod_sofia/sofia.c
+++ b/src/mod/endpoints/mod_sofia/sofia.c
@@ -6327,6 +6327,17 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
 		{
 			const char *invite_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_from");
 			const char *invite_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_to");
+			const char *wait_for_ack = switch_channel_get_variable(channel, "sip_wait_for_aleg_ack");
+
+			if (switch_true(wait_for_ack)) {
+				switch_core_session_t *other_session;
+
+				if (switch_core_session_get_partner(session, &other_session) == SWITCH_STATUS_SUCCESS) {
+					switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+					switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+					switch_core_session_rwunlock(other_session);
+				}
+			}
 
 			if (r_sdp && sofia_test_flag(tech_pvt, TFLAG_3PCC_INVITE) && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
 				sofia_set_flag(tech_pvt, TFLAG_SDP);