diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-08-15 11:34:12 -0700 |
|---|---|---|
| committer | Eric Holk <eholk@mozilla.com> | 2011-08-15 12:39:55 -0700 |
| commit | 5c6790519b12afae688c87ae3f55ee5eec1a6dcc (patch) | |
| tree | 7bfb02b5732710dbb1f0a0716875bde903d49d24 /src/rt/rust_kernel.cpp | |
| parent | 55c9842e7d16c3313ae12fbcc2d3a80cc9464190 (diff) | |
| download | rust-5c6790519b12afae688c87ae3f55ee5eec1a6dcc.tar.gz rust-5c6790519b12afae688c87ae3f55ee5eec1a6dcc.zip | |
Reducing the chances for race conditions in join.
Diffstat (limited to 'src/rt/rust_kernel.cpp')
| -rw-r--r-- | src/rt/rust_kernel.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index c11a5b69b73..ceddcf5b1c9 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -160,7 +160,17 @@ rust_kernel::get_task_by_id(rust_task_id id) { rust_task *task = NULL; // get leaves task unchanged if not found. task_table.get(id, &task); - if(task) task->ref(); + if(task) { + if(task->get_ref_count() == 0) { + // this means the destructor is running, since the destructor + // grabs the kernel lock to unregister the task. Pretend this + // doesn't actually exist. + return NULL; + } + else { + task->ref(); + } + } return task; } |
