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
@ -142,3 +142,8 @@ bool
|
||||
circular_buffer::is_empty() {
|
||||
return _unread == 0;
|
||||
}
|
||||
|
||||
size_t
|
||||
circular_buffer::size() {
|
||||
return _unread;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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.");
|
||||
|
||||
|
@ -2,8 +2,7 @@
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user