[Spice-commits] src/vmcstream.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 22 12:38:59 UTC 2019


 src/vmcstream.c |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 69e90462855ac74de2ffae5484efc48a4b99d0ff
Author: Jakub Janků <jjanku at redhat.com>
Date:   Tue Aug 20 16:05:46 2019 +0200

    vmcstream: fix task cancellation
    
    If the task is cancelled, g_task_propagate_pointer()
    in spice_vmc_output_stream_write_finish() returns NULL
    which produces following errors:
    
        (spicy:13597): GSpice-CRITICAL **: 15:39:46.168: spice_vmc_write_finish: assertion 'result != NULL' failed
    
        (spicy:13597): GLib-GObject-CRITICAL **: 15:39:46.168: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
    
    To fix this, call spice_vmc_write_finish() immediately in the
    corresponding write_cb().
    
    Signed-off-by: Jakub Janků <jjanku at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/vmcstream.c b/src/vmcstream.c
index b6f6d1a..b7da103 100644
--- a/src/vmcstream.c
+++ b/src/vmcstream.c
@@ -397,18 +397,11 @@ spice_vmc_output_stream_write_fn(GOutputStream   *stream,
 
 static gssize
 spice_vmc_output_stream_write_finish(GOutputStream *stream,
-                                     GAsyncResult *simple,
+                                     GAsyncResult *result,
                                      GError **error)
 {
-    SpiceVmcOutputStream *self = SPICE_VMC_OUTPUT_STREAM(stream);
-    GAsyncResult *res = g_task_propagate_pointer(G_TASK(simple), error);
-    gssize bytes_written;
-
-    SPICE_DEBUG("spicevmc write finish");
-    bytes_written = spice_vmc_write_finish(self->channel, res, error);
-    g_object_unref(res);
-
-    return bytes_written;
+    g_return_val_if_fail(g_task_is_valid(result, stream), -1);
+    return g_task_propagate_int(G_TASK(result), error);
 }
 
 static void
@@ -417,9 +410,17 @@ write_cb(GObject *source_object,
          gpointer user_data)
 {
     GTask *task = user_data;
+    GError *error = NULL;
+    gssize bytes_written;
 
-    g_task_return_pointer(task, g_object_ref(res), g_object_unref);
+    SPICE_DEBUG("spicevmc write finish");
+    bytes_written = spice_vmc_write_finish(SPICE_CHANNEL(source_object), res, &error);
 
+    if (error) {
+        g_task_return_error(task, error);
+    } else {
+        g_task_return_int(task, bytes_written);
+    }
     g_object_unref(task);
 }
 


More information about the Spice-commits mailing list