Re: [PATCH 1/6] maintenance: add get_random_minute()
- From
Taylor Blau <me@ttaylorr.com>
- Date
- Aug 8, 2023, 20:04 UTC
- Message-ID
- <ZNKfxOWJAuJ5DxAN@nand.local>
- In-Reply-To
- <8854e369-fabb-4044-a06c-eaf5b9fbde4a@github.com>
On Tue, Aug 08, 2023 at 01:28:50PM -0400, Derrick Stolee wrote:
Show 9 quoted lines
> > So I think this is kind of outside the scope of your series, but I > > wonder if we should have a git_rand() that automatically initializes the > > PRNG with the value of getpid()? Then multiple callers can grab random > > values at will without reinitializing the PRNG. > > I see you're moving ahead with removing the srand() from the lockfile code, > so I'll focus on creating a `git_rand()` that centralizes the use of > srand(), but won't touch the code in the lockfile so your patch applies > independently.
That thread may have progressed a little since you last looked at it.
Instead of using srand() and rand() (which would make sense to wrap with git_rand() as you propose), we can simplify our lives by using a CSPRNG, which only gets initialized once, as is already the case with csprng_bytes().
I think Junio is picking up a lightly modified version of my patch there, see [1].
Thanks, Taylor
[1]: https://lore.kernel.org/git/ZNKfKs1mLQhnybvF@nand.local/