projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
exec: fix a race condition when setting environment variables
[collectd.git]
/
src
/
daemon
/
utils_random.c
diff --git
a/src/daemon/utils_random.c
b/src/daemon/utils_random.c
index
7a9ce7b
..
5500aaa
100644
(file)
--- a/
src/daemon/utils_random.c
+++ b/
src/daemon/utils_random.c
@@
-31,6
+31,14
@@
#include <pthread.h>
#include <pthread.h>
+#ifdef WIN32
+double erand48(unsigned short unused[3]) {
+ return (double)rand() / (double)RAND_MAX;
+}
+
+long int jrand48(unsigned short unused[3]) { return rand(); }
+#endif
+
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static bool have_seed;
static unsigned short seed[3];
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static bool have_seed;
static unsigned short seed[3];
@@
-47,6
+55,10
@@
static void cdrand_seed(void) {
seed[1] = (unsigned short)(t >> 16);
seed[2] = (unsigned short)(t >> 32);
seed[1] = (unsigned short)(t >> 16);
seed[2] = (unsigned short)(t >> 32);
+#ifdef WIN32
+ srand((unsigned)t);
+#endif
+
have_seed = true;
}
have_seed = true;
}