Skip to content

Commit 50a7831

Browse files
committed
---
yaml --- r: 4517 b: refs/heads/master c: 0cd607b h: refs/heads/master i: 4515: 95fcfa6 v: v3
1 parent d7814b8 commit 50a7831

File tree

6 files changed

+29
-3
lines changed

6 files changed

+29
-3
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: f6ad0514087f985ce1c1aad126b28b8e17e2e005
2+
refs/heads/master: 0cd607bcbdc70d3d7ccefd5faf830cc8e5d68c86

trunk/src/rt/rust_kernel.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,14 @@ int rust_kernel::start_task_threads()
134134
return rval;
135135
}
136136

137+
void
138+
rust_kernel::fail() {
139+
for(size_t i = 0; i < num_threads; ++i) {
140+
rust_scheduler *thread = threads[i];
141+
thread->kill_all_tasks();
142+
}
143+
}
144+
137145
rust_task_id
138146
rust_kernel::create_task(rust_task *spawner, const char *name) {
139147
rust_scheduler *thread = threads[rand(&rctx) % num_threads];

trunk/src/rt/rust_kernel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class rust_kernel {
5252
void *realloc(void *mem, size_t size);
5353
void free(void *mem);
5454

55+
void fail();
56+
5557
int start_task_threads();
5658

5759
#ifdef __WIN32__

trunk/src/rt/rust_scheduler.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,21 @@ rust_scheduler::fail() {
7171
name, this);
7272
I(this, kernel->rval == 0);
7373
kernel->rval = 1;
74-
exit(1);
74+
kernel->fail();
75+
}
76+
77+
void
78+
rust_scheduler::kill_all_tasks() {
79+
I(this, !lock.lock_held_by_current_thread());
80+
scoped_lock with(lock);
81+
82+
for (size_t i = 0; i < running_tasks.length(); i++) {
83+
running_tasks[i]->kill();
84+
}
85+
86+
for (size_t i = 0; i < blocked_tasks.length(); i++) {
87+
blocked_tasks[i]->kill();
88+
}
7589
}
7690

7791
size_t

trunk/src/rt/rust_scheduler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ struct rust_scheduler : public kernel_owned<rust_scheduler>,
8181

8282
void log_state();
8383

84+
void kill_all_tasks();
85+
8486
rust_task *create_task(rust_task *spawner, const char *name);
8587

8688
virtual void run();

trunk/src/rt/rust_upcall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ upcall_fail(rust_task *task,
195195
size_t line) {
196196
LOG_UPCALL_ENTRY(task);
197197
LOG_ERR(task, upcall, "upcall fail '%s', %s:%" PRIdPTR, expr, file, line);
198-
task->fail();
199198
task->die();
199+
task->fail();
200200
task->notify_tasks_waiting_to_join();
201201
task->yield(4);
202202
}

0 commit comments

Comments
 (0)