From e9d96775ad5a5b7fbe0bfbbf3c613fa49d6044f7 Mon Sep 17 00:00:00 2001
From: Tilghman Lesher <tilghman@meg.abyt.es>
Date: Tue, 28 Oct 2008 21:38:26 +0000
Subject: [PATCH] Only re-add the io port if it was closed, otherwise reload
 causes a memory leak. (closes issue #13785)  Reported by: eliel  Patches:    
    chan_mgcp.c.patch uploaded by eliel (license 64)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@152442 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 channels/chan_mgcp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 644e7b787f..083c0e3e25 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -3431,8 +3431,9 @@ static void *do_monitor(void *data)
 			ast_verb(1, "Reloading MGCP\n");
 			reload_config(1);
 			/* Add an I/O event to our UDP socket */
-			if (mgcpsock > -1) 
+			if (mgcpsock > -1 && !mgcpsock_read_id) {
 				mgcpsock_read_id = ast_io_add(io, mgcpsock, mgcpsock_read, AST_IO_IN, NULL);
+			}
 		}
 
 		/* Check for interfaces needing to be killed */
-- 
GitLab