kernel: Fix race condition when waiting for load of new team.

There was no synchronization of the check of the done flag and the
waiting thread suspending to wait for it. It was therefore possible that
the new team both set the flag and triggered the wakeup of the waiting
thread in that time window, causing it to miss both the set flag and the
thread resumption.

Use a condition variable instead.

Fixes #13081.

Change-Id: I93c45db8dd773fe42b45c4b67153bcd39e200d3b
Reviewed-on: https://review.haiku-os.org/803
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Michael Lotz
2018-12-26 23:48:41 +00:00
committed by waddlesplash
parent b5ccfd350d
commit 13beda00d3
3 changed files with 12 additions and 16 deletions
+1 -2
View File
@@ -83,9 +83,8 @@ struct thread_death_entry {
};
struct team_loading_info {
Thread* thread; // the waiting thread
ConditionVariable condition;
status_t result; // the result of the loading
bool done; // set when loading is done/aborted
};
struct team_watcher {