[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] xenconsoled: Discard guest console data in bigger chunks



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1274944884 -3600
# Node ID 83a3f9556a055fbb8e5484d823e0715573e24f9e
# Parent  5be2d2a7f445bab61617b09627ca7f6a8ec90a69
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@xxxxxxxxxx>
Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
---
 tools/console/daemon/io.c |   31 +++++++++++++++++++------------
 1 files changed, 19 insertions(+), 12 deletions(-)

diff -r 5be2d2a7f445 -r 83a3f9556a05 tools/console/daemon/io.c
--- a/tools/console/daemon/io.c Thu May 27 08:20:26 2010 +0100
+++ b/tools/console/daemon/io.c Thu May 27 08:21:24 2010 +0100
@@ -202,18 +202,25 @@ static void buffer_append(struct domain 
        }
 
        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;
-
-               if (buffer->consumed > buffer->max_capacity - over)
-                       buffer->consumed = buffer->max_capacity - over;
+           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;
+
+                       memmove(buffer->data + buffer->max_capacity / 2,
+                               buffer->data + buffer->max_capacity,
+                               over);
+                       buffer->size = buffer->max_capacity / 2 + over;
+               }
        }
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.