From 38b34b6a7c00734875f35b67b7cf7adff529fd07 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 25 Sep 2006 15:32:54 +0000 Subject: [PATCH] * Use time(NULL) to seed the random number generator because it has a wider space than getpid() * Include to get time()'s prototype * Fix typo that prevented using /dev/urandom on systems that had it This commit was SVN r11780. --- orte/util/pre_condition_transports.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/orte/util/pre_condition_transports.c b/orte/util/pre_condition_transports.c index 9b2468d24f..57637952a9 100644 --- a/orte/util/pre_condition_transports.c +++ b/orte/util/pre_condition_transports.c @@ -30,6 +30,9 @@ #ifdef HAVE_FCNTL_H #include #endif +#ifdef HAVE_TIME_H +#include +#endif #include "orte/orte_constants.h" #include "orte/orte_types.h" @@ -52,9 +55,7 @@ */ static inline void orte_pre_condition_transports_use_rand(uint64_t* unique_key) { - int pid; - pid = getpid(); - srand(pid); + srand(time(NULL)); unique_key[1] = rand(); unique_key[2] = rand(); } @@ -73,7 +74,7 @@ int orte_pre_condition_transports(orte_app_context_t **app_context, size_t num_c /* put the number here - or else create an appropriate string. this just needs to * eventually be a string variable */ - if(0 == stat("/dev/urandom", &buf)) { + if(0 != stat("/dev/urandom", &buf)) { /* file doesn't exist! */ orte_pre_condition_transports_use_rand(unique_key); }