ensure that the random number generator(s) are always seeded with a different value during Asterisk startup
don't reinitialize random number generators in other modules (bug #4017) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5459 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
18e2c2e468
commit
b052fe894b
|
@ -106,7 +106,6 @@ int unload_module(void)
|
||||||
|
|
||||||
int load_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);
|
return ast_register_application(app_random, random_exec, random_synopsis, random_descrip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1922,6 +1922,12 @@ int main(int argc, char *argv[])
|
||||||
signal(SIGCHLD, child_handler);
|
signal(SIGCHLD, child_handler);
|
||||||
signal(SIGPIPE, SIG_IGN);
|
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()) {
|
if (init_logger()) {
|
||||||
printf(term_quit());
|
printf(term_quit());
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -8465,7 +8465,6 @@ static int reload_config(void)
|
||||||
ast_clear_flag((&globalflags), IAX_NOTRANSFER);
|
ast_clear_flag((&globalflags), IAX_NOTRANSFER);
|
||||||
ast_clear_flag((&globalflags), IAX_USEJITTERBUF);
|
ast_clear_flag((&globalflags), IAX_USEJITTERBUF);
|
||||||
ast_clear_flag((&globalflags), IAX_FORCEJITTERBUF);
|
ast_clear_flag((&globalflags), IAX_FORCEJITTERBUF);
|
||||||
srand(time(NULL));
|
|
||||||
delete_users();
|
delete_users();
|
||||||
set_config(config,1);
|
set_config(config,1);
|
||||||
prune_peers();
|
prune_peers();
|
||||||
|
|
|
@ -4632,9 +4632,6 @@ int load_module(void)
|
||||||
dundi_set_output(dundi_debug_output);
|
dundi_set_output(dundi_debug_output);
|
||||||
dundi_set_error(dundi_error_output);
|
dundi_set_error(dundi_error_output);
|
||||||
|
|
||||||
/* Seed random number generator */
|
|
||||||
srand(time(NULL));
|
|
||||||
|
|
||||||
sin.sin_family = AF_INET;
|
sin.sin_family = AF_INET;
|
||||||
sin.sin_port = ntohs(DUNDI_PORT);
|
sin.sin_port = ntohs(DUNDI_PORT);
|
||||||
sin.sin_addr.s_addr = INADDR_ANY;
|
sin.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
|
@ -169,10 +169,9 @@ static int ast_moh_files_next(struct ast_channel *chan)
|
||||||
state->pos++;
|
state->pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ast_test_flag(state->class, MOH_RANDOMIZE)) {
|
if (ast_test_flag(state->class, MOH_RANDOMIZE))
|
||||||
srand(time(NULL)+getpid()+strlen(chan->name)-state->class->total_files);
|
|
||||||
state->pos = rand();
|
state->pos = rand();
|
||||||
}
|
|
||||||
/* check to see if this file's format can be opened */
|
/* check to see if this file's format can be opened */
|
||||||
if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) != -1)
|
if (ast_fileexists(state->class->filearray[state->pos], NULL, NULL) != -1)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue