diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-06-21 18:08:34 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-06-27 09:58:39 -0700 |
| commit | 6367bcf4276c06d41b0d66f10711ca3b076ae547 (patch) | |
| tree | 14f52a00319dcba17755330da3bcf978a53c0b3d /src/rt/rust_dom.cpp | |
| parent | 4d99bf9af2107523c01566968e889c4f1a5de49e (diff) | |
| download | rust-6367bcf4276c06d41b0d66f10711ca3b076ae547.tar.gz rust-6367bcf4276c06d41b0d66f10711ca3b076ae547.zip | |
Fixed a few concurrency bugs. Still not perfect, but overall it seems much more reliable.
Diffstat (limited to 'src/rt/rust_dom.cpp')
| -rw-r--r-- | src/rt/rust_dom.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp index 7b5467ddeb1..ac258f5c973 100644 --- a/src/rt/rust_dom.cpp +++ b/src/rt/rust_dom.cpp @@ -166,9 +166,11 @@ rust_dom::number_of_live_tasks() { */ void rust_dom::reap_dead_tasks() { + I(this, scheduler_lock.lock_held_by_current_thread()); for (size_t i = 0; i < dead_tasks.length(); ) { rust_task *task = dead_tasks[i]; - if (task->ref_count == 0) { + // Make sure this task isn't still running somewhere else... + if (task->ref_count == 0 && task->can_schedule()) { I(this, task->tasks_waiting_to_join.is_empty()); dead_tasks.remove(task); DLOG(this, task, @@ -315,13 +317,14 @@ rust_dom::start_main_loop(int id) { DLOG(this, task, "Running task %p on worker %d", scheduled_task, id); + I(this, !scheduled_task->active); scheduled_task->active = true; activate(scheduled_task); scheduled_task->active = false; DLOG(this, task, "returned from task %s @0x%" PRIxPTR - " in state '%s', sp=0x%, worker id=%d" PRIxPTR, + " in state '%s', sp=0x%x, worker id=%d" PRIxPTR, scheduled_task->name, (uintptr_t)scheduled_task, scheduled_task->state->name, @@ -349,7 +352,9 @@ rust_dom::start_main_loop(int id) { "scheduler yielding ...", dead_tasks.length()); log_state(); + scheduler_lock.unlock(); sync::yield(); + scheduler_lock.lock(); } else { drain_incoming_message_queue(true); } |
