[Spice-commits] 7 commits - gtk/channel-main.c gtk/continuation.c gtk/continuation.h gtk/coroutine.h gtk/coroutine_gthread.c gtk/coroutine_ucontext.c gtk/coroutine_winfibers.c gtk/gio-coroutine.c gtk/spice-channel-priv.h gtk/spice-channel.c tests/Makefile.am tests/coroutine.c

Marc-André Lureau elmarco at kemper.freedesktop.org
Wed Nov 20 07:32:57 PST 2013


 gtk/channel-main.c        |   17 ++---
 gtk/continuation.c        |    9 +--
 gtk/continuation.h        |    2 
 gtk/coroutine.h           |    9 ++-
 gtk/coroutine_gthread.c   |   20 ++++--
 gtk/coroutine_ucontext.c  |   20 ++----
 gtk/coroutine_winfibers.c |   11 +--
 gtk/gio-coroutine.c       |    2 
 gtk/spice-channel-priv.h  |    3 -
 gtk/spice-channel.c       |   14 +---
 tests/Makefile.am         |   18 +++---
 tests/coroutine.c         |  136 ++++++++++++++++++++++++++++++++++++++++++++++
 12 files changed, 194 insertions(+), 67 deletions(-)

New commits:
commit a7eef2b50f72d024256f00ff5b692fb4f43c5829
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Wed Nov 20 12:25:25 2013 +0100

    main: fix recent main_channel_reset() warning
    
    Fix wrong warning added in 0704147d.
    
    (lt-spicy:17511):
    GSpice-WARNING **: (channel-main.c:415):spice_main_channel_reset:
    runtime check failed: (c->agent_connected == FALSE)

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index ef2a5e5..c747f0e 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -171,6 +171,7 @@ static void file_xfer_continue_read(SpiceFileXferTask *task);
 static void file_xfer_completed(SpiceFileXferTask *task, GError *error);
 static void file_xfer_flushed(SpiceMainChannel *channel, gboolean success);
 static void spice_main_set_max_clipboard(SpiceMainChannel *self, gint max);
+static void set_agent_connected(SpiceMainChannel *channel, gboolean connected);
 
 /* ------------------------------------------------------------------ */
 
@@ -410,10 +411,7 @@ static void spice_main_channel_reset(SpiceChannel *channel, gboolean migrating)
     agent_free_msg_queue(SPICE_MAIN_CHANNEL(channel));
     c->agent_msg_queue = g_queue_new();
 
-    /* check: if agent_connected can be TRUE, it should call instead
-       set_agent_connected() to notify new state */
-    g_warn_if_fail(c->agent_connected == FALSE);
-    spice_main_channel_reset_agent(SPICE_MAIN_CHANNEL(channel));
+    set_agent_connected(SPICE_MAIN_CHANNEL(channel), FALSE);
 
     SPICE_CHANNEL_CLASS(spice_main_channel_parent_class)->channel_reset(channel, migrating);
 }
@@ -1432,6 +1430,10 @@ static void set_agent_connected(SpiceMainChannel *channel, gboolean connected)
         c->agent_connected = connected;
         g_object_notify_main_context(G_OBJECT(channel), "agent-connected");
     }
+    if (!connected)
+        spice_main_channel_reset_agent(SPICE_MAIN_CHANNEL(channel));
+
+    emit_main_context(channel, SPICE_MAIN_AGENT_UPDATE);
 }
 
 /* coroutine context  */
@@ -1443,9 +1445,8 @@ static void agent_start(SpiceMainChannel *channel)
     };
     SpiceMsgOut *out;
 
-    set_agent_connected(channel, TRUE);
     c->agent_caps_received = false;
-    emit_main_context(channel, SPICE_MAIN_AGENT_UPDATE);
+    set_agent_connected(channel, TRUE);
 
     out = spice_msg_out_new(SPICE_CHANNEL(channel), SPICE_MSGC_MAIN_AGENT_START);
     out->marshallers->msgc_main_agent_start(out->marshaller, &agent_start);
