aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rt/circular_buffer.cpp2
-rw-r--r--src/test/run-pass/chan-poweroftwo.rs14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/rt/circular_buffer.cpp b/src/rt/circular_buffer.cpp
index bdf25124..77509abb 100644
--- a/src/rt/circular_buffer.cpp
+++ b/src/rt/circular_buffer.cpp
@@ -62,7 +62,7 @@ circular_buffer::enqueue(void *src) {
I(dom, _unread <= _buffer_sz);
// Grow if necessary.
- if (_unread == _buffer_sz) {
+ if (_unread + unit_sz > _buffer_sz) {
size_t new_buffer_sz = _buffer_sz << 1;
I(dom, new_buffer_sz <= MAX_CIRCULAR_BUFFFER_SIZE);
void *new_buffer = dom->malloc(new_buffer_sz);
diff --git a/src/test/run-pass/chan-poweroftwo.rs b/src/test/run-pass/chan-poweroftwo.rs
index fc05d7cc..f3a4b9b5 100644
--- a/src/test/run-pass/chan-poweroftwo.rs
+++ b/src/test/run-pass/chan-poweroftwo.rs
@@ -25,8 +25,22 @@ impure fn test_init() {
mychan <| val;
}
+// Dump lots of items into the channel so it has to grow.
+// Don't trigger any assertions.
+impure fn test_grow() {
+ let port[record] myport = port();
+ auto mychan = chan(myport);
+
+ let record val = rec(val1=0i32, val2=0i32, val3=0i32);
+
+ for each (uint i in _uint.range(0u, 100u)) {
+ mychan <| val;
+ }
+}
+
impure fn main() {
test_init();
+ test_grow();
}
// Local Variables: