diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-05-27 08:21:24 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-05-27 08:21:24 +0100 |
commit | 2e5af0a5dc61b0bd0a34def3bbe19b7e799b7a64 (patch) | |
tree | 671c6fb18923bb35b1ec119a174e55aa24e68a32 /tools | |
parent | a705c154283a30d632450773d6ce5e1f307874a7 (diff) | |
download | xen-2e5af0a5dc61b0bd0a34def3bbe19b7e799b7a64.tar.gz xen-2e5af0a5dc61b0bd0a34def3bbe19b7e799b7a64.tar.bz2 xen-2e5af0a5dc61b0bd0a34def3bbe19b7e799b7a64.zip |
xenconsoled: Discard guest console data in bigger chunks
Discard guest console data in bigger chunks so that there are fewer
discontinuities in the console data. Also avoid discarding data if
space is available at the front of the buffer by reclaiming that
space.
Patch from: Christian Limpach <Christian.Limpach@citrix.com>
Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/console/daemon/io.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 5a6ccbfd43..22833d7469 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -202,18 +202,25 @@ static void buffer_append(struct domain *dom) } if (discard_overflowed_data && buffer->max_capacity && - buffer->size > buffer->max_capacity) { - /* Discard the middle of the data. */ - - size_t over = buffer->size - buffer->max_capacity; - char *maxpos = buffer->data + buffer->max_capacity; - - memmove(maxpos - over, maxpos, over); - buffer->data = realloc(buffer->data, buffer->max_capacity); - buffer->size = buffer->capacity = buffer->max_capacity; + buffer->size > 5 * buffer->max_capacity / 4) { + if (buffer->consumed > buffer->max_capacity / 4) { + /* Move data up in buffer, since beginning has + * been output. Only needed because buffer is + * not a ring buffer *sigh* */ + memmove(buffer->data, + buffer->data + buffer->consumed, + buffer->size - buffer->consumed); + buffer->size -= buffer->consumed; + buffer->consumed = 0; + } else { + /* Discard the middle of the data. */ + size_t over = buffer->size - buffer->max_capacity; - if (buffer->consumed > buffer->max_capacity - over) - buffer->consumed = buffer->max_capacity - over; + memmove(buffer->data + buffer->max_capacity / 2, + buffer->data + buffer->max_capacity, + over); + buffer->size = buffer->max_capacity / 2 + over; + } } } |