diff options
author | Carlos Garcia Campos <cgarcia@igalia.com> | 2022-10-14 10:45:07 +0200 |
---|---|---|
committer | Carlos Garcia Campos <cgarcia@igalia.com> | 2022-10-14 13:10:35 +0200 |
commit | 998dff04cb559fbc3688cc8d3392c8fecc854201 (patch) | |
tree | f1edf71a225f7958a91f5d28bdb37a90e55a8bd4 /libsoup | |
parent | 4507ac14063537e6dd97fec505f29e394e9eac91 (diff) | |
download | libsoup-998dff04cb559fbc3688cc8d3392c8fecc854201.tar.gz |
session: create the queue sources when the first async item is queued
A session running only sync items doesn't need the queue sources at all.
Diffstat (limited to 'libsoup')
-rw-r--r-- | libsoup/soup-session.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c index ba74b1dc..b09fd6a8 100644 --- a/libsoup/soup-session.c +++ b/libsoup/soup-session.c @@ -212,6 +212,9 @@ soup_session_add_queue_source (SoupSession *session, SoupSessionPrivate *priv = soup_session_get_instance_private (session); SoupMessageQueueSource *queue_source; + if (!priv->queue_sources) + priv->queue_sources = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_source_unref); + queue_source = g_hash_table_lookup (priv->queue_sources, context); if (!queue_source) { GSource *source; @@ -238,9 +241,6 @@ soup_session_add_queue_source_for_item (SoupSession *session, if (!item->async) return; - if (item->context == priv->context) - return; - g_mutex_lock (&priv->queue_sources_mutex); soup_session_add_queue_source (session, item->context); g_mutex_unlock (&priv->queue_sources_mutex); @@ -291,8 +291,6 @@ soup_session_init (SoupSession *session) g_mutex_init (&priv->queue_mutex); priv->queue = g_queue_new (); g_mutex_init (&priv->queue_sources_mutex); - priv->queue_sources = g_hash_table_new_full (NULL, NULL, NULL, (GDestroyNotify)g_source_unref); - soup_session_add_queue_source (session, priv->context); priv->io_timeout = priv->idle_timeout = 60; @@ -337,7 +335,8 @@ soup_session_dispose (GObject *object) while (priv->features) soup_session_remove_feature (session, priv->features->data); - g_hash_table_foreach (priv->queue_sources, (GHFunc)destroy_queue_source, NULL); + if (priv->queue_sources) + g_hash_table_foreach (priv->queue_sources, (GHFunc)destroy_queue_source, NULL); G_OBJECT_CLASS (soup_session_parent_class)->dispose (object); } @@ -351,7 +350,7 @@ soup_session_finalize (GObject *object) g_warn_if_fail (g_queue_is_empty (priv->queue)); g_queue_free (priv->queue); g_mutex_clear (&priv->queue_mutex); - g_hash_table_destroy (priv->queue_sources); + g_clear_pointer (&priv->queue_sources, g_hash_table_destroy); g_mutex_clear (&priv->queue_sources_mutex); g_main_context_unref (priv->context); @@ -1913,7 +1912,8 @@ soup_session_kick_queue (SoupSession *session) SoupSessionPrivate *priv = soup_session_get_instance_private (session); g_mutex_lock (&priv->queue_sources_mutex); - g_hash_table_foreach (priv->queue_sources, (GHFunc)kick_queue_source, NULL); + if (priv->queue_sources) + g_hash_table_foreach (priv->queue_sources, (GHFunc)kick_queue_source, NULL); g_mutex_unlock (&priv->queue_sources_mutex); } |