about summary refs log tree commit diff
path: root/src/rt/rust_port.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-11-13 16:38:34 -0800
committerBrian Anderson <banderson@mozilla.com>2011-11-13 16:38:34 -0800
commitf619d5e9e2461c1ef3fb53cbbff325cfb04fb181 (patch)
tree4b9cce0565bf254e6dfe57387700c3c21049841c /src/rt/rust_port.cpp
parent58e923de6ef89f252f350d0d89f7b13798b517bd (diff)
downloadrust-f619d5e9e2461c1ef3fb53cbbff325cfb04fb181.tar.gz
rust-f619d5e9e2461c1ef3fb53cbbff325cfb04fb181.zip
rt: Add locking invariants to rust_port
Diffstat (limited to 'src/rt/rust_port.cpp')
-rw-r--r--src/rt/rust_port.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/rt/rust_port.cpp b/src/rt/rust_port.cpp
index ff743eeeb40..84cbb02e83b 100644
--- a/src/rt/rust_port.cpp
+++ b/src/rt/rust_port.cpp
@@ -22,8 +22,7 @@ rust_port::~rust_port() {
 }
 
 void rust_port::send(void *sptr) {
-    // FIXME: Is this lock really necessary? Why do we send with the lock
-    // but not receive with the lock?
+    I(task->sched, !lock.lock_held_by_current_thread());
     scoped_lock with(lock);
 
     buffer.enqueue(sptr);
@@ -40,6 +39,7 @@ void rust_port::send(void *sptr) {
 }
 
 bool rust_port::receive(void *dptr) {
+    I(task->sched, lock.lock_held_by_current_thread());
     if (buffer.is_empty() == false) {
         buffer.dequeue(dptr);
         LOG(task, comm, "<=== read data ===");
@@ -49,6 +49,7 @@ bool rust_port::receive(void *dptr) {
 }
 
 size_t rust_port::size() {
+    I(task->sched, !lock.lock_held_by_current_thread());
     scoped_lock with(lock);
     return buffer.size();
 }