about summary refs log tree commit diff
path: root/src/rt/rust_kernel.h
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-27 13:36:54 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-27 14:25:32 -0800
commitb3f77bf92703543793a8073c8319e461e024cb69 (patch)
treef32f999cc958d5c5a9d496025be4d5c31ca1b5ee /src/rt/rust_kernel.h
parente4c027446ec0d985be98dcbdce2b80308b88b12a (diff)
downloadrust-b3f77bf92703543793a8073c8319e461e024cb69.tar.gz
rust-b3f77bf92703543793a8073c8319e461e024cb69.zip
rt: Change the way the kernel exits to avoid pthread leaks
This makes the kernel join every scheduler thread before exiting in order to
ensure that all threads are completely terminated before the process exits. On
my machine, for 32-bit targets, this was causing regular valgrind errors.
Diffstat (limited to 'src/rt/rust_kernel.h')
-rw-r--r--src/rt/rust_kernel.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h
index 6ea66592b33..b1882e7c100 100644
--- a/src/rt/rust_kernel.h
+++ b/src/rt/rust_kernel.h
@@ -3,6 +3,7 @@
 #define RUST_KERNEL_H
 
 #include <map>
+#include <vector>
 #include "memory_region.h"
 #include "rust_log.h"
 
@@ -36,14 +37,15 @@ private:
     lock_and_signal rval_lock;
     int rval;
 
-    // Protects live_schedulers, max_sched_id and sched_table
+    // Protects max_sched_id and sched_table, join_list
     lock_and_signal sched_lock;
-    // Tracks the number of schedulers currently running.
-    // When this hits 0 we will signal the sched_lock and the
-    // kernel will terminate.
-    uintptr_t live_schedulers;
+    // The next scheduler id
     rust_sched_id max_sched_id;
+    // A map from scheduler ids to schedulers. When this is empty
+    // the kernel terminates
     sched_map sched_table;
+    // A list of scheduler ids that are ready to exit
+    std::vector<rust_sched_id> join_list;
 
 public: