From 228f9772d76fa6920e13c1de0ea4ca41befcb3c0 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Wed, 6 Mar 2013 18:01:21 -0600
Subject: [PATCH] dont destroy handle when subs are inside a call's dialog

---
 src/mod/endpoints/mod_sofia/sofia_presence.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/mod/endpoints/mod_sofia/sofia_presence.c b/src/mod/endpoints/mod_sofia/sofia_presence.c
index 3547130446..f49b138566 100644
--- a/src/mod/endpoints/mod_sofia/sofia_presence.c
+++ b/src/mod/endpoints/mod_sofia/sofia_presence.c
@@ -4072,7 +4072,9 @@ void sofia_presence_handle_sip_i_subscribe(int status,
 		nua_respond(nh, 481, "INVALID SUBSCRIPTION", TAG_END());
 	}
 
-	nua_handle_destroy(nh);
+	if (!sofia_private || !sofia_private->is_call) {
+		nua_handle_destroy(nh);
+	}
 	
 }