Skip to content

Commit 4e58fde

Browse files
committed
---
yaml --- r: 14601 b: refs/heads/try c: 04d9cc1 h: refs/heads/master i: 14599: dd7e547 v: v3
1 parent 28d8525 commit 4e58fde

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: f4ce965ce70f7f7ffa62df721d083cb3eafeb19d
5+
refs/heads/try: 04d9cc18a569f5d8a8b7c2c07a42259af41d7cb3
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_task.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
7777
state(state),
7878
cond(NULL),
7979
cond_name("none"),
80-
supervisor(spawner),
8180
list_index(-1),
8281
next_port_id(0),
8382
rendezvous_ptr(0),
@@ -92,7 +91,8 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
9291
reentered_rust_stack(false),
9392
c_stack(NULL),
9493
next_c_sp(0),
95-
next_rust_sp(0)
94+
next_rust_sp(0),
95+
supervisor(spawner)
9696
{
9797
LOGPTR(thread, "new task", (uintptr_t)this);
9898
DLOG(thread, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this);
@@ -103,6 +103,7 @@ rust_task::rust_task(rust_task_thread *thread, rust_task_list *state,
103103
}
104104
}
105105

106+
// NB: This does not always run on the task's scheduler thread
106107
void
107108
rust_task::delete_this()
108109
{
@@ -112,8 +113,11 @@ rust_task::delete_this()
112113
name, (uintptr_t)this, ref_count);
113114

114115
// FIXME: We should do this when the task exits, not in the destructor
115-
if (supervisor) {
116-
supervisor->deref();
116+
{
117+
scoped_lock with(supervisor_lock);
118+
if (supervisor) {
119+
supervisor->deref();
120+
}
117121
}
118122

119123
/* FIXME: tighten this up, there are some more
@@ -302,6 +306,7 @@ rust_task::conclude_failure() {
302306

303307
void
304308
rust_task::fail_parent() {
309+
scoped_lock with(supervisor_lock);
305310
if (supervisor) {
306311
DLOG(thread, task,
307312
"task %s @0x%" PRIxPTR
@@ -317,6 +322,7 @@ rust_task::fail_parent() {
317322
void
318323
rust_task::unsupervise()
319324
{
325+
scoped_lock with(supervisor_lock);
320326
if (supervisor) {
321327
DLOG(thread, task,
322328
"task %s @0x%" PRIxPTR

branches/try/src/rt/rust_task.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ rust_task : public kernel_owned<rust_task>, rust_cond
7171
rust_task_list *state;
7272
rust_cond *cond;
7373
const char *cond_name;
74-
rust_task *supervisor; // Parent-link for failure propagation.
7574
int32_t list_index;
7675

7776
rust_port_id next_port_id;
@@ -120,6 +119,9 @@ rust_task : public kernel_owned<rust_task>, rust_cond
120119

121120
rust_port_selector port_selector;
122121

122+
lock_and_signal supervisor_lock;
123+
rust_task *supervisor; // Parent-link for failure propagation.
124+
123125
// Called when the atomic refcount reaches zero
124126
void delete_this();
125127

0 commit comments

Comments
 (0)