@@ -1460,9 +1461,7 @@ static void agent_start(SpiceMainChannel *channel)
 /* coroutine context  */
 static void agent_stopped(SpiceMainChannel *channel)
 {
-    set_agent_connected(channel, FALSE); /* For notify */
-    spice_main_channel_reset_agent(channel);
-    emit_main_context(channel, SPICE_MAIN_AGENT_UPDATE);
+    set_agent_connected(channel, FALSE);
 }
 
 /* coroutine context */
commit 0c120e0f6d94da5b7aa2009e8c07fc1290722c01
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Nov 19 14:57:05 2013 +0100

    coroutine: make gthread coroutine pass tests
    
    The coroutine entry() return value must be passed via the caller->data,
    since coroutine_swap() returns from->data. (this is needed because
    coroutine_swap() argument is used both to return from entry() or to send
    data to a running coroutine)
    
    When leaving a coroutine, clear its caller.
    
    Return correct coroutine_self() before other coroutine are initialized.

diff --git a/gtk/coroutine_gthread.c b/gtk/coroutine_gthread.c
index c2ef1b3..cfeac1a 100644
--- a/gtk/coroutine_gthread.c
+++ b/gtk/coroutine_gthread.c
@@ -74,7 +74,7 @@ static gpointer coroutine_thread(gpointer opaque)
 
 	CO_DEBUG("RUNNABLE");
 	current = co;
-	co->data = co->entry(co->data);
+	co->caller->data = co->entry(co->data);
 	co->exited = 1;
 
 	co->caller->runnable = TRUE;
@@ -128,6 +128,7 @@ void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
 		g_cond_wait(run_cond, run_lock);
 	}
 	current = from;
+	to->caller = NULL;
 
 	CO_DEBUG("SWAPPED");
 	return from->data;
@@ -135,6 +136,9 @@ void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
 
 struct coroutine *coroutine_self(void)
 {
+	if (run_cond == NULL)
+		coroutine_system_init();
+
 	return current;
 }
 
commit 0ea5a6c8dcc0acf5c9c3fcc942779ed572ecdbf5
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Fri Nov 15 21:56:00 2013 +0100

    tests: add some coroutine tests

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9510e2c..6f80d93 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,18 +1,22 @@
 NULL =
 
-noinst_PROGRAMS = util
+noinst_PROGRAMS =				\
+	coroutine				\
+	util					\
+	$(NULL)
+
 TESTS = $(noinst_PROGRAMS)
 
 AM_CPPFLAGS =					\
 	$(GIO_CFLAGS) -I$(top_srcdir)/gtk	\
 	-DG_LOG_DOMAIN=\"GSpice\"		\
 	$(NULL)
-AM_LDFLAGS = $(GIO_LIBS)
 
-util_SOURCES =					\
-	$(top_srcdir)/gtk/spice-util-priv.h	\
-	$(top_srcdir)/gtk/spice-util.c		\
-	$(top_srcdir)/gtk/spice-util.h  	\
-	util.c					\
+AM_LDFLAGS = $(GIO_LIBS) -static
+
+LDADD =							\
+	$(top_builddir)/gtk/libspice-client-glib-2.0.la	\
 	$(NULL)
 
