File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 11
11
use container:: Container ;
12
12
use from_str:: FromStr ;
13
13
use libc;
14
- use option:: { Some , None } ;
14
+ use option:: { Some , None , Option } ;
15
15
use os;
16
16
use str:: StrSlice ;
17
17
use unstable:: atomics:: { AtomicInt , INIT_ATOMIC_INT , SeqCst } ;
@@ -57,7 +57,13 @@ pub fn limit_thread_creation_due_to_osx_and_valgrind() -> bool {
57
57
/// either `RUST_THREADS` or `num_cpus`.
58
58
pub fn default_sched_threads ( ) -> uint {
59
59
match os:: getenv ( "RUST_THREADS" ) {
60
- Some ( nstr) => FromStr :: from_str ( nstr) . unwrap ( ) ,
60
+ Some ( nstr) => {
61
+ let opt_n: Option < uint > = FromStr :: from_str ( nstr) ;
62
+ match opt_n {
63
+ Some ( n) if n > 0 => n,
64
+ _ => rtabort ! ( "`RUST_THREADS` is `%s`, should be a positive integer" , nstr)
65
+ }
66
+ }
61
67
None => {
62
68
if limit_thread_creation_due_to_osx_and_valgrind ( ) {
63
69
1
You can’t perform that action at this time.
0 commit comments