[Spice-devel] [PATCH 21/26] server/red_channel: add red_channel_disconnect, use in red_worker

Alon Levy alevy at redhat.com
Fri Feb 11 09:49:06 PST 2011


replace channel_release_res in red_worker with red_channel_disconnect.
---
 server/red_channel.c |   10 ++++++++++
 server/red_channel.h |    2 ++
 server/red_worker.c  |   18 +-----------------
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/server/red_channel.c b/server/red_channel.c
index 4d6a147..55845b4 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -738,3 +738,13 @@ int red_channel_no_item_being_sent(RedChannel *channel)
     return channel->send_data.item == NULL;
 }
 
+void red_channel_disconnect(RedChannel *channel)
+{
+    red_channel_pipe_clear(channel);
+    // TODO: clear our references from the pipe
+    channel->peer->cb_free(channel->peer);
+    channel->peer = NULL;
+    channel->send_data.blocked = FALSE;
+    channel->send_data.size = 0;
+}
+
diff --git a/server/red_channel.h b/server/red_channel.h
index 02f81fc..e27ed81 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -288,5 +288,7 @@ void red_channel_pipe_clear(RedChannel *channel);
 //  handle_channel_events - this is the only one that was used before, and was in red_channel.c
 void red_channel_receive(RedChannel *channel);
 void red_channel_send(RedChannel *channel);
+// For red_worker
+void red_channel_disconnect(RedChannel *channel);
 
 #endif
diff --git a/server/red_worker.c b/server/red_worker.c
index a7bf32a..131da7e 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -7183,15 +7183,6 @@ static inline void red_marshall_qxl_drawable(RedWorker *worker, DisplayChannel *
     }
 }
 
-static void inline channel_release_res(RedChannel *channel)
-{
-    if (!channel->send_data.item) {
-        return;
-    }
-    channel->release_item(channel, channel->send_data.item, FALSE);
-    channel->send_data.item = NULL;
-}
-
 static void display_channel_push_release(DisplayChannel *channel, uint8_t type, uint64_t id,
                                          uint64_t* sync_data)
 {
@@ -8269,14 +8260,7 @@ void red_show_tree(RedWorker *worker)
 // TODO: move to red_channel
 static void red_disconnect_channel(RedChannel *channel)
 {
-    channel_release_res(channel);
-    red_channel_pipe_clear(channel);
-
-    channel->peer->cb_free(channel->peer);
-
-    channel->peer = NULL;
-    channel->send_data.blocked = FALSE;
-    channel->send_data.size = 0;
+    red_channel_disconnect(channel);
     red_unref_channel(channel);
 }
 
-- 
1.7.4



More information about the Spice-devel mailing list