+util_SOURCES = util.c
+coroutine_SOURCES = coroutine.c
diff --git a/tests/coroutine.c b/tests/coroutine.c
new file mode 100644
index 0000000..287b3c9
--- /dev/null
+++ b/tests/coroutine.c
@@ -0,0 +1,136 @@
+#include <glib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "coroutine.h"
+
+static gpointer co_entry_check_self(gpointer data)
+{
+    g_assert(data == coroutine_self());
+    g_assert(!coroutine_self_is_main());
+
+    return NULL;
+}
+
+static gpointer co_entry_42(gpointer data)
+{
+    g_assert(GPOINTER_TO_INT(data) == 42);
+    g_assert(!coroutine_self_is_main());
+
+    return GINT_TO_POINTER(0x42);
+}
+
+static void test_coroutine_simple(void)
+{
+    struct coroutine *self = coroutine_self();
+    struct coroutine co = {
+        .stack_size = 16 << 20,
+        .entry = co_entry_42,
+    };
+    gpointer result;
+
+    g_assert(coroutine_self_is_main());
+
+    coroutine_init(&co);
+    result = coroutine_yieldto(&co, GINT_TO_POINTER(42));
+    g_assert_cmpint(GPOINTER_TO_INT(result), ==, 0x42);
+
+#if GLIB_CHECK_VERSION(2,34,0)
+    g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*!to->exited*");
+    coroutine_yieldto(&co, GINT_TO_POINTER(42));
+    g_test_assert_expected_messages();
+#endif
+
+    g_assert(self == coroutine_self());
+    g_assert(coroutine_self_is_main());
+}
+
+static gpointer co_entry_two(gpointer data)
+{
+    struct coroutine *self = coroutine_self();
+    struct coroutine co = {
+        .stack_size = 16 << 20,
+        .entry = co_entry_check_self,
+    };
+
+    g_assert(!coroutine_self_is_main());
+    coroutine_init(&co);
+    coroutine_yieldto(&co, &co);
+
+    g_assert(self == coroutine_self());
+    return NULL;
+}
+
+static void test_coroutine_two(void)
+{
+    struct coroutine *self = coroutine_self();
+    struct coroutine co = {
+        .stack_size = 16 << 20,
+        .entry = co_entry_two,
+    };
+
+    coroutine_init(&co);
+    coroutine_yieldto(&co, NULL);
+
+    g_assert(self == coroutine_self());
+}
+
+static gpointer co_entry_yield(gpointer data)
+{
+    gpointer val;
+
+    g_assert(data == NULL);
+    val = coroutine_yield(GINT_TO_POINTER(1));
+    g_assert_cmpint(GPOINTER_TO_INT(val), ==, 2);
+
+    g_assert(!coroutine_self_is_main());
+
+    val = coroutine_yield(GINT_TO_POINTER(3));
+    g_assert_cmpint(GPOINTER_TO_INT(val), ==, 4);
+
+    return NULL;
+}
+
+static void test_coroutine_yield(void)
+{
+    struct coroutine *self = coroutine_self();
+    struct coroutine co = {
+        .stack_size = 16 << 20,
+        .entry = co_entry_yield,
+    };
+    gpointer val;
+
+    coroutine_init(&co);
+    val = coroutine_yieldto(&co, NULL);
+
+    g_assert(self == coroutine_self());
+    g_assert_cmpint(GPOINTER_TO_INT(val), ==, 1);
+
+    val = coroutine_yieldto(&co, GINT_TO_POINTER(2));
+
+    g_assert(self == coroutine_self());
+    g_assert_cmpint(GPOINTER_TO_INT(val), ==, 3);
+
+    val = coroutine_yieldto(&co, GINT_TO_POINTER(4));
+
+    g_assert(self == coroutine_self());
+    g_assert(val == NULL);
+
+#if GLIB_CHECK_VERSION(2,34,0)
+    g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, "*!to->exited*");
+    coroutine_yieldto(&co, GINT_TO_POINTER(42));
+    g_test_assert_expected_messages();
+#endif
+}
+
+int main(int argc, char* argv[])
+{
+    g_test_init(&argc, &argv, NULL);
+
+    g_test_add_func("/coroutine/simple", test_coroutine_simple);
+    g_test_add_func("/coroutine/two", test_coroutine_two);
+    g_test_add_func("/coroutine/yield", test_coroutine_yield);
+
+    return g_test_run ();
+}
commit e92c914d2b0a21e994eeecdc836666ca0f35137e
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Nov 19 15:40:18 2013 +0100

    coroutine: replace IN_MAIN_CONTEXT macro
    
    Use a nicer function, with correct prefix.
    Remove extra "context" from function name

diff --git a/gtk/coroutine.h b/gtk/coroutine.h
index adfc338..78dc467 100644
--- a/gtk/coroutine.h
+++ b/gtk/coroutine.h
@@ -55,8 +55,6 @@ struct coroutine
 #endif
 };
 
-#define IN_MAIN_CONTEXT (coroutine_self() == NULL || coroutine_is_main_context(coroutine_self()))
-
 void coroutine_init(struct coroutine *co);
 
 int coroutine_release(struct coroutine *co);
@@ -69,7 +67,11 @@ void *coroutine_yieldto(struct coroutine *to, void *arg);
 
 void *coroutine_yield(void *arg);
 
