Blame SOURCES/0017-red_channel-add-on_input-callback-for-tracing-incomi.patch

20333d
From af5b26baa47ced2f5e4822b66fb102e82f885e9a Mon Sep 17 00:00:00 2001
20333d
From: Yonit Halperin <yhalperi@redhat.com>
20333d
Date: Wed, 14 Aug 2013 09:38:12 -0400
20333d
Subject: [PATCH] red_channel: add on_input callback for tracing incoming bytes
20333d
20333d
The callback will be used in the next patch.
20333d
20333d
https://bugzilla.redhat.com/show_bug.cgi?id=1016790
20333d
(cherry picked from commit d1e7142a0f90e2b977d2a73d26dc5b09d7771826)
20333d
---
20333d
 server/red_channel.c | 7 +++++++
20333d
 server/red_channel.h | 2 ++
20333d
 2 files changed, 9 insertions(+)
20333d
20333d
diff --git a/server/red_channel.c b/server/red_channel.c
20333d
index 228669b..bc6ac8d 100644
20333d
--- a/server/red_channel.c
20333d
+++ b/server/red_channel.c
20333d
@@ -244,6 +244,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
20333d
                 handler->cb->on_error(handler->opaque);
20333d
                 return;
20333d
             }
20333d
+            handler->cb->on_input(handler->opaque, bytes_read);
20333d
             handler->header_pos += bytes_read;
20333d
 
20333d
             if (handler->header_pos != handler->header.header_size) {
20333d
@@ -271,6 +272,7 @@ static void red_peer_handle_incoming(RedsStream *stream, IncomingHandler *handle
20333d
                 handler->cb->on_error(handler->opaque);
20333d
                 return;
20333d
             }
20333d
+            handler->cb->on_input(handler->opaque, bytes_read);
20333d
             handler->msg_pos += bytes_read;
20333d
             if (handler->msg_pos != msg_size) {
20333d
                 return;
20333d
@@ -383,6 +385,10 @@ static void red_channel_client_on_output(void *opaque, int n)
20333d
     stat_inc_counter(rcc->channel->out_bytes_counter, n);
20333d
 }
20333d
 
20333d
+static void red_channel_client_on_input(void *opaque, int n)
20333d
+{
20333d
+}
20333d
+
20333d
 static void red_channel_client_default_peer_on_error(RedChannelClient *rcc)
20333d
 {
20333d
     red_channel_client_disconnect(rcc);
20333d
@@ -919,6 +925,7 @@ RedChannel *red_channel_create(int size,
20333d
     channel->incoming_cb.handle_message = (handle_message_proc)handle_message;
20333d
     channel->incoming_cb.on_error =
20333d
         (on_incoming_error_proc)red_channel_client_default_peer_on_error;
20333d
+    channel->incoming_cb.on_input = red_channel_client_on_input;
20333d
     channel->outgoing_cb.get_msg_size = red_channel_client_peer_get_out_msg_size;
20333d
     channel->outgoing_cb.prepare = red_channel_client_peer_prepare_out_msg;
20333d
     channel->outgoing_cb.on_block = red_channel_client_peer_on_out_block;
20333d
diff --git a/server/red_channel.h b/server/red_channel.h
20333d
index fa11505..64befff 100644
20333d
--- a/server/red_channel.h
20333d
+++ b/server/red_channel.h
20333d
@@ -74,6 +74,7 @@ typedef uint8_t *(*alloc_msg_recv_buf_proc)(void *opaque, uint16_t type, uint32_
20333d
 typedef void (*release_msg_recv_buf_proc)(void *opaque,
20333d
                                           uint16_t type, uint32_t size, uint8_t *msg);
20333d
 typedef void (*on_incoming_error_proc)(void *opaque);
20333d
+typedef void (*on_input_proc)(void *opaque, int n);
20333d
 
20333d
 typedef struct IncomingHandlerInterface {
20333d
     handle_message_proc handle_message;
20333d
@@ -83,6 +84,7 @@ typedef struct IncomingHandlerInterface {
20333d
     // The following is an optional alternative to handle_message, used if not null
20333d
     spice_parse_channel_func_t parser;
20333d
     handle_parsed_proc handle_parsed;
20333d
+    on_input_proc on_input;
20333d
 } IncomingHandlerInterface;
20333d
 
20333d
 typedef struct IncomingHandler {