mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Protect random reseeding with a lock
This commit is contained in:
parent
54d944c496
commit
4259a16931
1 changed files with 7 additions and 1 deletions
|
|
@ -86,12 +86,18 @@ static uint64_t random_state = 1;
|
|||
|
||||
void random_seed(uint64_t seed)
|
||||
{
|
||||
lock_random();
|
||||
random_state = seed;
|
||||
unlock_random();
|
||||
}
|
||||
|
||||
void random_reseed(void)
|
||||
{
|
||||
random_state = os_tick();
|
||||
uint64_t seed = os_tick();
|
||||
|
||||
lock_random();
|
||||
random_state = seed;
|
||||
unlock_random();
|
||||
}
|
||||
|
||||
unsigned char random_u8(void)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue