Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rand() -> random(), since we use srandom(). #1955

Merged
merged 1 commit into from Mar 7, 2018

Conversation

dtzWill
Copy link
Member

@dtzWill dtzWill commented Mar 6, 2018

rand() requires we call srand() instead,
but might as well use random().


As-is, all threads will have the same seed and
(in some cases) quickly encounter problems when
they generate the same temporary link names in the same order.

Looking at the glibc source, it appears to implement
rand() using random() which is why this didn't cause
bigger problems previously.

Note that "random()" does return "long int" instead
of the "int" returned by "rand()" but that seems okay:
either they're the same size or the larger type
results in slightly longer names for our temporary
links bringing with it a corresponding reduction
in chance of collision between threads.

rand() requires we call srand() instead,
but might as well use random().
@edolstra edolstra merged commit 4452f6e into NixOS:master Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants