aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xapps/app_random.c1
-rwxr-xr-xasterisk.c6
-rwxr-xr-xchannels/chan_iax2.c1
-rwxr-xr-xpbx/pbx_dundi.c3
-rwxr-xr-xres/res_musiconhold.c5
5 files changed, 8 insertions, 8 deletions
diff --git a/apps/app_random.c b/apps/app_random.c
index c47212a27..f8558a3b4 100755
--- a/apps/app_random.c
+++ b/apps/app_random.c
@@ -106,7 +106,6 @@ int unload_module(void)
int load_module(void)
{
- srandom((unsigned int)getpid() + (unsigned int)time(NULL));
return ast_register_application(app_random, random_exec, random_synopsis, random_descrip);
}
diff --git a/asterisk.c b/asterisk.c
index ee0bef9a9..562cf3769 100755
--- a/asterisk.c
+++ b/asterisk.c
@@ -1922,6 +1922,12 @@ int main(int argc, char *argv[])
signal(SIGCHLD, child_handler);
signal(SIGPIPE, SIG_IGN);
+ /* ensure that the random number generators are seeded with a different value every time
+ Asterisk is started
+ */
+ srand((unsigned int) getpid() + (unsigned int) time(NULL));
+ srandom((unsigned int) getpid() + (unsigned int) time(NULL));
+
if (init_logger()) {
printf(term_quit());
exit(1);
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 40dbdb842..6c0608bce 100755
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -8465,7 +8465,6 @@ static int reload_config(void)
ast_clear_flag((&globalflags), IAX_NOTRANSFER);
ast_clear_flag((&globalflags), IAX_USEJITTERBUF);
ast_clear_flag((&globalflags), IAX_FORCEJITTERBUF);
- srand(time(NULL));
delete_users();
set_config(config,1);
prune_peers();
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index cae675c17..1c198c0e4 100755
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -4632,9 +4632,6 @@ int load_module(void)
dundi_set_output(dundi_debug_output);
dundi_set_error(dundi_error_output);
- /* Seed random number generator */
- srand(time(NULL));
-
sin.sin_family = AF_INET;
sin.sin_port = ntohs(DUNDI_PORT);
sin.sin_addr.s_addr = INADDR_ANY;
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index ac6c0d54d..6ba33b3ca 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -169,10 +169,9 @@ static int ast_moh_files_next(struct ast_channel *chan)
state->pos++;
}
- if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
- srand(time(NULL)+getpid()+strlen(chan->name)-state->class->total_files);
+ if (ast_test_flag(state->class, MOH_RANDOMIZE))
state->pos = rand();
- }
+
/* check to see if this file's format can be opened */
if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) != -1)
break;