[Spice-devel] [PATCH 09/23] server/red_channel: add public red_channel_default_peer_on_error

Alon Levy alevy at redhat.com
Mon Feb 7 09:31:11 PST 2011


for later use in red_worker
---
 server/red_channel.c |    8 +++-----
 server/red_channel.h |    2 ++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index ebb181c..717da02 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -185,10 +185,8 @@ static void red_peer_handle_outgoing(RedsStreamContext *peer, OutgoingHandler *h
     }
 }
 
-static void red_channel_peer_on_error(void *opaque)
+void red_channel_default_peer_on_error(RedChannel *channel)
 {
-    RedChannel *channel = (RedChannel *)opaque;
-
     channel->disconnect(channel);
 }
 
@@ -286,7 +284,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer,
     channel->incoming.alloc_msg_buf = (alloc_msg_recv_buf_proc)alloc_recv_buf;
     channel->incoming.release_msg_buf = (release_msg_recv_buf_proc)release_recv_buf;
     channel->incoming.handle_message = (handle_message_proc)handle_message;
-    channel->incoming.on_error = red_channel_peer_on_error;
+    channel->incoming.on_error = (on_incoming_error_proc)red_channel_default_peer_on_error;
 
     channel->outgoing.opaque = channel;
     channel->outgoing.pos = 0;
@@ -296,7 +294,7 @@ RedChannel *red_channel_create(int size, RedsStreamContext *peer,
     channel->outgoing.get_msg_size = red_channel_peer_get_out_msg_size;
     channel->outgoing.prepare = red_channel_peer_prepare_out_msg;
     channel->outgoing.on_block = red_channel_peer_on_out_block;
-    channel->outgoing.on_error = red_channel_peer_on_error;
+    channel->outgoing.on_error = (on_outgoing_error_proc)red_channel_default_peer_on_error;
     channel->outgoing.on_msg_done = red_channel_peer_on_out_msg_done;
 
     channel->shut = 0; // came here from inputs, perhaps can be removed? XXX
diff --git a/server/red_channel.h b/server/red_channel.h
index 7c973fd..5135970 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -200,6 +200,8 @@ void red_channel_init_outgoing_messages_window(RedChannel *channel);
 int red_channel_handle_message(RedChannel *channel, uint32_t size,
                                uint16_t type, void *message);
 
+/* default error handler that disconnects channel */
+void red_channel_default_peer_on_error(RedChannel *channel);
 
 /* when preparing send_data: should call reset, then init and then add_buf per buffer that is
    being sent */
-- 
1.7.4



More information about the Spice-devel mailing list