rt: Make task killing synchronization possibly more correct
I could not come up with a test but this looks better to me.
This commit is contained in:
parent
c424b7f847
commit
5d625af9f9
src/rt
@ -248,7 +248,7 @@ rust_task::kill() {
|
||||
killed = true;
|
||||
// Unblock the task so it can unwind.
|
||||
|
||||
if (blocked()) {
|
||||
if (blocked() && must_fail_from_being_killed_unlocked()) {
|
||||
wakeup(cond);
|
||||
}
|
||||
|
||||
@ -648,11 +648,13 @@ rust_task::on_rust_stack() {
|
||||
|
||||
void
|
||||
rust_task::inhibit_kill() {
|
||||
scoped_lock with(kill_lock);
|
||||
disallow_kill = true;
|
||||
}
|
||||
|
||||
void
|
||||
rust_task::allow_kill() {
|
||||
scoped_lock with(kill_lock);
|
||||
disallow_kill = false;
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ private:
|
||||
rust_cond *cond;
|
||||
const char *cond_name;
|
||||
|
||||
// Protects the killed flag
|
||||
// Protects the killed flag, disallow_kill flag, reentered_rust_stack
|
||||
lock_and_signal kill_lock;
|
||||
// Indicates that the task was killed and needs to unwind
|
||||
bool killed;
|
||||
@ -372,7 +372,10 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
|
||||
assert(next_rust_sp);
|
||||
|
||||
bool had_reentered_rust_stack = reentered_rust_stack;
|
||||
reentered_rust_stack = true;
|
||||
{
|
||||
scoped_lock with(kill_lock);
|
||||
reentered_rust_stack = true;
|
||||
}
|
||||
|
||||
uintptr_t prev_c_sp = next_c_sp;
|
||||
next_c_sp = get_sp();
|
||||
@ -384,7 +387,10 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
|
||||
__morestack(args, fn_ptr, sp);
|
||||
|
||||
next_c_sp = prev_c_sp;
|
||||
reentered_rust_stack = had_reentered_rust_stack;
|
||||
{
|
||||
scoped_lock with(kill_lock);
|
||||
reentered_rust_stack = had_reentered_rust_stack;
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
|
Loading…
x
Reference in New Issue
Block a user