From e0ba99b7f5b9f06dda7fe4baa8a7fb90e2ab40c8 Mon Sep 17 00:00:00 2001 From: tilghman Date: Wed, 5 Apr 2006 17:44:44 +0000 Subject: Bug 6873 - Finish moving from the non-threadsafe (and poor randomness) rand() to threadsafe ast_random() git-svn-id: http://svn.digium.com/svn/asterisk/trunk@17627 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_mgcp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'channels/chan_mgcp.c') diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 397e24084..d2bcfa865 100644 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -2616,7 +2616,7 @@ static void start_rtp(struct mgcp_subchannel *sub) ast_rtp_set_data(p->rtp, p); #endif /* Make a call*ID */ - snprintf(sub->callid, sizeof(sub->callid), "%08x%s", rand(), sub->txident); + snprintf(sub->callid, sizeof(sub->callid), "%08lx%s", ast_random(), sub->txident); /* Transmit the connection create */ transmit_connect_with_sdp(sub, NULL); ast_mutex_unlock(&sub->lock); @@ -3785,7 +3785,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v) strncpy(e->language, language, sizeof(e->language) - 1); strncpy(e->musicclass, musicclass, sizeof(e->musicclass) - 1); strncpy(e->mailbox, mailbox, sizeof(e->mailbox) - 1); - snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08x", rand()); + snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random()); e->msgstate = -1; e->amaflags = amaflags; e->capability = capability; @@ -3811,7 +3811,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v) /* ASSUME we're onhook */ e->hookstate = MGCP_ONHOOK; if (!ep_reload) { - /*snprintf(txident, sizeof(txident), "%08x", rand());*/ + /*snprintf(txident, sizeof(txident), "%08lx", ast_random());*/ for (i = 0; i < MAX_SUBS; i++) { sub = malloc(sizeof(struct mgcp_subchannel)); if (sub) { @@ -3821,7 +3821,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v) ast_mutex_init(&sub->cx_queue_lock); sub->parent = e; sub->id = i; - snprintf(sub->txident, sizeof(sub->txident), "%08x", rand()); + snprintf(sub->txident, sizeof(sub->txident), "%08lx", ast_random()); /*stnrcpy(sub->txident, txident, sizeof(sub->txident) - 1);*/ sub->cxmode = MGCP_CX_INACTIVE; sub->nat = nat; @@ -3916,7 +3916,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v) e->onhooktime = time(NULL); /* ASSUME we're onhook */ e->hookstate = MGCP_ONHOOK; - snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08x", rand()); + snprintf(e->rqnt_ident, sizeof(e->rqnt_ident), "%08lx", ast_random()); } for (i = 0, sub = NULL; i < MAX_SUBS; i++) { @@ -3938,7 +3938,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v) strncpy(sub->magic, MGCP_SUBCHANNEL_MAGIC, sizeof(sub->magic) - 1); sub->parent = e; sub->id = i; - snprintf(sub->txident, sizeof(sub->txident), "%08x", rand()); + snprintf(sub->txident, sizeof(sub->txident), "%08lx", ast_random()); sub->cxmode = MGCP_CX_INACTIVE; sub->next = e->sub; e->sub = sub; -- cgit v1.2.3