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
This commit is contained in:
Mark Michelson
2008-07-07 17:02:28 +00:00
parent d227632177
commit 2ac560c495

View File

@@ -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);