From 756c7cbb120c73de72f8e8dedcba1facea5029bd Mon Sep 17 00:00:00 2001 From: Tilghman Lesher 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: https://origsvn.digium.com/svn/asterisk/trunk@17627 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_page.c | 2 +- apps/app_queue.c | 4 ++-- apps/app_voicemail.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'apps') diff --git a/apps/app_page.c b/apps/app_page.c index a9ad2c16d..6051db440 100644 --- a/apps/app_page.c +++ b/apps/app_page.c @@ -143,7 +143,7 @@ static int page_exec(struct ast_channel *chan, void *data) char *tech, *resource; char meetmeopts[80]; struct ast_flags flags = { 0 }; - unsigned int confid = rand(); + unsigned int confid = ast_random(); struct ast_app *app; char *tmp; int res=0; diff --git a/apps/app_queue.c b/apps/app_queue.c index 9259bd77d..f79bb8a7c 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1992,7 +1992,7 @@ static int calc_metric(struct ast_call_queue *q, struct member *mem, int pos, st tmp->metric += mem->penalty * 1000000; break; case QUEUE_STRATEGY_RANDOM: - tmp->metric = rand() % 1000; + tmp->metric = ast_random() % 1000; tmp->metric += mem->penalty * 1000000; break; case QUEUE_STRATEGY_FEWESTCALLS: @@ -2241,7 +2241,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce else { /* Last ditch effort -- no CDR, make up something */ char tmpid[256]; - snprintf(tmpid, sizeof(tmpid), "chan-%x", rand()); + snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random()); ast_monitor_start(which, qe->parent->monfmt, tmpid, 1 ); } if (qe->parent->monjoin) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 369008390..dc0f87e17 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -1753,11 +1753,11 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *c fprintf(p, "Subject: New message %d in mailbox %s\n", msgnum + 1, mailbox); else fprintf(p, "Subject: [PBX]: New message %d in mailbox %s\n", msgnum + 1, mailbox); - fprintf(p, "Message-ID: \n", msgnum, (unsigned int)rand(), mailbox, getpid(), host); + fprintf(p, "Message-ID: \n", msgnum, (unsigned int)ast_random(), mailbox, getpid(), host); fprintf(p, "MIME-Version: 1.0\n"); if (attach_user_voicemail) { /* Something unique. */ - snprintf(bound, sizeof(bound), "voicemail_%d%s%d%d", msgnum, mailbox, getpid(), (unsigned int)rand()); + snprintf(bound, sizeof(bound), "voicemail_%d%s%d%d", msgnum, mailbox, getpid(), (unsigned int)ast_random()); fprintf(p, "Content-Type: multipart/mixed; boundary=\"%s\"\n\n\n", bound); -- cgit v1.2.3