diff --git a/src/cart/crt_init.c b/src/cart/crt_init.c index aa5716e71b52..4ae447bc8639 100644 --- a/src/cart/crt_init.c +++ b/src/cart/crt_init.c @@ -9,7 +9,6 @@ */ #include #include -#include #include #include "crt_internal.h" @@ -610,8 +609,6 @@ crt_init_opt(crt_group_id_t grpid, uint32_t flags, crt_init_options_t *opt) char *domain_env = NULL; char *auth_key; char *auth_key_env = NULL; - struct timeval now; - unsigned int seed; char *path; bool server = flags & CRT_FLAG_BIT_SERVER; int rc = 0; @@ -673,11 +670,6 @@ crt_init_opt(crt_group_id_t grpid, uint32_t flags, crt_init_options_t *opt) D_RWLOCK_WRLOCK(&crt_gdata.cg_rwlock); if (crt_gdata.cg_inited == 0) { - /* feed a seed for pseudo-random number generator */ - gettimeofday(&now, NULL); - seed = (unsigned int)(now.tv_sec * 1000000 + now.tv_usec); - d_srand(seed); - crt_gdata.cg_server = server; crt_gdata.cg_auto_swim_disable = (flags & CRT_FLAG_BIT_AUTO_SWIM_DISABLE) ? 1 : 0; diff --git a/src/gurt/misc.c b/src/gurt/misc.c index d92055a905d4..1abd49f7720b 100644 --- a/src/gurt/misc.c +++ b/src/gurt/misc.c @@ -46,6 +46,7 @@ void d_srand(long int seedval) { srand48_r(seedval, &randBuffer); + D_INFO("d_rand initialized with seed %ld\n", seedval); } long int @@ -544,7 +545,7 @@ d_rank_list_shuffle(d_rank_list_t *rank_list) return; for (i = 0; i < rank_list->rl_nr; i++) { - j = rand() % rank_list->rl_nr; + j = d_randn(rank_list->rl_nr); tmp = rank_list->rl_ranks[i]; rank_list->rl_ranks[i] = rank_list->rl_ranks[j]; rank_list->rl_ranks[j] = tmp; diff --git a/src/pool/cli.c b/src/pool/cli.c index 22516be7a27c..c862ba3466b5 100644 --- a/src/pool/cli.c +++ b/src/pool/cli.c @@ -1631,9 +1631,7 @@ choose_map_refresh_rank(struct map_refresh_arg *arg) if (arg->mra_i == -1) { /* Let i be a random integer in [0, n). */ - i = ((double)rand() / RAND_MAX) * n; - if (i == n) - i = 0; + i = d_randn(n); } else { /* Continue the round robin. */ i = arg->mra_i;