-
Notifications
You must be signed in to change notification settings - Fork 432
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
Limit OsRng to a single file handle when reading from a file #239
Conversation
I'd think the |
As it is this requires using a very recent compiler compared to the 1.15 we support now, so I'm hesitant adding it for that reason. Rand v0.5 will have quite a few changes anyway though so may be a good time to update the compiler. Thanks for taking a look. |
b952a22
to
91a02cc
Compare
Rebased. I plan to merge this with the bump to the minimum Rust version, and probably with all the |
When you made this PR I was curious how often reading from How many distributions support old(er) pre-3.17 Linux kernel versions?
So still necessary on some old but still supported Linux distro's. MacOS should switch to the same method as iOS, and not read from Then there are Dragonfly BSD and NetBSD that don't have a better interface, and Redox. Not sure how Redox handles file descriptors, and maybe they are willing to provide another interface? If I forget about the BSD's for a moment, I have a bit mixed feelings about requiring a newer compiler version and extra complexity to support an edge case on older platforms. I am not saying I disagree, just pointing out when this code is going to get used. |
Is it possible to return an new error instead of unwrapping? For the rest I don't feel confident to review, do you want to cc someone? |
@burdges are you happy enough reviewing this code? (I guess you already did; it hasn't changed.) @pitdicker yes, but all 5 unwraps would be code logic errors if they failed, and consequently Note: the Servo devs had a real problem here frequently running out of file handles when running tests. |
This is required by the new code (but see lazy_static code for a workaround supporting older Rustc).
91a02cc
to
92cde65
Compare
@asajeffrey @jdm review request |
The rustc bump becomes doubly painful when you have rand-0.3.22 now depending on rand-0.4. |
This was merged into master, which will be released as 0.5 eventually, not 0.4. There are several breaking changes between 0.4 and 0.5 so I don't anticipate the same kind of compatibility release (possibly there will be partial compatibility by opting into a feature). |
@dhardy Ah, sorry! I misunderstood the errors we were getting from rayon using rand-0.3, which now uses rand-0.4. I actually was previously aware that rand-0.4 required rust 1.15, but I guess I forgot this and then jumped to the wrong conclusion when searching the reason for this new break. |
Limit OsRng to a single file handle when reading from a file
Fix #234.
I'm not entirely happy with the code; it uses
unwrap
a lot and requires use ofunsafe
to access the mutex, and it also requires Rust 1.22; anything older gets:lazy_static
gets around this by using aBox
cast to a pointer which never gets freed.The reasons I didn't use
lazy_static
are:ReadRng
sincelazy_static
doesn't allow a constructor or argument to be passed