From 0cd607bcbdc70d3d7ccefd5faf830cc8e5d68c86 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 10 Aug 2011 12:57:53 -0700 Subject: rt: Shutdown gracefully on failure When the kernel fails, kill all tasks and wait for the schedulers to stop instead of just exiting. I'm sure there are tons of lurking issues here but this is enough to fail without leaking (at least in the absence of cleanups). --- src/rt/rust_scheduler.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/rt/rust_scheduler.cpp') diff --git a/src/rt/rust_scheduler.cpp b/src/rt/rust_scheduler.cpp index 30504319b30..33e607a85e1 100644 --- a/src/rt/rust_scheduler.cpp +++ b/src/rt/rust_scheduler.cpp @@ -71,7 +71,21 @@ rust_scheduler::fail() { name, this); I(this, kernel->rval == 0); kernel->rval = 1; - exit(1); + kernel->fail(); +} + +void +rust_scheduler::kill_all_tasks() { + I(this, !lock.lock_held_by_current_thread()); + scoped_lock with(lock); + + for (size_t i = 0; i < running_tasks.length(); i++) { + running_tasks[i]->kill(); + } + + for (size_t i = 0; i < blocked_tasks.length(); i++) { + blocked_tasks[i]->kill(); + } } size_t -- cgit 1.4.1-3-g733a5