File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 04056d89c831767f3c71a0cc274e7c17b5721734
2
+ refs/heads/master: 5f05ae68e555e94aa31c36b35dfb2e03952443ba
Original file line number Diff line number Diff line change @@ -121,13 +121,15 @@ circular_buffer::dequeue(void *dst) {
121
121
}
122
122
123
123
// 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 &&
125
125
_unread <= _buffer_sz / 4 ) {
126
126
dom->log (rust_log::MEM | rust_log::COMM,
127
127
" circular_buffer is shrinking to %d bytes" , _buffer_sz / 2 );
128
128
void *tmp = dom->malloc (_buffer_sz / 2 );
129
129
transfer (tmp);
130
130
_buffer_sz >>= 1 ;
131
+ I (dom, _buffer_sz >=
132
+ next_power_of_two (INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS * unit_sz));
131
133
dom->free (_buffer);
132
134
_buffer = (uint8_t *)tmp;
133
135
_next = 0 ;
Original file line number Diff line number Diff line change @@ -38,9 +38,19 @@ impure fn test_grow() {
38
38
}
39
39
}
40
40
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
+
41
50
impure fn main ( ) {
42
51
test_init ( ) ;
43
52
test_grow ( ) ;
53
+ test_shrink ( ) ;
44
54
}
45
55
46
56
// Local Variables:
You can’t perform that action at this time.
0 commit comments