[libsoup] Delete SoupSessionSync



commit 5dd1d1991d476f44180e2f177e06a6477100e530
Author: Patrick Griffis <pgriffis igalia com>
Date:   Thu Mar 12 19:10:57 2020 -0700

    Delete SoupSessionSync

 docs/reference/libsoup-2.4-sections.txt        |  17 ----
 libsoup/content-sniffer/soup-content-decoder.c |   3 +-
 libsoup/include/soup-installed.h               |   1 -
 libsoup/meson.build                            |   2 -
 libsoup/soup-autocleanups.h                    |   1 -
 libsoup/soup-message-client-io.c               |  10 +-
 libsoup/soup-message-io.c                      |  14 +--
 libsoup/soup-message.c                         |   5 +-
 libsoup/soup-request-http.c                    |   2 -
 libsoup/soup-request.c                         |   3 -
 libsoup/soup-session-sync.c                    | 132 -------------------------
 libsoup/soup-session-sync.h                    |  60 -----------
 libsoup/soup-session.c                         |  95 +-----------------
 libsoup/soup-types.h                           |   1 -
 libsoup/soup.h                                 |   1 -
 tests/test-utils.c                             |  48 ++-------
 tests/test-utils.h                             |   2 -
 17 files changed, 20 insertions(+), 377 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index fe00bf3b..2bbc3294 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -519,23 +519,6 @@ SoupSessionAsyncClass
 soup_session_async_get_type
 </SECTION>
 
-<SECTION>
-<FILE>soup-session-sync</FILE>
-<TITLE>SoupSessionSync</TITLE>
-SoupSessionSync
-soup_session_sync_new
-soup_session_sync_new_with_options
-<SUBSECTION Standard>
-SOUP_IS_SESSION_SYNC
-SOUP_IS_SESSION_SYNC_CLASS
-SOUP_SESSION_SYNC
-SOUP_SESSION_SYNC_CLASS
-SOUP_SESSION_SYNC_GET_CLASS
-SOUP_TYPE_SESSION_SYNC
-SoupSessionSyncClass
-soup_session_sync_get_type
-</SECTION>
-
 <SECTION>
 <FILE>soup-session-feature</FILE>
 <TITLE>SoupSessionFeature</TITLE>
diff --git a/libsoup/content-sniffer/soup-content-decoder.c b/libsoup/content-sniffer/soup-content-decoder.c
index a9b9e768..c0155786 100644
--- a/libsoup/content-sniffer/soup-content-decoder.c
+++ b/libsoup/content-sniffer/soup-content-decoder.c
@@ -27,8 +27,7 @@
  * incoming ones. Currently it supports the "gzip", "deflate", and "br"
  * content codings.
  *
- * If you are using a plain #SoupSession (ie, not #SoupSessionAsync or
- * #SoupSessionSync), then a #SoupContentDecoder will automatically be
+ * A #SoupContentDecoder will automatically be
  * added to the session by default. (You can use
  * %SOUP_SESSION_REMOVE_FEATURE_BY_TYPE at construct time if you don't
  * want this.) If you are using one of the deprecated #SoupSession
