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.
This commit is contained in:
parent
c56ecc1d56
commit
74e12fcef6
5 changed files with 17 additions and 4 deletions
|
@ -142,3 +142,8 @@ bool
|
||||||
circular_buffer::is_empty() {
|
circular_buffer::is_empty() {
|
||||||
return _unread == 0;
|
return _unread == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t
|
||||||
|
circular_buffer::size() {
|
||||||
|
return _unread;
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
void dequeue(void *dst);
|
void dequeue(void *dst);
|
||||||
uint8_t *peek();
|
uint8_t *peek();
|
||||||
bool is_empty();
|
bool is_empty();
|
||||||
|
size_t size();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Size of the buffer in bytes, should always be a power of two so that
|
// Size of the buffer in bytes, should always be a power of two so that
|
||||||
|
|
|
@ -54,9 +54,9 @@ void rust_port::log_state() {
|
||||||
for (uint32_t i = 0; i < chans.length(); i++) {
|
for (uint32_t i = 0; i < chans.length(); i++) {
|
||||||
rust_chan *chan = chans[i];
|
rust_chan *chan = chans[i];
|
||||||
task->log(rust_log::COMM,
|
task->log(rust_log::COMM,
|
||||||
"\tchan: 0x%" PRIxPTR ", data pending: %s, remote: %s",
|
"\tchan: 0x%" PRIxPTR ", size: %d, remote: %s",
|
||||||
chan,
|
chan,
|
||||||
!chan->buffer.is_empty() ? "yes" : "no",
|
chan->buffer.size(),
|
||||||
chan == remote_channel ? "yes" : "no");
|
chan == remote_channel ? "yes" : "no");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,14 @@ upcall_flush_chan(rust_task *task, rust_chan *chan) {
|
||||||
return;
|
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,
|
A(dom, chan->port->is_proxy() == false,
|
||||||
"Channels to remote ports should be flushed automatically.");
|
"Channels to remote ports should be flushed automatically.");
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ io fn start(chan[chan[str]] c) {
|
||||||
let port[str] p = port();
|
let port[str] p = port();
|
||||||
c <| chan(p);
|
c <| chan(p);
|
||||||
auto a <- p;
|
auto a <- p;
|
||||||
auto b <- p;
|
// auto b <- p; // Never read the second string.
|
||||||
// Never read the second string.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
io fn main() {
|
io fn main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue