diff options
Diffstat (limited to 'src/rt')
| -rw-r--r-- | src/rt/circular_buffer.cpp | 5 | ||||
| -rw-r--r-- | src/rt/circular_buffer.h | 1 | ||||
| -rw-r--r-- | src/rt/rust_port.cpp | 4 | ||||
| -rw-r--r-- | src/rt/rust_upcall.cpp | 8 |
4 files changed, 16 insertions, 2 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."); |