-gboolean coroutine_is_main_context(struct coroutine *co);
+gboolean coroutine_is_main(struct coroutine *co);
+
+static inline gboolean coroutine_self_is_main(void) {
+	return coroutine_self() == NULL || coroutine_is_main(coroutine_self());
+}
 
 #endif
 /*
diff --git a/gtk/coroutine_gthread.c b/gtk/coroutine_gthread.c
index 367f325..c2ef1b3 100644
--- a/gtk/coroutine_gthread.c
+++ b/gtk/coroutine_gthread.c
@@ -160,7 +160,7 @@ void *coroutine_yield(void *arg)
 	return coroutine_swap(coroutine_self(), to, arg);
 }
 
-gboolean coroutine_is_main_context(struct coroutine *co)
+gboolean coroutine_is_main(struct coroutine *co)
 {
     return (co == &leader);
 }
diff --git a/gtk/coroutine_ucontext.c b/gtk/coroutine_ucontext.c
index 6a5eb54..46899e7 100644
--- a/gtk/coroutine_ucontext.c
+++ b/gtk/coroutine_ucontext.c
@@ -137,7 +137,7 @@ void *coroutine_yield(void *arg)
 	return coroutine_swap(coroutine_self(), to, arg);
 }
 
-gboolean coroutine_is_main_context(struct coroutine *co)
+gboolean coroutine_is_main(struct coroutine *co)
 {
     return (co == &leader);
 }
diff --git a/gtk/coroutine_winfibers.c b/gtk/coroutine_winfibers.c
index 1ed1981..67f10d5 100644
--- a/gtk/coroutine_winfibers.c
+++ b/gtk/coroutine_winfibers.c
@@ -111,7 +111,7 @@ void *coroutine_yield(void *arg)
 	return coroutine_swap(coroutine_self(), to, arg);
 }
 
-gboolean coroutine_is_main_context(struct coroutine *co)
+gboolean coroutine_is_main(struct coroutine *co)
 {
     return (co == &leader);
 }
diff --git a/gtk/gio-coroutine.c b/gtk/gio-coroutine.c
index dd2b9fc..9de9b54 100644
--- a/gtk/gio-coroutine.c
+++ b/gtk/gio-coroutine.c
@@ -252,7 +252,7 @@ void g_object_notify_main_context(GObject *object,
 {
     struct signal_data data;
 
-    if (IN_MAIN_CONTEXT) {
+    if (coroutine_self_is_main()) {
         g_object_notify(object, property_name);
     } else {
 
diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index 351126f..0816061 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -186,7 +186,7 @@ void spice_caps_set(GArray *caps, guint32 cap, const gchar *desc);
 /* coroutine context */
 #define emit_main_context(object, event, args...)                                      \
     G_STMT_START {                                                                     \
-        if (IN_MAIN_CONTEXT) {                                                         \
+        if (coroutine_self_is_main()) {                                 \
             do_emit_main_context(G_OBJECT(object), event, &((struct event) { args })); \
         } else {                                                                       \
             g_signal_emit_main_context(G_OBJECT(object), do_emit_main_context,         \
commit 0508f586be974a49497a15d5ce39b2f94b68a4bf
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Tue Nov 19 15:29:28 2013 +0100

    coroutine: error out on OOM or impossible conditions
    
    Take an approach similar to gthreads, which are considered as low
    level/must work features by glib, which aborts on failures.

diff --git a/gtk/continuation.c b/gtk/continuation.c
index 2891a25..d1249d6 100644
--- a/gtk/continuation.c
+++ b/gtk/continuation.c
@@ -18,6 +18,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 #include <config.h>
+#include <errno.h>
+#include <glib.h>
 
 #undef _FORTIFY_SOURCE
 
@@ -49,13 +51,12 @@ static void continuation_trampoline(int i0, int i1)
 	cc->entry(cc);
 }
 
-int cc_init(struct continuation *cc)
+void cc_init(struct continuation *cc)
 {
 	volatile union cc_arg arg;
 	arg.p = cc;
 	if (getcontext(&cc->uc) == -1)
-		return -1;
-
+		g_error("getcontext() failed: %s", g_strerror(errno));
 	cc->uc.uc_link = &cc->last;
 	cc->uc.uc_stack.ss_sp = cc->stack;
 	cc->uc.uc_stack.ss_size = cc->stack_size;
@@ -63,8 +64,6 @@ int cc_init(struct continuation *cc)
 
 	makecontext(&cc->uc, (void *)continuation_trampoline, 2, arg.i[0], arg.i[1]);
 	swapcontext(&cc->last, &cc->uc);
-
-	return 0;
 }
 
 int cc_release(struct continuation *cc)
diff --git a/gtk/continuation.h b/gtk/continuation.h
index 1247337..675a257 100644
--- a/gtk/continuation.h
+++ b/gtk/continuation.h
@@ -39,7 +39,7 @@ struct continuation
 	jmp_buf jmp;
 };
 
-int cc_init(struct continuation *cc);
+void cc_init(struct continuation *cc);
 
 int cc_release(struct continuation *cc);
 
diff --git a/gtk/coroutine.h b/gtk/coroutine.h
index ef6f3db..adfc338 100644
--- a/gtk/coroutine.h
+++ b/gtk/coroutine.h
@@ -56,7 +56,8 @@ struct coroutine
 };
 
 #define IN_MAIN_CONTEXT (coroutine_self() == NULL || coroutine_is_main_context(coroutine_self()))
-int coroutine_init(struct coroutine *co) G_GNUC_WARN_UNUSED_RESULT;
+
+void coroutine_init(struct coroutine *co);
 
 int coroutine_release(struct coroutine *co);
 
diff --git a/gtk/coroutine_gthread.c b/gtk/coroutine_gthread.c
index ab30631..367f325 100644
--- a/gtk/coroutine_gthread.c
+++ b/gtk/coroutine_gthread.c
@@ -86,8 +86,10 @@ static gpointer coroutine_thread(gpointer opaque)
 	return NULL;
 }
 
-int coroutine_init(struct coroutine *co)
+void coroutine_init(struct coroutine *co)
 {
+	GError *err = NULL;
+
 	if (run_cond == NULL)
 		coroutine_system_init();
 
@@ -95,15 +97,13 @@ int coroutine_init(struct coroutine *co)
 	co->thread = g_thread_create_full(coroutine_thread, co, co->stack_size,
 					  FALSE, TRUE,
 					  G_THREAD_PRIORITY_NORMAL,
-					  NULL);
-	if (co->thread == NULL)
-		return -1;
+					  &err);
+	if (err != NULL)
+		g_error("g_thread_create_full() failed: %s", err->message);
 
 	co->exited = 0;
 	co->runnable = FALSE;
 	co->caller = NULL;
-
-	return 0;
 }
 
 int coroutine_release(struct coroutine *co G_GNUC_UNUSED)
diff --git a/gtk/coroutine_ucontext.c b/gtk/coroutine_ucontext.c
index 4689166..6a5eb54 100644
--- a/gtk/coroutine_ucontext.c
+++ b/gtk/coroutine_ucontext.c
@@ -63,10 +63,8 @@ static void coroutine_trampoline(struct continuation *cc)
 	co->data = co->entry(co->data);
 }
 
-int coroutine_init(struct coroutine *co)
+void coroutine_init(struct coroutine *co)
 {
-	int inited;
-
 	if (co->stack_size == 0)
 		co->stack_size = 16 << 20;
 
@@ -76,20 +74,14 @@ int coroutine_init(struct coroutine *co)
 			    MAP_PRIVATE | MAP_ANONYMOUS,
 			    -1, 0);
 	if (co->cc.stack == MAP_FAILED)
-		g_error("Failed to allocate %u bytes for coroutine stack: %s",
-			(unsigned)co->stack_size, strerror(errno));
+		g_error("mmap(%" G_GSIZE_FORMAT ") failed: %s",
+			co->stack_size, g_strerror(errno));
+
 	co->cc.entry = coroutine_trampoline;
 	co->cc.release = _coroutine_release;
 	co->exited = 0;
 
-	inited = cc_init(&co->cc);
-	if (inited != 0) {
-		munmap(co->cc.stack, co->cc.stack_size);
-		co->cc.stack = NULL;
-		co->exited = 1;
-	}
-
-	return inited;
+	cc_init(&co->cc);
 }
 
 #if 0
diff --git a/gtk/coroutine_winfibers.c b/gtk/coroutine_winfibers.c
index 266b1de..1ed1981 100644
--- a/gtk/coroutine_winfibers.c
+++ b/gtk/coroutine_winfibers.c
@@ -51,20 +51,19 @@ static void WINAPI coroutine_trampoline(LPVOID lpParameter)
 	SwitchToFiber(caller->fiber);
 }
 
-int coroutine_init(struct coroutine *co)
+void coroutine_init(struct coroutine *co)
 {
 	if (leader.fiber == NULL) {
 		leader.fiber = ConvertThreadToFiber(&leader);
 		if (leader.fiber == NULL)
-			return -1;
+			g_error("ConvertThreadToFiber() failed");
 	}
 
 	co->fiber = CreateFiber(0, &coroutine_trampoline, co);
-	co->ret = 0;
 	if (co->fiber == NULL)
-		return -1;
+		g_error("CreateFiber() failed");
 
-	return 0;
+	co->ret = 0;
 }
 
 struct coroutine *coroutine_self(void)
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index 2c8c1b9..a045767 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2366,7 +2366,6 @@ static gboolean connect_delayed(gpointer data)
     SpiceChannel *channel = data;
     SpiceChannelPrivate *c = channel->priv;
     struct coroutine *co;
-    int inited;
 
     CHANNEL_DEBUG(channel, "Open coroutine starting %p", channel);
     c->connect_delayed_id = 0;
@@ -2377,13 +2376,7 @@ static gboolean connect_delayed(gpointer data)
     co->entry = spice_channel_coroutine;
     co->release = NULL;
 
-    inited = coroutine_init(co);
-    if (inited != 0) {
-        g_warning("Failed to initialize channel coroutine");
-        CHANNEL_DEBUG(channel, "coroutine_init failed");
-        g_object_unref(G_OBJECT(channel));
-        return FALSE;
-    }
+    coroutine_init(co);
     coroutine_yieldto(co, channel);
 
     return FALSE;
commit af28d1acd6fd9f10de6f2f45210c81d9b87c6a44
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Fri Nov 15 14:40:10 2013 +0100

    channel: get rid of connection_id, available from session

diff --git a/gtk/spice-channel-priv.h b/gtk/spice-channel-priv.h
index 80a6563..351126f 100644
--- a/gtk/spice-channel-priv.h
+++ b/gtk/spice-channel-priv.h
@@ -113,7 +113,6 @@ struct _SpiceChannelPrivate {
     guint                       channel_watch;
     int                         tls;
 
-    int                         connection_id;
     int                         channel_id;
     int                         channel_type;
     SpiceLinkHeader             link_hdr;
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index b82c305..2c8c1b9 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -130,7 +130,6 @@ static void spice_channel_constructed(GObject *gobject)
     if (disabled && strstr(disabled, desc))
         c->disable_channel_msg = TRUE;
 
-    c->connection_id = spice_session_get_connection_id(c->session);
     spice_session_channel_new(c->session, channel);
 
     /* Chain up to the parent class */
@@ -1136,7 +1135,7 @@ static void spice_channel_send_link(SpiceChannel *channel)
         return;
     }
 
-    c->link_msg.connection_id = c->connection_id;
+    c->link_msg.connection_id = spice_session_get_connection_id(c->session);
     c->link_msg.channel_type  = c->channel_type;
     c->link_msg.channel_id    = c->channel_id;
     c->link_msg.caps_offset   = sizeof(c->link_msg);
commit e13c4c862ab8ad7b959dbf4810d3f5bb96358f95
Author: Marc-André Lureau <marcandre.lureau at redhat.com>
Date:   Mon Nov 18 17:24:08 2013 +0100

    channel: remove useless desc != NULL check
    
    spice_channel_type_to_string() does not return NULL

diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index ccf15d3..b82c305 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -123,7 +123,7 @@ static void spice_channel_constructed(GObject *gobject)
     const char *desc = spice_channel_type_to_string(c->channel_type);
 
     snprintf(c->name, sizeof(c->name), "%s-%d:%d",
-             desc ? desc : "unknown", c->channel_type, c->channel_id);
+             desc, c->channel_type, c->channel_id);
     CHANNEL_DEBUG(channel, "%s", __FUNCTION__);
 
     const char *disabled  = g_getenv("SPICE_DISABLE_CHANNELS");


More information about the Spice-commits mailing list