diff --git a/libsoup/include/soup-installed.h b/libsoup/include/soup-installed.h
index 56fa31fe..0743301d 100644
--- a/libsoup/include/soup-installed.h
+++ b/libsoup/include/soup-installed.h
@@ -44,7 +44,6 @@ extern "C" {
 #include <libsoup/soup-server.h>
 #include <libsoup/soup-session-async.h>
 #include <libsoup/soup-session-feature.h>
-#include <libsoup/soup-session-sync.h>
 #include <libsoup/soup-socket.h>
 #include <libsoup/soup-status.h>
 #include <libsoup/soup-tld.h>
diff --git a/libsoup/meson.build b/libsoup/meson.build
index ac7f6b84..3c859d95 100644
--- a/libsoup/meson.build
+++ b/libsoup/meson.build
@@ -81,7 +81,6 @@ soup_sources = [
   'soup-session.c',
   'soup-session-async.c',
   'soup-session-feature.c',
-  'soup-session-sync.c',
   'soup-socket.c',
   'soup-socket-properties.c',
   'soup-status.c',
@@ -180,7 +179,6 @@ soup_introspection_headers = [
   'soup-session.h',
   'soup-session-async.h',
   'soup-session-feature.h',
-  'soup-session-sync.h',
   'soup-socket.h',
   'soup-status.h',
   'soup-tld.h',
diff --git a/libsoup/soup-autocleanups.h b/libsoup/soup-autocleanups.h
index 1895eb0c..18b5c72e 100644
--- a/libsoup/soup-autocleanups.h
+++ b/libsoup/soup-autocleanups.h
@@ -55,7 +55,6 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupServer, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSession, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionAsync, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionFeature, g_object_unref)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSessionSync, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSocket, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupURI, soup_uri_free)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupWebsocketConnection, g_object_unref)
diff --git a/libsoup/soup-message-client-io.c b/libsoup/soup-message-client-io.c
index 1a60360f..9fba1958 100644
--- a/libsoup/soup-message-client-io.c
+++ b/libsoup/soup-message-client-io.c
@@ -146,12 +146,10 @@ soup_message_send_request (SoupMessageQueueItem      *item,
        GMainContext *async_context;
        GIOStream *iostream;
 
-       if (!SOUP_IS_SESSION_SYNC (item->session)) {
-               async_context = soup_session_get_async_context (item->session);
-               if (!async_context)
-                       async_context = g_main_context_default ();
-       } else
-               async_context = NULL;
+        async_context = soup_session_get_async_context (item->session);
+        if (!async_context)
+                async_context = g_main_context_default ();
+
        iostream = soup_socket_get_iostream (soup_connection_get_socket (item->conn));
 
        soup_message_io_client (item, iostream, async_context,
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index 1a15d004..78578acc 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -568,13 +568,11 @@ io_write (SoupMessage *msg, gboolean blocking,
                                g_clear_object (&io->body_ostream);
                        } else {
                                io->async_close_wait = g_cancellable_new ();
-                               if (io->async_context)
-                                       g_main_context_push_thread_default (io->async_context);
+                               g_main_context_push_thread_default (io->async_context);
                                g_output_stream_close_async (io->body_ostream,
                                                             G_PRIORITY_DEFAULT, cancellable,
                                                             closed_async, g_object_ref (msg));
-                               if (io->async_context)
-                                       g_main_context_pop_thread_default (io->async_context);
+                               g_main_context_pop_thread_default (io->async_context);
                        }
                }
 
@@ -1200,9 +1198,7 @@ new_iostate (SoupMessage *msg, GIOStream *iostream,
        io->iostream = g_object_ref (iostream);
        io->istream = SOUP_FILTER_INPUT_STREAM (g_io_stream_get_input_stream (iostream));
        io->ostream = g_io_stream_get_output_stream (iostream);
-
-       if (async_context)
-               io->async_context = g_main_context_ref (async_context);
+       io->async_context = g_main_context_ref (async_context);
 
        io->read_header_buf = g_byte_array_new ();
        io->write_buf       = g_string_new (NULL);
@@ -1248,9 +1244,7 @@ soup_message_io_client (SoupMessageQueueItem *item,
        io->write_state     = SOUP_MESSAGE_IO_STATE_HEADERS;
 
        if (!item->new_api) {
-               gboolean blocking =
-                       SOUP_IS_SESSION_SYNC (item->session) ||
-                       (!SOUP_IS_SESSION_ASYNC (item->session) && !item->async);
+               gboolean blocking = !SOUP_IS_SESSION_ASYNC (item->session) && !item->async;
                io_run (item->msg, blocking);
        }
 }
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index 3acf1e42..ae0bb0bc 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -2192,9 +2192,8 @@ soup_message_get_soup_request (SoupMessage *msg)
  * message with lower priority (messages with the same priority are
  * processed on a FIFO basis).
  *
- * Setting priorities does not currently work with #SoupSessionSync
- * (or with synchronous messages on a plain #SoupSession) because in
- * the synchronous/blocking case, priority ends up being determined
+ * Setting priorities does not currently work with synchronous messages
+ * because in the synchronous/blocking case, priority ends up being determined
  * semi-randomly by thread scheduling.
  *
  * Since: 2.44
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index 285f59d7..d582eb67 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -137,8 +137,6 @@ soup_request_http_send_async (SoupRequest          *request,
        SoupSession *session = soup_request_get_session (request);
        GTask *task;
 
-       g_return_if_fail (!SOUP_IS_SESSION_SYNC (session));
-
        task = g_task_new (request, cancellable, callback, user_data);
        soup_session_send_async (session, http->priv->msg, cancellable,
                                 http_input_stream_ready_cb, task);
diff --git a/libsoup/soup-request.c b/libsoup/soup-request.c
index a8d19ddc..b06d4aea 100644
--- a/libsoup/soup-request.c
+++ b/libsoup/soup-request.c
@@ -229,9 +229,6 @@ soup_request_send (SoupRequest          *request,
  * Begins an asynchronously request for the URI pointed to by
  * @request.
  *
- * Note that you cannot use this method with #SoupRequests attached to
- * a #SoupSessionSync.
- *
  * Since: 2.42
  */
 void
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index 007f7da7..22a1ded7 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -46,17 +46,6 @@
  * one session for the first user, and a second session for the other
  * user.)
  *
- * In the past, #SoupSession was an abstract class, and users needed
- * to choose between #SoupSessionAsync (which always uses
- * #GMainLoop<!-- -->-based I/O), or #SoupSessionSync (which always uses
- * blocking I/O and can be used from multiple threads simultaneously).
- * This is no longer necessary; you can (and should) use a plain
- * #SoupSession, which supports both synchronous and asynchronous use.
- * (When using a plain #SoupSession, soup_session_queue_message()
- * behaves like it traditionally did on a #SoupSessionAsync, and
- * soup_session_send_message() behaves like it traditionally did on a
- * #SoupSessionSync.)
- *
  * Additional #SoupSession functionality is provided by
  * #SoupSessionFeature objects, which can be added to a session with
  * soup_session_add_feature() or soup_session_add_feature_by_type()
@@ -1973,13 +1962,6 @@ soup_session_real_queue_message (SoupSession *session, SoupMessage *msg,
  * be invoked. If after returning from this callback the message has not
  * been requeued, @msg will be unreffed.
  *
- * (The behavior above applies to a plain #SoupSession; if you are
- * using #SoupSessionAsync or #SoupSessionSync, then the #GMainContext
- * that is used depends on the settings of #SoupSession:async-context
- * and #SoupSession:use-thread-context, and for #SoupSessionSync, the
- * message will actually be sent and processed in another thread, with
- * only the final callback occurring in the indicated #GMainContext.)
- *
  * Contrast this method with soup_session_send_async(), which also
  * asynchronously sends a message, but returns before reading the
  * response body, and allows you to read the response via a
@@ -2288,17 +2270,6 @@ soup_session_real_flush_queue (SoupSession *session)
 {
        SoupSessionPrivate *priv = soup_session_get_instance_private (session);
        SoupMessageQueueItem *item;
-       GHashTable *current = NULL;
-       gboolean done = FALSE;
-
-       if (SOUP_IS_SESSION_SYNC (session)) {
-               /* Record the current contents of the queue */
-               current = g_hash_table_new (NULL, NULL);
-               for (item = soup_message_queue_first (priv->queue);
-                    item;
-                    item = soup_message_queue_next (priv->queue, item))
-                       g_hash_table_insert (current, item, item);
-       }
 
        /* Cancel everything */
        for (item = soup_message_queue_first (priv->queue);
@@ -2307,33 +2278,6 @@ soup_session_real_flush_queue (SoupSession *session)
                soup_session_cancel_message (session, item->msg,
                                             SOUP_STATUS_CANCELLED);
        }
-
-       if (SOUP_IS_SESSION_SYNC (session)) {
-               /* Wait until all of the items in @current have been
-                * removed from the queue. (This is not the same as
-                * "wait for the queue to be empty", because the app
-                * may queue new requests in response to the
-                * cancellation of the old ones. We don't try to
-                * cancel those requests as well, since we'd likely
-                * just end up looping forever.)
-                */
-               g_mutex_lock (&priv->conn_lock);
-               do {
-                       done = TRUE;
-                       for (item = soup_message_queue_first (priv->queue);
-                            item;
-                            item = soup_message_queue_next (priv->queue, item)) {
-                               if (g_hash_table_lookup (current, item))
-                                       done = FALSE;
-                       }
-
-                       if (!done)
-                               g_cond_wait (&priv->conn_cond, &priv->conn_lock);
-               } while (!done);
-               g_mutex_unlock (&priv->conn_lock);
-
-               g_hash_table_destroy (current);
-       }
 }
 
 /**
@@ -3040,11 +2984,6 @@ soup_session_class_init (SoupSessionClass *session_class)
         * if you want to ensure that all future connections will have
         * this timeout value.
         *
-        * Note that the default value of 60 seconds only applies to
-        * plain #SoupSessions. If you are using #SoupSessionAsync or
-        * #SoupSessionSync, the default value is 0 (meaning idle
-        * connections will never time out).
-        *
         * Since: 2.24
         **/
        /**
@@ -3086,11 +3025,6 @@ soup_session_class_init (SoupSessionClass *session_class)
         * See #SoupSession:ssl-strict for more information on how
         * https certificate validation is handled.
         *
-        * Note that the default value of %TRUE only applies to plain
-        * #SoupSessions. If you are using #SoupSessionAsync or
-        * #SoupSessionSync, the default value is %FALSE, for backward
-        * compatibility.
-        *
         * Since: 2.38
         **/
        g_object_class_install_property (
@@ -3122,12 +3056,6 @@ soup_session_class_init (SoupSessionClass *session_class)
         * See #SoupSession:ssl-strict for more information on how
         * https certificate validation is handled.
         *
-        * If you are using a plain #SoupSession then
-        * #SoupSession:ssl-use-system-ca-file will be %TRUE by
-        * default, and so this property will be a copy of the system
-        * CA database. If you are using #SoupSessionAsync or
-        * #SoupSessionSync, this property will be %NULL by default.
-        *
         * Since: 2.38
         **/
        g_object_class_install_property (
@@ -3165,11 +3093,7 @@ soup_session_class_init (SoupSessionClass *session_class)
         *
         * For a plain #SoupSession, if the session has no CA file or
         * TLS database, and this property is %TRUE, then all
-        * certificates will be rejected. However, beware that the
-        * deprecated #SoupSession subclasses (#SoupSessionAsync and
-        * #SoupSessionSync) have the opposite behavior: if there is
-        * no CA file or TLS database, then all certificates are always
-        * accepted, and this property has no effect.
+        * certificates will be rejected.
         *
         * Since: 2.30
         */
@@ -3249,11 +3173,6 @@ soup_session_class_init (SoupSessionClass *session_class)
         * if you want to ensure that all future connections will have
         * this timeout value.
         *
-        * Note that the default value of 60 seconds only applies to
-        * plain #SoupSessions. If you are using #SoupSessionAsync or
-        * #SoupSessionSync, the default value is 0 (meaning socket I/O
-        * will not time out).
-        *
         * Not to be confused with #SoupSession:idle-timeout (which is
         * the length of time that idle persistent connections will be
         * kept open).
@@ -3449,11 +3368,6 @@ soup_session_class_init (SoupSessionClass *session_class)
         *
         * In a plain #SoupSession, the default value is %NULL,
         * meaning that only "http" is recognized as meaning "http".
-        * In #SoupSessionAsync and #SoupSessionSync, for backward
-        * compatibility, the default value is an array containing the
-        * single element <literal>"*"</literal>, a special value
-        * which means that any scheme except "https" is considered to
-        * be an alias for "http".
         *
         * See also #SoupSession:https-aliases.
         *
@@ -3986,11 +3900,6 @@ cancel_cancellable (G_GNUC_UNUSED GCancellable *cancellable, GCancellable *chain
  * asynchronously sends a #SoupMessage, but doesn't invoke its
  * callback until the response has been completely read.
  *
- * (Note that this method cannot be called on the deprecated
- * #SoupSessionSync subclass, and can only be called on
- * #SoupSessionAsync if you have set the
- * #SoupSession:use-thread-context property.)
- *
  * Since: 2.42
  */
 void
@@ -4004,7 +3913,6 @@ soup_session_send_async (SoupSession         *session,
        gboolean use_thread_context;
 
        g_return_if_fail (SOUP_IS_SESSION (session));
-       g_return_if_fail (!SOUP_IS_SESSION_SYNC (session));
 
        g_object_get (G_OBJECT (session),
                      SOUP_SESSION_USE_THREAD_CONTEXT, &use_thread_context,
@@ -4065,7 +3973,6 @@ soup_session_send_finish (SoupSession   *session,
        GTask *task;
 
        g_return_val_if_fail (SOUP_IS_SESSION (session), NULL);
-       g_return_val_if_fail (!SOUP_IS_SESSION_SYNC (session), NULL);
        g_return_val_if_fail (g_task_is_valid (result, session), NULL);
 
        task = G_TASK (result);
diff --git a/libsoup/soup-types.h b/libsoup/soup-types.h
index 89e077a6..6106d9c4 100644
--- a/libsoup/soup-types.h
+++ b/libsoup/soup-types.h
@@ -30,7 +30,6 @@ typedef struct _SoupServer              SoupServer;
 typedef struct _SoupSession             SoupSession;
 typedef struct _SoupSessionAsync        SoupSessionAsync;
 typedef struct _SoupSessionFeature      SoupSessionFeature;
-typedef struct _SoupSessionSync         SoupSessionSync;
 typedef struct _SoupSocket              SoupSocket;
 typedef struct _SoupURI                 SoupURI;
 typedef struct _SoupWebsocketConnection SoupWebsocketConnection;
diff --git a/libsoup/soup.h b/libsoup/soup.h
index c0131d9f..b8fedbaa 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -44,7 +44,6 @@ extern "C" {
 #include "soup-server.h"
 #include "soup-session-async.h"
 #include "soup-session-feature.h"
-#include "soup-session-sync.h"
 #include "soup-socket.h"
 #include "soup-status.h"
 #include "soup-tld.h"
diff --git a/tests/test-utils.c b/tests/test-utils.c
index 1d98b4a3..dd0f5a94 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -632,14 +632,6 @@ cancel_request_timeout (gpointer data)
        return FALSE;
 }
 
-static gpointer
-cancel_request_thread (gpointer data)
-{
-       g_usleep (100000); /* .1s */
-       cancel_message_or_cancellable ((CancelData *) data);
-       return NULL;
-}
-
 GInputStream *
 soup_test_request_send (SoupRequest   *req,
                        GCancellable  *cancellable,
@@ -650,18 +642,6 @@ soup_test_request_send (SoupRequest   *req,
        GInputStream *stream;
        CancelData *cancel_data = create_cancel_data (req, cancellable, flags);
 
-       if (SOUP_IS_SESSION_SYNC (soup_request_get_session (req))) {
-               GThread *thread;
-
-               if (cancel_data)
-                       thread = g_thread_new ("cancel_request_thread", cancel_request_thread,
-                                              cancel_data);
-               stream = soup_request_send (req, cancellable, error);
-               if (cancel_data)
-                       g_thread_unref (thread);
-               return stream;
-       }
-
        data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
        if (cancel_data &&
            (flags & SOUP_TEST_REQUEST_CANCEL_SOON || flags & SOUP_TEST_REQUEST_CANCEL_IMMEDIATE)) {
@@ -701,27 +681,18 @@ soup_test_request_read_all (SoupRequest   *req,
        AsyncAsSyncData data;
        gsize nread;
 
-       if (!SOUP_IS_SESSION_SYNC (soup_request_get_session (req)))
-               data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
-       else
-               data.loop = NULL;
+        data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
 
        do {
-               if (!data.loop) {
-                       nread = g_input_stream_read (stream, buf, sizeof (buf),
-                                                    cancellable, error);
-               } else {
-                       g_input_stream_read_async (stream, buf, sizeof (buf),
-                                                  G_PRIORITY_DEFAULT, cancellable,
-                                                  async_as_sync_callback, &data);
-                       g_main_loop_run (data.loop);
-                       nread = g_input_stream_read_finish (stream, data.result, error);
-                       g_object_unref (data.result);
-               }
+                g_input_stream_read_async (stream, buf, sizeof (buf),
+                                                G_PRIORITY_DEFAULT, cancellable,
+                                                async_as_sync_callback, &data);
+                g_main_loop_run (data.loop);
+                nread = g_input_stream_read_finish (stream, data.result, error);
+                g_object_unref (data.result);
        } while (nread > 0);
 
-       if (data.loop)
-               g_main_loop_unref (data.loop);
+       g_main_loop_unref (data.loop);
 
        return nread == 0;
 }
@@ -735,9 +706,6 @@ soup_test_request_close_stream (SoupRequest   *req,
        AsyncAsSyncData data;
        gboolean ok;
 
-       if (SOUP_IS_SESSION_SYNC (soup_request_get_session (req)))
-               return g_input_stream_close (stream, cancellable, error);
-
        data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
 
        g_input_stream_close_async (stream, G_PRIORITY_DEFAULT, cancellable,
diff --git a/tests/test-utils.h b/tests/test-utils.h
index d230b1c3..6462f46f 100644
--- a/tests/test-utils.h
+++ b/tests/test-utils.h
@@ -55,8 +55,6 @@ typedef enum {
 
 #undef SOUP_TYPE_SESSION_ASYNC
 #define SOUP_TYPE_SESSION_ASYNC (_soup_session_async_get_type_undeprecated ())
-#undef SOUP_TYPE_SESSION_SYNC
-#define SOUP_TYPE_SESSION_SYNC (_soup_session_sync_get_type_undeprecated ())
 
 SoupSession *soup_test_session_new         (GType type, ...);
 void         soup_test_session_abort_unref (SoupSession *session);


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