[Spice-devel] [PATCH 01/24] server/red_channel: add out_bytes_counter (unused)

Alon Levy alevy at redhat.com
Wed Jan 19 10:07:47 PST 2011


---
 server/red_channel.c |    3 +++
 server/red_channel.h |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index a13ef0e..584b92e 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include "stat.h"
 #include "red_channel.h"
 
 static void red_channel_push(RedChannel *channel);
@@ -172,6 +173,7 @@ static void red_peer_handle_outgoing(RedsStreamContext *peer, OutgoingHandler *h
             }
         } else {
             handler->pos += n;
+            stat_inc_counter(handler->out_bytes_counter, n);
             if (handler->pos == handler->size) { // finished writing data
                 handler->on_msg_done(handler->opaque);
                 handler->vec = handler->vec_buf;
@@ -285,6 +287,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer,
     channel->outgoing.opaque = channel;
     channel->outgoing.pos = 0;
     channel->outgoing.size = 0;
+    channel->outgoing.out_bytes_counter = NULL;
 
     channel->outgoing.get_msg_size = red_channel_peer_get_out_msg_size;
     channel->outgoing.prepare = red_channel_peer_prepare_out_msg;
diff --git a/server/red_channel.h b/server/red_channel.h
index 893a7f8..e8ebb05 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -77,6 +77,9 @@ typedef struct OutgoingHandler {
     on_outgoing_error_proc on_error;
     on_outgoing_block_proc on_block;
     on_outgoing_msg_done_proc on_msg_done;
+#ifdef RED_STATISTICS
+    uint64_t *out_bytes_counter;
+#endif
 } OutgoingHandler;
 
 /* Red Channel interface */
-- 
1.7.3.4



More information about the Spice-devel mailing list