From 2a65c9408c6e590d10d974b758a7c42ee824b923 Mon Sep 17 00:00:00 2001
From: "Michael L. Young" <elgueromexicano@gmail.com>
Date: Fri, 22 Mar 2013 20:43:24 +0000
Subject: [PATCH] Fix StopMixMonitor Hanging Up When Unable To Stop MixMonitor
 On A Channel

A regression was accidentally introduced when allowing an optional ID to be used
when calling StopMixMonitor.  When we are unable to stop MixMonitor on a
channel, -1 is being returned which triggers the hangup of the channel.

This patch restores the prior behavior by returning 0 whether we were successful
or not.  It also allows the call from the manager to use the return code when
the action fails.

(closes issue ASTERISK-21294)
Reported by: daroz
Tested by: daroz
Patches:
  asterisk-21294-stop_mixmonitor_hangingup.diff Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/2404/
........

Merged revisions 383631 from http://svn.asterisk.org/svn/asterisk/branches/11


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@383632 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_mixmonitor.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index fa13dcbbd9..6e7976ec9f 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -1042,7 +1042,7 @@ static int mixmonitor_exec(struct ast_channel *chan, const char *data)
 	return 0;
 }
 
-static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
+static int stop_mixmonitor_full(struct ast_channel *chan, const char *data)
 {
 	struct ast_datastore *datastore = NULL;
 	char *parse = "";
@@ -1096,6 +1096,12 @@ static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
 	return 0;
 }
 
+static int stop_mixmonitor_exec(struct ast_channel *chan, const char *data)
+{
+	stop_mixmonitor_full(chan, data);
+	return 0;
+}
+
 static char *handle_cli_mixmonitor(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_channel *chan;
@@ -1315,7 +1321,7 @@ static int manager_stop_mixmonitor(struct mansession *s, const struct message *m
 		return AMI_SUCCESS;
 	}
 
-	res = stop_mixmonitor_exec(c, mixmonitor_id);
+	res = stop_mixmonitor_full(c, mixmonitor_id);
 
 	if (res) {
 		astman_send_error(s, m, "Could not stop monitoring channel");
-- 
GitLab