From 44be72ace6c744492f6af288f8058bcc28dd1479 Mon Sep 17 00:00:00 2001
From: Yalu Zhang <yalu.zhang@iopsys.eu>
Date: Fri, 25 Oct 2024 15:11:58 +0000
Subject: [PATCH] Set connection as -1 in chan_voicemngr_close_connection() if
 there is other call on the line

This is used to release all calls on a DECT extension. Otherwise there is still
a remaining call on DECT when two participants have left the 3-way conference
which is initiated by DECT.
---
 src/channels/chan_voicemngr.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c
index e358744..923ff89 100644
--- a/src/channels/chan_voicemngr.c
+++ b/src/channels/chan_voicemngr.c
@@ -5770,10 +5770,12 @@ static int chan_voicemngr_close_connection(struct chan_voicemngr_subchannel *sub
 	struct chan_voicemngr_pvt *p = sub->parent;
 
 	if (sub->connection_init) {
-		if (!chan_voicemngr_in_onhold(p) && !chan_voicemngr_in_call(p) && !chan_voicemngr_in_dialing(p) && !chan_voicemngr_in_ringback(p) &&
-			!chan_voicemngr_in_callwaiting(p) && !chan_voicemngr_in_transferring(p)) { // Does the line have another call?
-			ast_debug(1, "Closing real endpoint connection line_id: %d, connection_id=%d, call_id: %d\n", p->line_id, sub->connection_id, sub->call_id);
-			endpt_connection(p->line_id, sub->call_id, "destroy");
+		if (!chan_voicemngr_in_onhold(p) && !chan_voicemngr_in_call(p) && !chan_voicemngr_in_dialing(p) &&
+			!chan_voicemngr_in_ringback(p) && !chan_voicemngr_in_callwaiting(p) && !chan_voicemngr_in_transferring(p)) {
+			// There is no other call on the line
+			ast_debug(1, "Closing real endpoint connection line_id: %d, connection_id=%d\n",
+					p->line_id, sub->connection_id);
+			endpt_connection(p->line_id, -1, "destroy");
 		} else {
 			ast_debug(1, "Releasing connection for pvt line_id=%i connection_id=%d, call_id: %d\n",
 				sub->parent->line_id, sub->connection_id, sub->call_id);
-- 
GitLab