[asterisk-commits] branch 1.2 - r7677 /branches/1.2/channel.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Dec 30 08:54:20 CST 2005


Author: tilghman
Date: Fri Dec 30 08:54:19 2005
New Revision: 7677

URL: http://svn.digium.com/view/asterisk?rev=7677&view=rev
Log:
Bug 6091 - Fix race condition around uniqueid

Modified:
    branches/1.2/channel.c

Modified: branches/1.2/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channel.c?rev=7677&r1=7676&r2=7677&view=diff
==============================================================================
--- branches/1.2/channel.c (original)
+++ branches/1.2/channel.c Fri Dec 30 08:54:19 2005
@@ -94,6 +94,7 @@
  */
 static int shutting_down = 0;
 
+AST_MUTEX_DEFINE_STATIC(uniquelock);
 static int uniqueint = 0;
 
 unsigned long global_fin = 0, global_fout = 0;
@@ -583,7 +584,9 @@
 	tmp->data = NULL;
 	tmp->fin = global_fin;
 	tmp->fout = global_fout;
+	ast_mutex_lock(&uniquelock);
 	snprintf(tmp->uniqueid, sizeof(tmp->uniqueid), "%li.%d", (long) time(NULL), uniqueint++);
+	ast_mutex_unlock(&uniquelock);
 	headp = &tmp->varshead;
 	ast_mutex_init(&tmp->lock);
 	AST_LIST_HEAD_INIT_NOLOCK(headp);



More information about the asterisk-commits mailing list