aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-30 14:54:19 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-30 14:54:19 +0000
commitbdb99139fb41d0d057e6fec109c05373ab7acd7a (patch)
tree671cd0e68fece9432366d1965a13b0cc5cb2bbb8 /channel.c
parent2e6e32e358292154d69b19186e25f32192f14bcf (diff)
Bug 6091 - Fix race condition around uniqueid
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@7677 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rw-r--r--channel.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/channel.c b/channel.c
index 1897fb1c6..89071211f 100644
--- a/channel.c
+++ b/channel.c
@@ -94,6 +94,7 @@ struct ast_channel_spy_list {
*/
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 @@ struct ast_channel *ast_channel_alloc(int needqueue)
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);