aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-08-11 16:08:26 -0700
committerMichael Bebenita <[email protected]>2010-08-11 16:08:45 -0700
commit74e12fcef682acdbec6c3f4a3fb29b7583e7d1b6 (patch)
tree73abc23ff1587457b10279bc79d879d2e620f0be /src
parentAdded a -v(algrind) option to run.py. (diff)
downloadrust-74e12fcef682acdbec6c3f4a3fb29b7583e7d1b6.tar.xz
rust-74e12fcef682acdbec6c3f4a3fb29b7583e7d1b6.zip
Ignore upcall_flush for channels that are disassociated from ports. This makes task-comm-10 break a little less hard, but it still leaks because messages pending in the channel are never freed.
Diffstat (limited to 'src')
-rw-r--r--src/rt/circular_buffer.cpp5
-rw-r--r--src/rt/circular_buffer.h1
-rw-r--r--src/rt/rust_port.cpp4
-rw-r--r--src/rt/rust_upcall.cpp8
-rw-r--r--src/test/run-pass/task-comm-10.rs3
5 files changed, 17 insertions, 4 deletions
diff --git a/src/rt/circular_buffer.cpp b/src/rt/circular_buffer.cpp
index dbf5059b..caa95359 100644
--- a/src/rt/circular_buffer.cpp
+++ b/src/rt/circular_buffer.cpp
@@ -142,3 +142,8 @@ bool
circular_buffer::is_empty() {
return _unread == 0;
}
+
+size_t
+circular_buffer::size() {
+ return _unread;
+}
diff --git a/src/rt/circular_buffer.h b/src/rt/circular_buffer.h
index 732ba329..9ddaba42 100644
--- a/src/rt/circular_buffer.h
+++ b/src/rt/circular_buffer.h
@@ -21,6 +21,7 @@ public:
void dequeue(void *dst);
uint8_t *peek();
bool is_empty();
+ size_t size();
private:
// Size of the buffer in bytes, should always be a power of two so that
diff --git a/src/rt/rust_port.cpp b/src/rt/rust_port.cpp
index c97b5d41..fa7790b6 100644
--- a/src/rt/rust_port.cpp
+++ b/src/rt/rust_port.cpp
@@ -54,9 +54,9 @@ void rust_port::log_state() {
for (uint32_t i = 0; i < chans.length(); i++) {
rust_chan *chan = chans[i];
task->log(rust_log::COMM,
- "\tchan: 0x%" PRIxPTR ", data pending: %s, remote: %s",
+ "\tchan: 0x%" PRIxPTR ", size: %d, remote: %s",
chan,
- !chan->buffer.is_empty() ? "yes" : "no",
+ chan->buffer.size(),
chan == remote_channel ? "yes" : "no");
}
}
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index 90d6f6d9..01eaf744 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -116,6 +116,14 @@ upcall_flush_chan(rust_task *task, rust_chan *chan) {
return;
}
+ // We cannot flush if the target port was dropped.
+ if (chan->is_associated() == false) {
+ return;
+ }
+
+ A(dom, chan->is_associated(),
+ "Channel should be associated to a port.");
+
A(dom, chan->port->is_proxy() == false,
"Channels to remote ports should be flushed automatically.");
diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs
index 529ef6f5..4cdcf18b 100644
--- a/src/test/run-pass/task-comm-10.rs
+++ b/src/test/run-pass/task-comm-10.rs
@@ -2,8 +2,7 @@ io fn start(chan[chan[str]] c) {
let port[str] p = port();
c <| chan(p);
auto a <- p;
- auto b <- p;
- // Never read the second string.
+ // auto b <- p; // Never read the second string.
}
io fn main() {