summaryrefslogtreecommitdiff
path: root/channels/chan_jingle.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2006-05-30 20:24:40 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2006-05-30 20:24:40 +0000
commit705b5459c1a9ae284ea147a83fbaded5edc5d07c (patch)
tree131959b10515ffed46b1380630462f801b46a7c3 /channels/chan_jingle.c
parent9afb0e1cd2f0e100eb6d335494a33a7785dcf774 (diff)
Bug 7237 - Replace recoded thread_safe_rand with the existing ast_random API
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@30906 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_jingle.c')
-rw-r--r--channels/chan_jingle.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index 83a79ed4f..3f53e4ab8 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -161,9 +161,6 @@ static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GS
/* Protect the interface list (of sip_pvt's) */
AST_MUTEX_DEFINE_STATIC(jinglelock);
-AST_MUTEX_DEFINE_STATIC(rand_lock); /*!< Lock for thread-safe random generator */
-
-
static struct ast_channel *jingle_request(const char *type, int format, void *data, int *cause);
static int jingle_digit(struct ast_channel *ast, char digit);
static int jingle_call(struct ast_channel *ast, char *dest, int timeout);
@@ -393,17 +390,6 @@ static int jingle_answer(struct ast_channel *ast)
return res;
}
-static force_inline int thread_safe_rand(void)
-{
- int val;
-
- ast_mutex_lock(&rand_lock);
- val = rand();
- ast_mutex_unlock(&rand_lock);
-
- return val;
-}
-
static struct ast_rtp *jingle_get_rtp_peer(struct ast_channel *chan)
{
struct jingle_pvt *p;
@@ -567,8 +553,8 @@ static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p,
ast_copy_string(ours1->name, "rtp", sizeof(ours1->name));
ours1->port = ntohs(sin.sin_port);
ours1->preference = 1;
- snprintf(user, sizeof(user), "%08x%08x", thread_safe_rand(), thread_safe_rand());
- snprintf(pass, sizeof(pass), "%08x%08x", thread_safe_rand(), thread_safe_rand());
+ snprintf(user, sizeof(user), "%08lx%08lx", ast_random(), ast_random());
+ snprintf(pass, sizeof(pass), "%08lx%08lx", ast_random(), ast_random());
ast_copy_string(ours1->username, user, sizeof(ours1->username));
ast_copy_string(ours1->password, pass, sizeof(ours1->password));
ast_inet_ntoa(ours1->ip, sizeof(ours1->ip), us);
@@ -579,8 +565,8 @@ static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p,
if (!ast_strlen_zero(externip)) {
/* XXX We should really stun for this one not just go with externip XXX */
- snprintf(user, sizeof(user), "%08x%08x", thread_safe_rand(), thread_safe_rand());
- snprintf(pass, sizeof(pass), "%08x%08x", thread_safe_rand(), thread_safe_rand());
+ snprintf(user, sizeof(user), "%08lx%08lx", ast_random(), ast_random());
+ snprintf(pass, sizeof(pass), "%08lx%08lx", ast_random(), ast_random());
ast_copy_string(ours2->username, user, sizeof(ours2->username));
ast_copy_string(ours2->password, pass, sizeof(ours2->password));
ast_copy_string(ours2->ip, externip, sizeof(ours2->ip));