From e1125f336c0f71adb0a329ee1608ce8e46692f2b Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthony.minessale@gmail.com>
Date: Thu, 12 Oct 2006 02:26:20 +0000
Subject: [PATCH] udpate

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3037 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 src/mod/endpoints/mod_sofia/mod_sofia.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c
index 7ed814e6dd..dd0da2a7b3 100644
--- a/src/mod/endpoints/mod_sofia/mod_sofia.c
+++ b/src/mod/endpoints/mod_sofia/mod_sofia.c
@@ -2281,13 +2281,15 @@ static void sip_i_state(int status,
 		break;
 	case nua_callstate_terminated: 
 		if (session) {
-			switch_set_flag_locked(tech_pvt, TFLAG_BYE);
-			if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
-				switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
-				nua_handle_destroy(tech_pvt->nh);
-				tech_pvt->nh = NULL;
-			} else {
-				terminate_session(&session, sip_cause_to_freeswitch(status), __LINE__);
+			if (!switch_test_flag(tech_pvt, TFLAG_BYE)) {
+				switch_set_flag_locked(tech_pvt, TFLAG_BYE);
+				if (switch_test_flag(tech_pvt, TFLAG_NOHUP)) {
+					switch_clear_flag_locked(tech_pvt, TFLAG_NOHUP);
+					nua_handle_destroy(tech_pvt->nh);
+					tech_pvt->nh = NULL;
+				} else {
+					terminate_session(&session, sip_cause_to_freeswitch(status), __LINE__);
+				}
 			}
 		}
 		break;