diff options
| author | Ben Blum <bblum@andrew.cmu.edu> | 2012-07-12 19:52:27 -0400 |
|---|---|---|
| committer | Ben Blum <bblum@andrew.cmu.edu> | 2012-07-13 20:13:53 -0400 |
| commit | 62575d9c4a26eb2fa0bd1a1dbf1580633a886dce (patch) | |
| tree | f141f61c105f65a58493cec70bd90cae5c454fa3 /src/rt/rust_port.cpp | |
| parent | aad184cc5737671c9c61c774ff4eb3908620857b (diff) | |
| download | rust-62575d9c4a26eb2fa0bd1a1dbf1580633a886dce.tar.gz rust-62575d9c4a26eb2fa0bd1a1dbf1580633a886dce.zip | |
Reintroduce linked failure (rust_port locking)
This reverts commit a10f52c5793b358a16e3e98db4b16c65ba8e254b.
Diffstat (limited to 'src/rt/rust_port.cpp')
| -rw-r--r-- | src/rt/rust_port.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/rt/rust_port.cpp b/src/rt/rust_port.cpp index f1a40508aca..919dadd4044 100644 --- a/src/rt/rust_port.cpp +++ b/src/rt/rust_port.cpp @@ -26,9 +26,11 @@ void rust_port::deref() { scoped_lock with(ref_lock); ref_count--; if (!ref_count) { + // The port owner is waiting for the port to be detached (if it + // hasn't already been killed) + scoped_lock with(task->lifecycle_lock); if (task->blocked_on(&detach_cond)) { - // The port owner is waiting for the port to be detached - task->wakeup(&detach_cond); + task->wakeup_inner(&detach_cond); } } } @@ -64,12 +66,15 @@ void rust_port::send(void *sptr) { assert(!buffer.is_empty() && "rust_chan::transmit with nothing to send."); - if (task->blocked_on(this)) { - KLOG(kernel, comm, "dequeued in rendezvous_ptr"); - buffer.dequeue(task->rendezvous_ptr); - task->rendezvous_ptr = 0; - task->wakeup(this); - did_rendezvous = true; + { + scoped_lock with(task->lifecycle_lock); + if (task->blocked_on(this)) { + KLOG(kernel, comm, "dequeued in rendezvous_ptr"); + buffer.dequeue(task->rendezvous_ptr); + task->rendezvous_ptr = 0; + task->wakeup_inner(this); + did_rendezvous = true; + } } } @@ -78,11 +83,8 @@ void rust_port::send(void *sptr) { // it may be waiting on a group of ports rust_port_selector *port_selector = task->get_port_selector(); - // This check is not definitive. The port selector will take a lock - // and check again whether the task is still blocked. - if (task->blocked_on(port_selector)) { - port_selector->msg_sent_on(this); - } + // The port selector will check if the task is blocked, not us. + port_selector->msg_sent_on(this); } } |
