Skip to content

Commit e962951

Browse files
brsongraydon
authored andcommitted
---
yaml --- r: 1213 b: refs/heads/master c: 5f05ae6 h: refs/heads/master i: 1211: 500aef3 v: v3
1 parent 51c8dcc commit e962951

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 04056d89c831767f3c71a0cc274e7c17b5721734
2+
refs/heads/master: 5f05ae68e555e94aa31c36b35dfb2e03952443ba

trunk/src/rt/circular_buffer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,15 @@ circular_buffer::dequeue(void *dst) {
121121
}
122122

123123
// Shrink if possible.
124-
if (_buffer_sz >= INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz &&
124+
if (_buffer_sz > INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz &&
125125
_unread <= _buffer_sz / 4) {
126126
dom->log(rust_log::MEM | rust_log::COMM,
127127
"circular_buffer is shrinking to %d bytes", _buffer_sz / 2);
128128
void *tmp = dom->malloc(_buffer_sz / 2);
129129
transfer(tmp);
130130
_buffer_sz >>= 1;
131+
I(dom, _buffer_sz >=
132+
next_power_of_two(INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz));
131133
dom->free(_buffer);
132134
_buffer = (uint8_t *)tmp;
133135
_next = 0;

trunk/src/test/run-pass/chan-poweroftwo.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,19 @@ impure fn test_grow() {
3838
}
3939
}
4040

41+
// Don't allow the buffer to shrink below it's original size
42+
impure fn test_shrink() {
43+
let port[i8] myport = port();
44+
auto mychan = chan(myport);
45+
46+
mychan <| 0i8;
47+
auto x <- myport;
48+
}
49+
4150
impure fn main() {
4251
test_init();
4352
test_grow();
53+
test_shrink();
4454
}
4555

4656
// Local Variables:

0 commit comments

Comments
 (0)