Skip to content

Commit 73760ea

Browse files
authored
Merge pull request #653 from yuanding53/master
Optimize random function in ff_compat.c
2 parents 93b7ff1 + e27a576 commit 73760ea

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/ff_compat.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ struct prisonlist allprison;
6767

6868
MALLOC_DEFINE(M_FADVISE, "fadvise", "posix_fadvise(2) information");
6969
int async_io_version;
70+
extern unsigned int rand_r(unsigned int *seed);
71+
unsigned int seed = 0;
7072

7173
#define M_ZERO 0x0100 /* bzero the allocation */
7274

@@ -294,7 +296,10 @@ arc4rand(void *ptr, unsigned int len, int reseed)
294296
uint32_t
295297
arc4random(void)
296298
{
297-
return ff_arc4random();
299+
if (seed == 0) {
300+
seed = ff_arc4random();
301+
}
302+
return (uint32_t)rand_r(&seed);
298303
}
299304

300305
void

0 commit comments

Comments
 (0)