diff options
| author | Eric Holk <eholk@mozilla.com> | 2011-06-21 15:10:55 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-06-27 09:58:39 -0700 |
| commit | 4d99bf9af2107523c01566968e889c4f1a5de49e (patch) | |
| tree | 8d7fb27687d58be9bd8f6f907b914da4e76fced3 /src/rt/rust_chan.cpp | |
| parent | cb00befff050e69565d2862b458bbd56f20b7cd3 (diff) | |
| download | rust-4d99bf9af2107523c01566968e889c4f1a5de49e.tar.gz rust-4d99bf9af2107523c01566968e889c4f1a5de49e.zip | |
Added some locking to ports to prevent the case where two threads simultaneously wake up a task blocked on a certain port.
Diffstat (limited to 'src/rt/rust_chan.cpp')
| -rw-r--r-- | src/rt/rust_chan.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp index fdc7f2704d3..4349794e658 100644 --- a/src/rt/rust_chan.cpp +++ b/src/rt/rust_chan.cpp @@ -31,6 +31,7 @@ rust_chan::~rust_chan() { void rust_chan::associate(maybe_proxy<rust_port> *port) { this->port = port; if (port->is_proxy() == false) { + scoped_lock sync(port->referent()->lock); LOG(task, task, "associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR, this, port); @@ -49,6 +50,7 @@ void rust_chan::disassociate() { A(task->dom, is_associated(), "Channel must be associated with a port."); if (port->is_proxy() == false) { + scoped_lock sync(port->referent()->lock); LOG(task, task, "disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR, this, port->referent()); @@ -81,6 +83,7 @@ void rust_chan::send(void *sptr) { buffer.dequeue(NULL); } else { rust_port *target_port = port->referent(); + scoped_lock sync(target_port->lock); if (target_port->task->blocked_on(target_port)) { DLOG(dom, comm, "dequeued in rendezvous_ptr"); buffer.dequeue(target_port->task->rendezvous_ptr); |
