From 6376b4b7057f69bc2845f2e9d731747fa2669848 Mon Sep 17 00:00:00 2001
From: Michael Jerris <mike@jerris.com>
Date: Wed, 11 Feb 2009 17:38:16 +0000
Subject: [PATCH] Tue Feb 10 07:03:27 CST 2009  Pekka Pessi
 <first.last@nokia.com>   * nua_session.c: fixed race condition with ACK  
 Ignore-this: 37d3e74b169e8a154b9734dbade74d84

  Response message got destroyed after sending ACK if stack was run in
  multithreaded mode.



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11872 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 libs/sofia-sip/.update                           | 2 +-
 libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update
index 61f9d44345..36a8190d61 100644
--- a/libs/sofia-sip/.update
+++ b/libs/sofia-sip/.update
@@ -1 +1 @@
-Wed Feb 11 11:37:16 CST 2009
+Wed Feb 11 11:38:10 CST 2009
diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
index f97116b834..6257dbaa59 100644
--- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
+++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_session.c
@@ -1021,13 +1021,14 @@ static int nua_invite_client_report(nua_client_request_t *cr,
   nua_dialog_state_t *ds = nh->nh_ds;
   nua_dialog_usage_t *du = cr->cr_usage;
   nua_session_usage_t *ss = nua_dialog_usage_private(du);
+  msg_t *response = nta_outgoing_getresponse(orq);
   unsigned next_state;
   int error;
 
   nh_referral_respond(nh, status, phrase); /* XXX - restarting after 401/407 */
 
   nua_stack_event(nh->nh_nua, nh,
-		  nta_outgoing_getresponse(orq),
+		  response,
 		  cr->cr_event,
 		  status, phrase,
 		  tags);
@@ -1049,6 +1050,8 @@ static int nua_invite_client_report(nua_client_request_t *cr,
     return 1;
   }
 
+  response = msg_ref_create(response); /* Keep reference to contents of sip */
+
   if (orq != cr->cr_orq && cr->cr_orq) {	/* Being restarted */
     next_state = nua_callstate_calling;
   }
@@ -1144,6 +1147,8 @@ static int nua_invite_client_report(nua_client_request_t *cr,
 
   signal_call_state_change(nh, ss, status, phrase, next_state);
 
+  msg_destroy(response);
+
   return 1;
 }