mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-01 20:36:38 -05: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)
|
void random_seed(uint64_t seed)
|
||||||
{
|
{
|
||||||
|
lock_random();
|
||||||
random_state = seed;
|
random_state = seed;
|
||||||
|
unlock_random();
|
||||||
}
|
}
|
||||||
|
|
||||||
void random_reseed(void)
|
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)
|
unsigned char random_u8(void)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue