[asterisk-commits] trunk r30906 - /trunk/channels/chan_jingle.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue May 30 13:24:40 MST 2006


Author: tilghman
Date: Tue May 30 15:24:40 2006
New Revision: 30906

URL: http://svn.digium.com/view/asterisk?rev=30906&view=rev
Log:
Bug 7237 - Replace recoded thread_safe_rand with the existing ast_random API

Modified:
    trunk/channels/chan_jingle.c

Modified: trunk/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_jingle.c?rev=30906&r1=30905&r2=30906&view=diff
==============================================================================
--- trunk/channels/chan_jingle.c (original)
+++ trunk/channels/chan_jingle.c Tue May 30 15:24:40 2006
@@ -161,9 +161,6 @@
 /* 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 @@
 	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 @@
 	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 @@
 
 	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));



More information about the asterisk-commits mailing list