From 2bed4ec968fabd1158351dcabd957b1dec3c7fc0 Mon Sep 17 00:00:00 2001
From: Tilghman Lesher <tilghman@meg.abyt.es>
Date: Wed, 26 Dec 2007 20:49:35 +0000
Subject: [PATCH] Merged revisions 94808 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r94808 | tilghman | 2007-12-26 14:43:38 -0600 (Wed, 26 Dec 2007) | 6 lines

Workaround for what is probably a glibc bug (but we'll see this crop up again
and again, if we don't add the workaround).
Reported by: rolek
Patch by: tilghman
(Closes issue #11601, closes issue #11426)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@94809 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 main/manager.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/main/manager.c b/main/manager.c
index e229a78920..56584fae99 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -2589,6 +2589,14 @@ static void *session_do(void *data)
 			ast_verb(2, "Connect attempt from '%s' unable to authenticate\n", ast_inet_ntoa(s->sin.sin_addr));
 		ast_log(LOG_EVENT, "Failed attempt from %s\n", ast_inet_ntoa(s->sin.sin_addr));
 	}
+
+	/* If the entire session occurs in a single context switch, then it's
+	 * possible to get an unsafe memory condition by free()ing the memory
+	 * before letting other threads run at least once.  This actually seems
+	 * like a workaround for a glibc bug.
+	 */
+	usleep(1);
+
 	destroy_session(s);
 
 done:
-- 
GitLab