[glib: 1/2] gunix{input|output}stream: Drop custom close_{async|finish}() methods



commit 0a2dc161c02db667e32876fa74a0dcc837ee37a4
Author: Philip Withnall <withnall endlessm com>
Date:   Mon Mar 2 13:52:56 2020 +0000

    gunix{input|output}stream: Drop custom close_{async|finish}() methods
    
    They were not actually asynchronous, and hence caused blocking in the
    main thread. Deleting them means the default implementation of those
    vfuncs is used, which runs the sync implementation in a thread — which
    is what is wanted here.
    
    Spotted by Benjamin Otte.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Fixes: #2051

 gio/gunixinputstream.c  | 41 -----------------------------------------
 gio/gunixoutputstream.c | 41 -----------------------------------------
 2 files changed, 82 deletions(-)
---
diff --git a/gio/gunixinputstream.c b/gio/gunixinputstream.c
index c63e4e50e..796aa546e 100644
--- a/gio/gunixinputstream.c
+++ b/gio/gunixinputstream.c
@@ -103,14 +103,6 @@ static void     g_unix_input_stream_skip_async   (GInputStream         *stream,
 static gssize   g_unix_input_stream_skip_finish  (GInputStream         *stream,
                                                  GAsyncResult         *result,
                                                  GError              **error);
-static void     g_unix_input_stream_close_async  (GInputStream         *stream,
-                                                 int                   io_priority,
-                                                 GCancellable         *cancellable,
-                                                 GAsyncReadyCallback   callback,
-                                                 gpointer              data);
-static gboolean g_unix_input_stream_close_finish (GInputStream         *stream,
-                                                 GAsyncResult         *result,
-                                                 GError              **error);
 
 static gboolean g_unix_input_stream_pollable_can_poll      (GPollableInputStream *stream);
 static gboolean g_unix_input_stream_pollable_is_readable   (GPollableInputStream *stream);
@@ -134,8 +126,6 @@ g_unix_input_stream_class_init (GUnixInputStreamClass *klass)
       stream_class->skip_async = g_unix_input_stream_skip_async;
       stream_class->skip_finish = g_unix_input_stream_skip_finish;
     }
-  stream_class->close_async = g_unix_input_stream_close_async;
-  stream_class->close_finish = g_unix_input_stream_close_finish;
 
   /**
    * GUnixInputStream:fd:
@@ -452,37 +442,6 @@ g_unix_input_stream_skip_finish  (GInputStream  *stream,
   /* TODO: Not implemented */
 }
 
-static void
-g_unix_input_stream_close_async (GInputStream        *stream,
-                                int                  io_priority,
-                                GCancellable        *cancellable,
-                                GAsyncReadyCallback  callback,
-                                gpointer             user_data)
-{
-  GTask *task;
-  GError *error = NULL;
-
-  task = g_task_new (stream, cancellable, callback, user_data);
-  g_task_set_source_tag (task, g_unix_input_stream_close_async);
-  g_task_set_priority (task, io_priority);
-
-  if (g_unix_input_stream_close (stream, cancellable, &error))
-    g_task_return_boolean (task, TRUE);
-  else
-    g_task_return_error (task, error);
-  g_object_unref (task);
-}
-
-static gboolean
-g_unix_input_stream_close_finish (GInputStream  *stream,
-                                 GAsyncResult  *result,
-                                 GError       **error)
-{
-  g_return_val_if_fail (g_task_is_valid (result, stream), FALSE);
-
-  return g_task_propagate_boolean (G_TASK (result), error);
-}
-
 static gboolean
 g_unix_input_stream_pollable_can_poll (GPollableInputStream *stream)
 {
diff --git a/gio/gunixoutputstream.c b/gio/gunixoutputstream.c
index 1af0b44d2..6b2071f7f 100644
--- a/gio/gunixoutputstream.c
+++ b/gio/gunixoutputstream.c
@@ -102,14 +102,6 @@ static gboolean g_unix_output_stream_writev       (GOutputStream        *stream,
 static gboolean g_unix_output_stream_close        (GOutputStream        *stream,
                                                   GCancellable         *cancellable,
                                                   GError              **error);
-static void     g_unix_output_stream_close_async  (GOutputStream        *stream,
-                                                  int                   io_priority,
-                                                  GCancellable         *cancellable,
-                                                  GAsyncReadyCallback   callback,
-                                                  gpointer              data);
-static gboolean g_unix_output_stream_close_finish (GOutputStream        *stream,
-                                                  GAsyncResult         *result,
-                                                  GError              **error);
 
 static gboolean g_unix_output_stream_pollable_can_poll      (GPollableOutputStream *stream);
 static gboolean g_unix_output_stream_pollable_is_writable   (GPollableOutputStream *stream);
@@ -133,8 +125,6 @@ g_unix_output_stream_class_init (GUnixOutputStreamClass *klass)
   stream_class->write_fn = g_unix_output_stream_write;
   stream_class->writev_fn = g_unix_output_stream_writev;
   stream_class->close_fn = g_unix_output_stream_close;
-  stream_class->close_async = g_unix_output_stream_close_async;
-  stream_class->close_finish = g_unix_output_stream_close_finish;
 
    /**
    * GUnixOutputStream:fd:
@@ -539,37 +529,6 @@ g_unix_output_stream_close (GOutputStream  *stream,
   return res != -1;
 }
 
-static void
-g_unix_output_stream_close_async (GOutputStream       *stream,
-                                 int                  io_priority,
-                                 GCancellable        *cancellable,
-                                 GAsyncReadyCallback  callback,
-                                 gpointer             user_data)
-{
-  GTask *task;
-  GError *error = NULL;
-
-  task = g_task_new (stream, cancellable, callback, user_data);
-  g_task_set_source_tag (task, g_unix_output_stream_close_async);
-  g_task_set_priority (task, io_priority);
-
-  if (g_unix_output_stream_close (stream, cancellable, &error))
-    g_task_return_boolean (task, TRUE);
-  else
-    g_task_return_error (task, error);
-  g_object_unref (task);
-}
-
-static gboolean
-g_unix_output_stream_close_finish (GOutputStream  *stream,
-                                  GAsyncResult   *result,
-                                  GError        **error)
-{
-  g_return_val_if_fail (g_task_is_valid (result, stream), FALSE);
-
-  return g_task_propagate_boolean (G_TASK (result), error);
-}
-
 static gboolean
 g_unix_output_stream_pollable_can_poll (GPollableOutputStream *stream)
 {


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