[glib/wip/carlosg/cancelled-splice: 1/2] goutputstream: Check cancellable state after splice




commit 594bb6a69987ca56e58dee5f58a7a32df0ed71bc
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Aug 24 12:00:44 2020 +0200

    goutputstream: Check cancellable state after splice
    
    After a splice operation is finished, it attempts to 1) close input/output
    streams, as per the given flags, and 2) return the operation result (maybe
    an error, too).
    
    Neither bode well if a splice operation is cancelled early though, the
    close operations borrow the already cancelled cancellable, and returning
    the operation result is oblivious that the operation may already be in
    an error state. This may go silent, or result in:
    
    GLib-GIO-FATAL-CRITICAL: g_task_return_error: assertion '!task->ever_returned' failed
    
    Fix both things by checking early the cancellable state. Streams still go
    unclosed (which probably makes sense after all, since the operation was
    cancelled), but the task is not assumed to be in an unfinished state overall.
    
    This error triggers a semi-frequent CI failure in tracker, see the summary at
    https://gitlab.gnome.org/GNOME/tracker/-/issues/240

 gio/goutputstream.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/gio/goutputstream.c b/gio/goutputstream.c
index 87b61a4ec..833e5e48d 100644
--- a/gio/goutputstream.c
+++ b/gio/goutputstream.c
@@ -2717,6 +2717,12 @@ real_splice_async_complete (GTask *task)
   SpliceData *op = g_task_get_task_data (task);
   gboolean done = TRUE;
 
+  if (g_task_return_error_if_cancelled (task))
+    {
+      g_object_unref (task);
+      return;
+    }
+
   if (op->flags & G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE)
     {
       done = FALSE;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]