From: Mark Michelson Date: Mon, 7 Jul 2008 17:02:28 +0000 (+0000) Subject: By using the iaxdynamicthreadcount to identify a thread, it was possible X-Git-Tag: 1.4.22-rc1~145 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2ac560c4951f27a505e8ca27a9accce65c5d59b5;p=thirdparty%2Fasterisk.git By using the iaxdynamicthreadcount to identify a thread, it was possible for thread identifiers to be duplicated. By using a globally-unique monotonically- increasing integer, this is now avoided. (closes issue #13009) Reported by: jpgrayson Patches: chan_iax2_dyn_threadnum.patch uploaded by jpgrayson (license 492) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@128639 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 9234a5d177..f312f4fe62 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -446,6 +446,7 @@ static AST_LIST_HEAD_STATIC(registrations, iax2_registry); static int iaxthreadcount = DEFAULT_THREAD_COUNT; static int iaxmaxthreadcount = DEFAULT_MAX_THREAD_COUNT; static int iaxdynamicthreadcount = 0; +static int iaxdynamicthreadnum = 0; static int iaxactivethreadcount = 0; struct iax_rr { @@ -920,7 +921,7 @@ static struct iax2_thread *find_idle_thread(void) if (thread == NULL && iaxmaxthreadcount > iaxdynamicthreadcount) { /* We need to MAKE a thread! */ if ((thread = ast_calloc(1, sizeof(*thread)))) { - thread->threadnum = iaxdynamicthreadcount; + thread->threadnum = iaxdynamicthreadnum++; thread->type = IAX_TYPE_DYNAMIC; ast_mutex_init(&thread->lock); ast_cond_init(&thread->cond, NULL);