[Spice-devel] [PATCH spice-gtk 6/6] spice-channel: cleanup, remove spice_channel_send_msg()

Hans de Goede hdegoede at redhat.com
Thu Dec 1 07:48:56 PST 2011


There are only 2 callers, both of which want it to do a different thing,
making the callers do this directly allows us to remove
spice_channel_send_msg(); and gets rid of the weirdness where we've a
function which can be called in both co-routine and system context.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 gtk/spice-channel.c |   25 +++++--------------------
 1 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 7878fb4..e9ba21c 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -42,7 +42,7 @@
 #include "gio-coroutine.h"
 
 static void spice_channel_handle_msg(SpiceChannel *channel, SpiceMsgIn *msg);
-static void spice_channel_send_msg(SpiceChannel *channel, SpiceMsgOut *out, gboolean buffered);
+static void spice_channel_write_msg(SpiceChannel *channel, SpiceMsgOut *out);
 static void spice_channel_send_link(SpiceChannel *channel);
 static void channel_disconnect(SpiceChannel *channel);
 
@@ -539,8 +539,10 @@ G_GNUC_INTERNAL
 void spice_msg_out_send(SpiceMsgOut *out)
 {
     g_return_if_fail(out != NULL);
+    g_return_if_fail(out->channel != NULL);
 
-    spice_channel_send_msg(out->channel, out, TRUE);
+    spice_msg_out_ref(out);
+    g_queue_push_tail(&out->channel->priv->xmit_queue, out);
 
     /* TODO: we currently flush/wakeup immediately all buffered messages */
     spice_channel_wakeup(out->channel);
@@ -552,7 +554,7 @@ void spice_msg_out_send_internal(SpiceMsgOut *out)
 {
     g_return_if_fail(out != NULL);
 
-    spice_channel_send_msg(out->channel, out, FALSE);
+    spice_channel_write_msg(out->channel, out);
 }
 
 /* ---------------------------------------------------------------- */
@@ -1565,23 +1567,6 @@ gboolean spice_channel_get_read_only(SpiceChannel *channel)
     return spice_session_get_read_only(channel->priv->session);
 }
 
-/* coroutine context if @buffered is FALSE,
-   system context if @buffered is TRUE */
-static void spice_channel_send_msg(SpiceChannel *channel, SpiceMsgOut *out, gboolean buffered)
-{
-    SpiceChannelPrivate *c = channel->priv;
-
-    g_return_if_fail(channel != NULL);
-    g_return_if_fail(out != NULL);
-
-    if (buffered) {
-        spice_msg_out_ref(out);
-        g_queue_push_tail(&c->xmit_queue, out);
-    } else {
-        spice_channel_write_msg(channel, out);
-    }
-}
-
 /* coroutine context */
 G_GNUC_INTERNAL
 void spice_channel_recv_msg(SpiceChannel *channel,
-- 
1.7.7.4



More information about the Spice-devel mailing list