[libsoup/wip/remove-deprecations: 37/49] Remove SoupSessionAsync
- From: Patrick Griffis <pgriffis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/wip/remove-deprecations: 37/49] Remove SoupSessionAsync
- Date: Tue, 30 Jun 2020 21:57:24 +0000 (UTC)
commit f9d1a37ebaea302d7dd5a0c2e0bffc51a492ebc8
Author: Patrick Griffis <pgriffis igalia com>
Date: Sun Mar 15 02:48:06 2020 -0700
Remove SoupSessionAsync
docs/reference/libsoup-2.4-sections.txt | 24 ---
examples/get.c | 20 +-
libsoup/Soup-2.4.metadata | 2 -
libsoup/cache/soup-cache.c | 2 +-
libsoup/include/soup-installed.h | 1 -
libsoup/meson.build | 2 -
libsoup/soup-connection.c | 7 +-
libsoup/soup-message-client-io.c | 2 +-
libsoup/soup-message-io.c | 3 +-
libsoup/soup-message-private.h | 1 -
libsoup/soup-message-queue.c | 2 +-
libsoup/soup-message-server-io.c | 12 +-
libsoup/soup-request-http.c | 2 -
libsoup/soup-server.c | 4 -
libsoup/soup-session-async.c | 146 -------------
libsoup/soup-session-async.h | 60 ------
libsoup/soup-session-host.c | 2 +-
libsoup/soup-session.c | 359 +++++++-------------------------
libsoup/soup-session.h | 18 --
libsoup/soup-socket-private.h | 10 +-
libsoup/soup-socket-properties.c | 21 +-
libsoup/soup-socket.c | 83 +-------
libsoup/soup-socket.h | 2 -
libsoup/soup.h | 2 +-
tests/cache-test.c | 6 -
tests/coding-test.c | 1 -
tests/connection-test.c | 1 -
tests/context-test.c | 2 -
tests/hsts-db-test.c | 1 -
tests/hsts-test.c | 2 -
tests/misc-test.c | 7 -
tests/multipart-test.c | 1 -
tests/no-ssl-test.c | 34 ---
tests/proxy-test.c | 3 -
tests/redirect-test.c | 1 -
tests/resource-test.c | 3 +-
tests/sniffing-test.c | 1 -
tests/ssl-test.c | 50 -----
tests/timeout-test.c | 3 -
39 files changed, 96 insertions(+), 807 deletions(-)
---
diff --git a/docs/reference/libsoup-2.4-sections.txt b/docs/reference/libsoup-2.4-sections.txt
index f9cf6cb0..df31d0aa 100644
--- a/docs/reference/libsoup-2.4-sections.txt
+++ b/docs/reference/libsoup-2.4-sections.txt
@@ -445,9 +445,6 @@ soup_session_redirect_message
<SUBSECTION>
soup_session_pause_message
soup_session_unpause_message
-<SUBSECTION>
-soup_session_get_async_context
-<SUBSECTION>
soup_session_add_feature
soup_session_add_feature_by_type
soup_session_remove_feature
@@ -470,8 +467,6 @@ SOUP_SESSION_TLS_DATABASE
SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE
SOUP_SESSION_SSL_STRICT
SOUP_SESSION_TLS_INTERACTION
-SOUP_SESSION_ASYNC_CONTEXT
-SOUP_SESSION_USE_THREAD_CONTEXT
SOUP_SESSION_TIMEOUT
SOUP_SESSION_IDLE_TIMEOUT
SOUP_SESSION_USER_AGENT
@@ -501,23 +496,6 @@ SoupMessageQueueItem
SOUP_SESSION_USE_NTLM
</SECTION>
-<SECTION>
-<FILE>soup-session-async</FILE>
-<TITLE>SoupSessionAsync</TITLE>
-SoupSessionAsync
-soup_session_async_new
-soup_session_async_new_with_options
-<SUBSECTION Standard>
-SOUP_IS_SESSION_ASYNC
-SOUP_IS_SESSION_ASYNC_CLASS
-SOUP_SESSION_ASYNC
-SOUP_SESSION_ASYNC_CLASS
-SOUP_SESSION_ASYNC_GET_CLASS
-SOUP_TYPE_SESSION_ASYNC
-SoupSessionAsyncClass
-soup_session_async_get_type
-</SECTION>
-
<SECTION>
<FILE>soup-session-feature</FILE>
<TITLE>SoupSessionFeature</TITLE>
@@ -638,14 +616,12 @@ SOUP_SOCKET_REMOTE_ADDRESS
SOUP_SOCKET_FLAG_NONBLOCKING
SOUP_SOCKET_IS_SERVER
SOUP_SOCKET_SSL_CREDENTIALS
-SOUP_SOCKET_ASYNC_CONTEXT
SOUP_SOCKET_TIMEOUT
SOUP_SOCKET_SSL_FALLBACK
SOUP_SOCKET_SSL_STRICT
SOUP_SOCKET_TLS_CERTIFICATE
SOUP_SOCKET_TLS_ERRORS
SOUP_SOCKET_TRUSTED_CERTIFICATE
-SOUP_SOCKET_USE_THREAD_CONTEXT
<SUBSECTION Standard>
SOUP_SOCKET
SOUP_IS_SOCKET
diff --git a/examples/get.c b/examples/get.c
index 96ee67c2..67e72f2a 100644
--- a/examples/get.c
+++ b/examples/get.c
@@ -35,12 +35,9 @@ get_url (const char *url)
msg = soup_message_new (head ? "HEAD" : "GET", url);
soup_message_set_flags (msg, SOUP_MESSAGE_NO_REDIRECT);
- if (loop) {
- g_object_ref (msg);
- soup_session_queue_message (session, msg, finished, loop);
- g_main_loop_run (loop);
- } else
- soup_session_send_message (session, msg);
+ g_object_ref (msg);
+ soup_session_queue_message (session, msg, finished, loop);
+ g_main_loop_run (loop);
name = soup_message_get_uri (msg)->path;
@@ -147,7 +144,7 @@ _get_tls_cert_interaction_new (GTlsCertificate *cert)
static const char *ca_file, *proxy;
static char *client_cert_file, *client_key_file;
-static gboolean synchronous, ntlm;
+static gboolean ntlm;
static gboolean negotiate;
static GOptionEntry entries[] = {
@@ -178,9 +175,6 @@ static GOptionEntry entries[] = {
{ "quiet", 'q', 0,
G_OPTION_ARG_NONE, &quiet,
"Don't show HTTP status code", NULL },
- { "sync", 's', 0,
- G_OPTION_ARG_NONE, &synchronous,
- "Use SoupSessionSync rather than SoupSessionAsync", NULL },
{ NULL }
};
@@ -286,13 +280,11 @@ main (int argc, char **argv)
}
#endif /* LIBSOUP_HAVE_GSSAPI */
- if (!synchronous)
- loop = g_main_loop_new (NULL, TRUE);
+ loop = g_main_loop_new (NULL, TRUE);
get_url (url);
- if (!synchronous)
- g_main_loop_unref (loop);
+ g_main_loop_unref (loop);
g_object_unref (session);
diff --git a/libsoup/Soup-2.4.metadata b/libsoup/Soup-2.4.metadata
index 9a45ca2e..87c11637 100644
--- a/libsoup/Soup-2.4.metadata
+++ b/libsoup/Soup-2.4.metadata
@@ -30,12 +30,10 @@ Message
Server
.new skip=false
Session
- .async_context type="GLib.MainContext"
.get_features type_arguments="weak Soup.SessionFeature"
.send_async.cancellable#parameter default=null
Session*.new_with_options skip=false
Socket
- .async_context type="GLib.MainContext"
.new skip=false
URI
.set_query_from_fields skip=false
diff --git a/libsoup/cache/soup-cache.c b/libsoup/cache/soup-cache.c
index 472f24c8..36f0dcae 100644
--- a/libsoup/cache/soup-cache.c
+++ b/libsoup/cache/soup-cache.c
@@ -1269,7 +1269,7 @@ soup_cache_flush (SoupCache *cache)
session = cache->priv->session;
g_return_if_fail (SOUP_IS_SESSION (session));
- async_context = soup_session_get_async_context (session);
+ async_context = g_main_context_get_thread_default ();
/* We give cache 10 secs to finish */
timeout = soup_add_timeout (async_context, 10000, force_flush_timeout, &forced);
diff --git a/libsoup/include/soup-installed.h b/libsoup/include/soup-installed.h
index 0743301d..24bec683 100644
--- a/libsoup/include/soup-installed.h
+++ b/libsoup/include/soup-installed.h
@@ -42,7 +42,6 @@ extern "C" {
#include <libsoup/soup-request-file.h>
#include <libsoup/soup-request-http.h>
#include <libsoup/soup-server.h>
-#include <libsoup/soup-session-async.h>
#include <libsoup/soup-session-feature.h>
#include <libsoup/soup-socket.h>
#include <libsoup/soup-status.h>
diff --git a/libsoup/meson.build b/libsoup/meson.build
index 1b0e038e..9b1c6d2f 100644
--- a/libsoup/meson.build
+++ b/libsoup/meson.build
@@ -79,7 +79,6 @@ soup_sources = [
'soup-request-http.c',
'soup-server.c',
'soup-session.c',
- 'soup-session-async.c',
'soup-session-feature.c',
'soup-session-host.c',
'soup-socket.c',
@@ -178,7 +177,6 @@ soup_introspection_headers = [
'soup-request-http.h',
'soup-server.h',
'soup-session.h',
- 'soup-session-async.h',
'soup-session-feature.h',
'soup-socket.h',
'soup-status.h',
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index d4af0e9e..927c545a 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -234,7 +234,7 @@ start_idle_timer (SoupConnection *conn)
if (priv->socket_props->idle_timeout > 0 && !priv->idle_timeout_src) {
priv->idle_timeout_src =
- soup_add_timeout (priv->socket_props->async_context,
+ soup_add_timeout (NULL,
priv->socket_props->idle_timeout * 1000,
idle_timeout, conn);
}
@@ -416,12 +416,10 @@ soup_connection_connect_async (SoupConnection *conn,
g_signal_connect (priv->socket, "event",
G_CALLBACK (re_emit_socket_event), conn);
- soup_socket_properties_push_async_context (priv->socket_props);
task = g_task_new (conn, cancellable, callback, user_data);
soup_socket_connect_async_internal (priv->socket, cancellable,
socket_connect_complete, task);
- soup_socket_properties_pop_async_context (priv->socket_props);
}
gboolean
@@ -544,13 +542,10 @@ soup_connection_start_ssl_async (SoupConnection *conn,
g_return_if_fail (SOUP_IS_CONNECTION (conn));
priv = soup_connection_get_instance_private (conn);
- soup_socket_properties_push_async_context (priv->socket_props);
task = g_task_new (conn, cancellable, callback, user_data);
soup_socket_handshake_async (priv->socket, priv->remote_uri->host,
cancellable, start_ssl_completed, task);
-
- soup_socket_properties_pop_async_context (priv->socket_props);
}
gboolean
diff --git a/libsoup/soup-message-client-io.c b/libsoup/soup-message-client-io.c
index 9fba1958..fdaa79dc 100644
--- a/libsoup/soup-message-client-io.c
+++ b/libsoup/soup-message-client-io.c
@@ -146,7 +146,7 @@ soup_message_send_request (SoupMessageQueueItem *item,
GMainContext *async_context;
GIOStream *iostream;
- async_context = soup_session_get_async_context (item->session);
+ async_context = g_main_context_get_thread_default ();
if (!async_context)
async_context = g_main_context_default ();
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index 311b688d..654373b1 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -1205,8 +1205,7 @@ soup_message_io_client (SoupMessageQueueItem *item,
io->write_state = SOUP_MESSAGE_IO_STATE_HEADERS;
if (!item->new_api) {
- gboolean blocking = !SOUP_IS_SESSION_ASYNC (item->session) && !item->async;
- io_run (item->msg, blocking);
+ io_run (item->msg, !item->async);
}
}
diff --git a/libsoup/soup-message-private.h b/libsoup/soup-message-private.h
index ddc99ab4..a7a83917 100644
--- a/libsoup/soup-message-private.h
+++ b/libsoup/soup-message-private.h
@@ -72,7 +72,6 @@ void soup_message_send_request (SoupMessageQueueItem *item,
gpointer user_data);
void soup_message_read_request (SoupMessage *msg,
SoupSocket *sock,
- gboolean use_thread_context,
SoupMessageCompletionFn completion_cb,
gpointer user_data);
diff --git a/libsoup/soup-message-queue.c b/libsoup/soup-message-queue.c
index 436f3eb5..815fbb79 100644
--- a/libsoup/soup-message-queue.c
+++ b/libsoup/soup-message-queue.c
@@ -81,7 +81,7 @@ soup_message_queue_append (SoupMessageQueue *queue, SoupMessage *msg,
item = g_slice_new0 (SoupMessageQueueItem);
item->session = g_object_ref (queue->session);
- item->async_context = soup_session_get_async_context (item->session);
+ item->async_context = g_main_context_get_thread_default ();
if (item->async_context)
g_main_context_ref (item->async_context);
item->queue = queue;
diff --git a/libsoup/soup-message-server-io.c b/libsoup/soup-message-server-io.c
index 2e30b227..196690a7 100644
--- a/libsoup/soup-message-server-io.c
+++ b/libsoup/soup-message-server-io.c
@@ -281,23 +281,13 @@ get_response_headers (SoupMessage *msg, GString *headers,
void
soup_message_read_request (SoupMessage *msg,
SoupSocket *sock,
- gboolean use_thread_context,
SoupMessageCompletionFn completion_cb,
gpointer user_data)
{
GMainContext *async_context;
GIOStream *iostream;
- if (use_thread_context)
- async_context = g_main_context_ref_thread_default ();
- else {
- g_object_get (sock,
- SOUP_SOCKET_ASYNC_CONTEXT, &async_context,
- NULL);
- if (!async_context)
- async_context = g_main_context_ref (g_main_context_default ());
- }
-
+ async_context = g_main_context_ref_thread_default ();
iostream = soup_socket_get_iostream (sock);
soup_message_io_server (msg, iostream, async_context,
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index d582eb67..efdea6fe 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -105,8 +105,6 @@ soup_request_http_send (SoupRequest *request,
SoupRequestHTTP *http = SOUP_REQUEST_HTTP (request);
SoupSession *session = soup_request_get_session (request);
- g_return_val_if_fail (!SOUP_IS_SESSION_ASYNC (session), NULL);
-
return soup_session_send (session, http->priv->msg,
cancellable, error);
}
diff --git a/libsoup/soup-server.c b/libsoup/soup-server.c
index 30b6cffe..34f9cb8d 100644
--- a/libsoup/soup-server.c
+++ b/libsoup/soup-server.c
@@ -1165,7 +1165,6 @@ start_request (SoupServer *server, SoupClientContext *client)
msg, client);
soup_message_read_request (msg, client->sock,
- TRUE,
request_finished, client);
}
@@ -1412,7 +1411,6 @@ soup_server_listen (SoupServer *server, GSocketAddress *address,
saddr = soup_address_new_from_gsockaddr (address);
listener = soup_socket_new (SOUP_SOCKET_LOCAL_ADDRESS, saddr,
- SOUP_SOCKET_USE_THREAD_CONTEXT, TRUE,
SOUP_SOCKET_IPV6_ONLY, TRUE,
NULL);
@@ -1641,7 +1639,6 @@ soup_server_listen_socket (SoupServer *server, GSocket *socket,
listener = g_initable_new (SOUP_TYPE_SOCKET, NULL, error,
SOUP_SOCKET_GSOCKET, socket,
- SOUP_SOCKET_USE_THREAD_CONTEXT, TRUE,
SOUP_SOCKET_IPV6_ONLY, TRUE,
NULL);
if (!listener)
@@ -1691,7 +1688,6 @@ soup_server_listen_fd (SoupServer *server, int fd,
listener = g_initable_new (SOUP_TYPE_SOCKET, NULL, error,
SOUP_SOCKET_FD, fd,
- SOUP_SOCKET_USE_THREAD_CONTEXT, TRUE,
SOUP_SOCKET_IPV6_ONLY, TRUE,
NULL);
if (!listener)
diff --git a/libsoup/soup-session-host.c b/libsoup/soup-session-host.c
index c3d8da7b..40c47727 100644
--- a/libsoup/soup-session-host.c
+++ b/libsoup/soup-session-host.c
@@ -169,7 +169,7 @@ connection_disconnected (SoupConnection *conn, gpointer host)
if (priv->num_conns == 0) {
g_assert (priv->keep_alive_src == NULL);
- priv->keep_alive_src = soup_add_timeout_reffed (soup_session_get_async_context
(priv->session),
+ priv->keep_alive_src = soup_add_timeout_reffed (g_main_context_get_thread_default (),
HOST_KEEP_ALIVE,
emit_unused,
host);
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index a9d474f3..2c97df5d 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -112,7 +112,6 @@ typedef struct {
GCond conn_cond;
GMainContext *async_context;
- gboolean use_thread_context;
char **http_aliases, **https_aliases;
@@ -166,7 +165,6 @@ enum {
PROP_TLS_DATABASE,
PROP_SSL_STRICT,
PROP_ASYNC_CONTEXT,
- PROP_USE_THREAD_CONTEXT,
PROP_TIMEOUT,
PROP_USER_AGENT,
PROP_ACCEPT_LANGUAGE,
@@ -190,6 +188,8 @@ soup_session_init (SoupSession *session)
SoupAuthManager *auth_manager;
priv->queue = soup_message_queue_new (session);
+ priv->async_context = g_main_context_ref_thread_default ();
+ priv->io_timeout = priv->idle_timeout = 60;
g_mutex_init (&priv->conn_lock);
g_cond_init (&priv->conn_cond);
@@ -215,6 +215,8 @@ soup_session_init (SoupSession *session)
soup_session_add_feature (session, SOUP_SESSION_FEATURE (auth_manager));
g_object_unref (auth_manager);
+ soup_session_add_feature_by_type (session, SOUP_TYPE_CONTENT_DECODER);
+
/* We'll be doing DNS continuously-ish while the session is active,
* so hold a ref on the default GResolver.
*/
@@ -222,9 +224,13 @@ soup_session_init (SoupSession *session)
priv->ssl_strict = TRUE;
- priv->http_aliases = g_new (char *, 2);
- priv->http_aliases[0] = (char *)g_intern_string ("*");
- priv->http_aliases[1] = NULL;
+
+ /* If the user overrides the proxy or tlsdb during construction,
+ * we don't want to needlessly resolve the extension point. So
+ * we just set flags saying to do it later.
+ */
+ priv->proxy_use_default = TRUE;
+ priv->tlsdb_use_default = TRUE;
priv->request_types = g_hash_table_new (soup_str_case_hash,
soup_str_case_equal);
@@ -233,43 +239,6 @@ soup_session_init (SoupSession *session)
soup_session_add_feature_by_type (session, SOUP_TYPE_REQUEST_DATA);
}
-static GObject *
-soup_session_constructor (GType type,
- guint n_construct_properties,
- GObjectConstructParam *construct_params)
-{
- GObject *object;
-
- object = G_OBJECT_CLASS (soup_session_parent_class)->constructor (type, n_construct_properties,
construct_params);
-
- /* If this is a "plain" SoupSession, fix up the default
- * properties values, etc.
- */
- if (type == SOUP_TYPE_SESSION) {
- SoupSession *session = SOUP_SESSION (object);
- SoupSessionPrivate *priv = soup_session_get_instance_private (session);
-
- g_clear_pointer (&priv->async_context, g_main_context_unref);
- priv->async_context = g_main_context_ref_thread_default ();
- priv->use_thread_context = TRUE;
-
- priv->io_timeout = priv->idle_timeout = 60;
-
- priv->http_aliases[0] = NULL;
-
- /* If the user overrides the proxy or tlsdb during construction,
- * we don't want to needlessly resolve the extension point. So
- * we just set flags saying to do it later.
- */
- priv->proxy_use_default = TRUE;
- priv->tlsdb_use_default = TRUE;
-
- soup_session_add_feature_by_type (session, SOUP_TYPE_CONTENT_DECODER);
- }
-
- return object;
-}
-
static void
soup_session_dispose (GObject *object)
{
@@ -345,9 +314,7 @@ ensure_socket_props (SoupSession *session)
ssl_strict = priv->ssl_strict && (priv->tlsdb != NULL ||
SOUP_IS_PLAIN_SESSION (session));
- priv->socket_props = soup_socket_properties_new (priv->async_context,
- priv->use_thread_context,
- priv->proxy_resolver,
+ priv->socket_props = soup_socket_properties_new (priv->proxy_resolver,
priv->local_addr,
priv->tlsdb,
priv->tls_interaction,
@@ -454,7 +421,6 @@ soup_session_set_property (GObject *object, guint prop_id,
SoupSession *session = SOUP_SESSION (object);
SoupSessionPrivate *priv = soup_session_get_instance_private (session);
const char *user_agent;
- GMainContext *async_context;
gboolean socket_props_changed = FALSE;
switch (prop_id) {
@@ -490,28 +456,6 @@ soup_session_set_property (GObject *object, guint prop_id,
priv->ssl_strict = g_value_get_boolean (value);
socket_props_changed = TRUE;
break;
- case PROP_ASYNC_CONTEXT:
- async_context = g_value_get_pointer (value);
- if (async_context && async_context != g_main_context_get_thread_default ())
- g_return_if_fail (!SOUP_IS_PLAIN_SESSION (session));
- priv->async_context = async_context;
- if (priv->async_context)
- g_main_context_ref (priv->async_context);
- socket_props_changed = TRUE;
- break;
- case PROP_USE_THREAD_CONTEXT:
- if (!g_value_get_boolean (value))
- g_return_if_fail (!SOUP_IS_PLAIN_SESSION (session));
- priv->use_thread_context = g_value_get_boolean (value);
- if (priv->use_thread_context) {
- if (priv->async_context)
- g_main_context_unref (priv->async_context);
- priv->async_context = g_main_context_get_thread_default ();
- if (priv->async_context)
- g_main_context_ref (priv->async_context);
- }
- socket_props_changed = TRUE;
- break;
case PROP_TIMEOUT:
priv->io_timeout = g_value_get_uint (value);
socket_props_changed = TRUE;
@@ -628,12 +572,6 @@ soup_session_get_property (GObject *object, guint prop_id,
case PROP_SSL_STRICT:
g_value_set_boolean (value, priv->ssl_strict);
break;
- case PROP_ASYNC_CONTEXT:
- g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) :
NULL);
- break;
- case PROP_USE_THREAD_CONTEXT:
- g_value_set_boolean (value, priv->use_thread_context);
- break;
case PROP_TIMEOUT:
g_value_set_uint (value, priv->io_timeout);
break;
@@ -702,34 +640,6 @@ soup_session_new_with_options (const char *optname1,
return session;
}
-/**
- * soup_session_get_async_context:
- * @session: a #SoupSession
- *
- * Gets @session's #SoupSession:async-context. This does not add a ref
- * to the context, so you will need to ref it yourself if you want it
- * to outlive its session.
- *
- * For a modern #SoupSession, this will always just return the
- * thread-default #GMainContext, and so is not especially useful.
- *
- * Return value: (nullable) (transfer none): @session's #GMainContext,
- * which may be %NULL
- **/
-GMainContext *
-soup_session_get_async_context (SoupSession *session)
-{
- SoupSessionPrivate *priv;
-
- g_return_val_if_fail (SOUP_IS_SESSION (session), NULL);
- priv = soup_session_get_instance_private (session);
-
- if (priv->use_thread_context)
- return g_main_context_get_thread_default ();
- else
- return priv->async_context;
-}
-
/* Hosts */
/* Note that we can't use soup_uri_host_hash() and soup_uri_host_equal()
@@ -1736,7 +1646,7 @@ async_run_queue (SoupSession *session)
continue;
if (!item->async ||
- item->async_context != soup_session_get_async_context (session))
+ item->async_context != g_main_context_get_thread_default ())
continue;
item->async_pending = FALSE;
@@ -1791,18 +1701,6 @@ idle_run_queue_dnotify (gpointer user_data)
* qv.
**/
-static void
-soup_session_real_queue_message (SoupSession *session, SoupMessage *msg,
- SoupSessionCallback callback, gpointer user_data)
-{
- SoupMessageQueueItem *item;
-
- item = soup_session_append_queue_item (session, msg, TRUE, FALSE,
- callback, user_data);
- soup_session_kick_queue (session);
- soup_message_queue_item_unref (item);
-}
-
/**
* soup_session_queue_message:
* @session: a #SoupSession
@@ -1827,25 +1725,40 @@ soup_session_real_queue_message (SoupSession *session, SoupMessage *msg,
*/
void
soup_session_queue_message (SoupSession *session, SoupMessage *msg,
- SoupSessionCallback callback, gpointer user_data)
+ SoupSessionCallback callback, gpointer user_data)
{
+ SoupMessageQueueItem *item;
+
g_return_if_fail (SOUP_IS_SESSION (session));
g_return_if_fail (SOUP_IS_MESSAGE (msg));
- SOUP_SESSION_GET_CLASS (session)->queue_message (session, msg,
- callback, user_data);
+ item = soup_session_append_queue_item (session, msg, TRUE, FALSE,
+ callback, user_data);
+ soup_session_kick_queue (session);
+ soup_message_queue_item_unref (item);
/* The SoupMessageQueueItem will hold a ref on @msg until it is
* finished, so we can drop the ref adopted from the caller now.
*/
g_object_unref (msg);
}
-static void
-soup_session_real_requeue_message (SoupSession *session, SoupMessage *msg)
+/**
+ * soup_session_requeue_message:
+ * @session: a #SoupSession
+ * @msg: the message to requeue
+ *
+ * This causes @msg to be placed back on the queue to be attempted
+ * again.
+ **/
+void
+soup_session_requeue_message (SoupSession *session, SoupMessage *msg)
{
SoupSessionPrivate *priv = soup_session_get_instance_private (session);
SoupMessageQueueItem *item;
+ g_return_if_fail (SOUP_IS_SESSION (session));
+ g_return_if_fail (SOUP_IS_MESSAGE (msg));
+
item = soup_message_queue_lookup (priv->queue, msg);
g_return_if_fail (item != NULL);
@@ -1862,37 +1775,6 @@ soup_session_real_requeue_message (SoupSession *session, SoupMessage *msg)
soup_message_queue_item_unref (item);
}
-/**
- * soup_session_requeue_message:
- * @session: a #SoupSession
- * @msg: the message to requeue
- *
- * This causes @msg to be placed back on the queue to be attempted
- * again.
- **/
-void
-soup_session_requeue_message (SoupSession *session, SoupMessage *msg)
-{
- g_return_if_fail (SOUP_IS_SESSION (session));
- g_return_if_fail (SOUP_IS_MESSAGE (msg));
-
- SOUP_SESSION_GET_CLASS (session)->requeue_message (session, msg);
-}
-
-static guint
-soup_session_real_send_message (SoupSession *session, SoupMessage *msg)
-{
- SoupMessageQueueItem *item;
- guint status;
-
- item = soup_session_append_queue_item (session, msg, FALSE, FALSE,
- NULL, NULL);
- soup_session_process_queue_item (session, item, NULL, TRUE);
- status = msg->status_code;
- soup_message_queue_item_unref (item);
- return status;
-}
-
/**
* soup_session_send_message:
* @session: a #SoupSession
@@ -1920,13 +1802,20 @@ soup_session_real_send_message (SoupSession *session, SoupMessage *msg)
guint
soup_session_send_message (SoupSession *session, SoupMessage *msg)
{
+ SoupMessageQueueItem *item;
+ guint status;
+
g_return_val_if_fail (SOUP_IS_SESSION (session), SOUP_STATUS_MALFORMED);
g_return_val_if_fail (SOUP_IS_MESSAGE (msg), SOUP_STATUS_MALFORMED);
- return SOUP_SESSION_GET_CLASS (session)->send_message (session, msg);
+ item = soup_session_append_queue_item (session, msg, FALSE, FALSE,
+ NULL, NULL);
+ soup_session_process_queue_item (session, item, NULL, TRUE);
+ status = msg->status_code;
+ soup_message_queue_item_unref (item);
+ return status;
}
-
/**
* soup_session_pause_message:
* @session: a #SoupSession
@@ -1959,8 +1848,8 @@ soup_session_pause_message (SoupSession *session,
soup_message_queue_item_unref (item);
}
-static void
-soup_session_real_kick_queue (SoupSession *session)
+void
+soup_session_kick_queue (SoupSession *session)
{
SoupSessionPrivate *priv = soup_session_get_instance_private (session);
SoupMessageQueueItem *item;
@@ -1975,7 +1864,7 @@ soup_session_real_kick_queue (SoupSession *session)
item;
item = soup_message_queue_next (priv->queue, item)) {
if (item->async) {
- GMainContext *context = item->async_context ? item->async_context :
g_main_context_default ();
+ GMainContext *context = item->async_context;
if (!g_hash_table_contains (async_pending, context)) {
if (!item->async_pending) {
@@ -2001,12 +1890,6 @@ soup_session_real_kick_queue (SoupSession *session)
}
}
-void
-soup_session_kick_queue (SoupSession *session)
-{
- SOUP_SESSION_GET_CLASS (session)->kick (session);
-}
-
/**
* soup_session_unpause_message:
* @session: a #SoupSession
@@ -2046,29 +1929,6 @@ soup_session_unpause_message (SoupSession *session,
}
-static void
-soup_session_real_cancel_message (SoupSession *session, SoupMessage *msg, guint status_code)
-{
- SoupSessionPrivate *priv = soup_session_get_instance_private (session);
- SoupMessageQueueItem *item;
-
- item = soup_message_queue_lookup (priv->queue, msg);
- g_return_if_fail (item != NULL);
-
- if (item->paused) {
- item->paused = FALSE;
-
- if (soup_message_io_in_progress (msg))
- soup_message_io_unpause (msg);
- }
-
- soup_message_set_status (msg, status_code);
- g_cancellable_cancel (item->cancellable);
-
- soup_session_kick_queue (item->session);
- soup_message_queue_item_unref (item);
-}
-
/**
* soup_session_cancel_message:
* @session: a #SoupSession
@@ -2100,42 +1960,36 @@ soup_session_real_cancel_message (SoupSession *session, SoupMessage *msg, guint
* returning to the main loop.
**/
void
-soup_session_cancel_message (SoupSession *session, SoupMessage *msg,
- guint status_code)
+soup_session_cancel_message (SoupSession *session, SoupMessage *msg, guint status_code)
{
- SoupSessionPrivate *priv;
+ SoupSessionPrivate *priv = soup_session_get_instance_private (session);
SoupMessageQueueItem *item;
g_return_if_fail (SOUP_IS_SESSION (session));
g_return_if_fail (SOUP_IS_MESSAGE (msg));
- priv = soup_session_get_instance_private (session);
item = soup_message_queue_lookup (priv->queue, msg);
- /* If the message is already ending, don't do anything */
+ /* If the message is already ending, don't do anything */
if (!item)
- return;
+ return;
+
if (item->state == SOUP_MESSAGE_FINISHED) {
soup_message_queue_item_unref (item);
return;
}
- SOUP_SESSION_GET_CLASS (session)->cancel_message (session, msg, status_code);
- soup_message_queue_item_unref (item);
-}
-
-static void
-soup_session_real_flush_queue (SoupSession *session)
-{
- SoupSessionPrivate *priv = soup_session_get_instance_private (session);
- SoupMessageQueueItem *item;
+ if (item->paused) {
+ item->paused = FALSE;
- /* Cancel everything */
- for (item = soup_message_queue_first (priv->queue);
- item;
- item = soup_message_queue_next (priv->queue, item)) {
- soup_session_cancel_message (session, item->msg,
- SOUP_STATUS_CANCELLED);
+ if (soup_message_io_in_progress (msg))
+ soup_message_io_unpause (msg);
}
+
+ soup_message_set_status (msg, status_code);
+ g_cancellable_cancel (item->cancellable);
+
+ soup_session_kick_queue (item->session);
+ soup_message_queue_item_unref (item);
}
/**
@@ -2154,9 +2008,18 @@ soup_session_real_flush_queue (SoupSession *session)
void
soup_session_abort (SoupSession *session)
{
+ SoupSessionPrivate *priv = soup_session_get_instance_private (session);
+ SoupMessageQueueItem *item;
+
g_return_if_fail (SOUP_IS_SESSION (session));
- SOUP_SESSION_GET_CLASS (session)->flush_queue (session);
+ /* Cancel everything */
+ for (item = soup_message_queue_first (priv->queue);
+ item;
+ item = soup_message_queue_next (priv->queue, item)) {
+ soup_session_cancel_message (session, item->msg,
+ SOUP_STATUS_CANCELLED);
+ }
soup_session_cleanup_connections (session, TRUE);
}
@@ -2178,7 +2041,7 @@ prefetch_uri (SoupSession *session, SoupURI *uri,
g_mutex_unlock (&priv->conn_lock);
soup_address_resolve_async (addr,
- soup_session_get_async_context (session),
+ priv->async_context,
cancellable, callback, user_data);
g_object_unref (addr);
}
@@ -2536,16 +2399,7 @@ soup_session_class_init (SoupSessionClass *session_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (session_class);
- /* virtual method definition */
- session_class->queue_message = soup_session_real_queue_message;
- session_class->send_message = soup_session_real_send_message;
- session_class->requeue_message = soup_session_real_requeue_message;
- session_class->cancel_message = soup_session_real_cancel_message;
- session_class->flush_queue = soup_session_real_flush_queue;
- session_class->kick = soup_session_real_kick_queue;
-
/* virtual method override */
- object_class->constructor = soup_session_constructor;
object_class->dispose = soup_session_dispose;
object_class->finalize = soup_session_finalize;
object_class->set_property = soup_session_set_property;
@@ -2929,61 +2783,7 @@ soup_session_class_init (SoupSessionClass *session_class)
TRUE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
- /**
- * SoupSession:async-context:
- *
- * The #GMainContext that miscellaneous session-related
- * asynchronous callbacks are invoked on. (Eg, setting
- * #SoupSession:idle-timeout will add a timeout source on this
- * context.)
- *
- * For a plain #SoupSession, this property is always set to
- * the #GMainContext that is the thread-default at the time
- * the session was created, and cannot be overridden. For the
- * deprecated #SoupSession subclasses, the default value is
- * %NULL, meaning to use the global default #GMainContext.
- *
- * If #SoupSession:use-thread-context is %FALSE, this context
- * will also be used for asynchronous HTTP I/O.
- */
- /**
- * SOUP_SESSION_ASYNC_CONTEXT:
- *
- * Alias for the #SoupSession:async-context property, qv.
- */
- g_object_class_install_property (
- object_class, PROP_ASYNC_CONTEXT,
- g_param_spec_pointer (SOUP_SESSION_ASYNC_CONTEXT,
- "Async GMainContext",
- "The GMainContext to dispatch async I/O in",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
- /**
- * SOUP_SESSION_USE_THREAD_CONTEXT:
- *
- * Alias for the #SoupSession:use-thread-context property, qv.
- *
- * Since: 2.38
- */
- /**
- * SoupSession:use-thread-context:
- *
- * If %TRUE (which it always is on a plain #SoupSession),
- * asynchronous HTTP requests in this session will run in
- * whatever the thread-default #GMainContext is at the time
- * they are started, rather than always occurring in
- * #SoupSession:async-context.
- *
- * Since: 2.38
- */
- g_object_class_install_property (
- object_class, PROP_USE_THREAD_CONTEXT,
- g_param_spec_boolean (SOUP_SESSION_USE_THREAD_CONTEXT,
- "Use thread-default GMainContext",
- "Whether to use thread-default main contexts",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+
/**
* SoupSession:timeout:
*
@@ -3508,7 +3308,9 @@ try_run_until_read (SoupMessageQueueItem *item)
g_clear_error (&error);
item->io_source = soup_message_io_get_source (item->msg, item->cancellable,
read_ready_cb, item);
- g_source_attach (item->io_source, soup_session_get_async_context (item->session));
+
+ SoupSessionPrivate *priv = soup_session_get_instance_private (item->session);
+ g_source_attach (item->io_source, priv->async_context);
}
static void
@@ -3733,15 +3535,9 @@ soup_session_send_async (SoupSession *session,
gpointer user_data)
{
SoupMessageQueueItem *item;
- gboolean use_thread_context;
g_return_if_fail (SOUP_IS_SESSION (session));
- g_object_get (G_OBJECT (session),
- SOUP_SESSION_USE_THREAD_CONTEXT, &use_thread_context,
- NULL);
- g_return_if_fail (use_thread_context);
-
item = soup_session_append_queue_item (session, msg, TRUE, TRUE,
NULL, NULL);
g_signal_connect (msg, "restarted",
@@ -3866,7 +3662,6 @@ soup_session_send (SoupSession *session,
GError *my_error = NULL;
g_return_val_if_fail (SOUP_IS_SESSION (session), NULL);
- g_return_val_if_fail (!SOUP_IS_SESSION_ASYNC (session), NULL);
item = soup_session_append_queue_item (session, msg, FALSE, TRUE,
NULL, NULL);
@@ -4162,8 +3957,6 @@ steal_connection (SoupSession *session,
SoupSocket *sock;
GIOStream *stream;
- g_message ("steal_connection");
-
conn = g_object_ref (item->conn);
soup_session_set_item_connection (session, item, NULL);
@@ -4342,14 +4135,12 @@ soup_session_websocket_connect_async (SoupSession *session,
GAsyncReadyCallback callback,
gpointer user_data)
{
- SoupSessionPrivate *priv = soup_session_get_instance_private (session);
SoupMessageQueueItem *item;
GTask *task;
GPtrArray *supported_extensions;
SoupMessageFlags flags;
g_return_if_fail (SOUP_IS_SESSION (session));
- g_return_if_fail (priv->use_thread_context);
g_return_if_fail (SOUP_IS_MESSAGE (msg));
supported_extensions = soup_session_get_supported_websocket_extensions_for_message (session, msg);
diff --git a/libsoup/soup-session.h b/libsoup/soup-session.h
index d8e5ce9e..ff775227 100644
--- a/libsoup/soup-session.h
+++ b/libsoup/soup-session.h
@@ -39,22 +39,9 @@ typedef struct {
SoupAuth *auth, gboolean retrying);
/* methods */
- void (*queue_message) (SoupSession *session, SoupMessage *msg,
- SoupSessionCallback callback,
- gpointer user_data);
- void (*requeue_message) (SoupSession *session, SoupMessage *msg);
- guint (*send_message) (SoupSession *session, SoupMessage *msg);
-
- void (*cancel_message) (SoupSession *session, SoupMessage *msg,
- guint status_code);
-
void (*auth_required) (SoupSession *session, SoupMessage *msg,
SoupAuth *auth, gboolean retrying);
- void (*flush_queue) (SoupSession *session);
-
- void (*kick) (SoupSession *session);
-
/* Padding for future expansion */
void (*_libsoup_reserved4) (void);
} SoupSessionClass;
@@ -70,8 +57,6 @@ GType soup_session_get_type (void);
#define SOUP_SESSION_TLS_DATABASE "tls-database"
#define SOUP_SESSION_SSL_STRICT "ssl-strict"
#define SOUP_SESSION_TLS_INTERACTION "tls-interaction"
-#define SOUP_SESSION_ASYNC_CONTEXT "async-context"
-#define SOUP_SESSION_USE_THREAD_CONTEXT "use-thread-context"
#define SOUP_SESSION_TIMEOUT "timeout"
#define SOUP_SESSION_USER_AGENT "user-agent"
#define SOUP_SESSION_ACCEPT_LANGUAGE "accept-language"
@@ -117,9 +102,6 @@ void soup_session_cancel_message (SoupSession *session,
SOUP_AVAILABLE_IN_2_4
void soup_session_abort (SoupSession *session);
-SOUP_AVAILABLE_IN_2_4
-GMainContext *soup_session_get_async_context(SoupSession *session);
-
SOUP_AVAILABLE_IN_2_42
void soup_session_send_async (SoupSession *session,
SoupMessage *msg,
diff --git a/libsoup/soup-socket-private.h b/libsoup/soup-socket-private.h
index bc6c105e..1d4d6f45 100644
--- a/libsoup/soup-socket-private.h
+++ b/libsoup/soup-socket-private.h
@@ -51,9 +51,6 @@ gboolean soup_socket_listen_full (SoupSocket *sock,
typedef struct {
- GMainContext *async_context;
- gboolean use_thread_context;
-
GProxyResolver *proxy_resolver;
SoupAddress *local_addr;
@@ -71,9 +68,7 @@ typedef struct {
GType soup_socket_properties_get_type (void);
#define SOUP_TYPE_SOCKET_PROPERTIES (soup_socket_properties_get_type ())
-SoupSocketProperties *soup_socket_properties_new (GMainContext *async_context,
- gboolean use_thread_context,
- GProxyResolver *proxy_resolver,
+SoupSocketProperties *soup_socket_properties_new (GProxyResolver *proxy_resolver,
SoupAddress *local_addr,
GTlsDatabase *tlsdb,
GTlsInteraction *tls_interaction,
@@ -84,7 +79,4 @@ SoupSocketProperties *soup_socket_properties_new (GMainContext *async_conte
SoupSocketProperties *soup_socket_properties_ref (SoupSocketProperties *props);
void soup_socket_properties_unref (SoupSocketProperties *props);
-void soup_socket_properties_push_async_context (SoupSocketProperties *props);
-void soup_socket_properties_pop_async_context (SoupSocketProperties *props);
-
#endif /* __SOUP_SOCKET_PRIVATE_H__ */
diff --git a/libsoup/soup-socket-properties.c b/libsoup/soup-socket-properties.c
index 3c99be73..38bfea3c 100644
--- a/libsoup/soup-socket-properties.c
+++ b/libsoup/soup-socket-properties.c
@@ -11,9 +11,7 @@
#include "soup.h"
SoupSocketProperties *
-soup_socket_properties_new (GMainContext *async_context,
- gboolean use_thread_context,
- GProxyResolver *proxy_resolver,
+soup_socket_properties_new (GProxyResolver *proxy_resolver,
SoupAddress *local_addr,
GTlsDatabase *tlsdb,
GTlsInteraction *tls_interaction,
@@ -26,9 +24,6 @@ soup_socket_properties_new (GMainContext *async_context,
props = g_slice_new (SoupSocketProperties);
props->ref_count = 1;
- props->async_context = async_context ? g_main_context_ref (async_context) : NULL;
- props->use_thread_context = use_thread_context;
-
props->proxy_resolver = proxy_resolver ? g_object_ref (proxy_resolver) : NULL;
props->local_addr = local_addr ? g_object_ref (local_addr) : NULL;
@@ -55,7 +50,6 @@ soup_socket_properties_unref (SoupSocketProperties *props)
if (!g_atomic_int_dec_and_test (&props->ref_count))
return;
- g_clear_pointer (&props->async_context, g_main_context_unref);
g_clear_object (&props->proxy_resolver);
g_clear_object (&props->local_addr);
g_clear_object (&props->tlsdb);
@@ -64,18 +58,5 @@ soup_socket_properties_unref (SoupSocketProperties *props)
g_slice_free (SoupSocketProperties, props);
}
-void
-soup_socket_properties_push_async_context (SoupSocketProperties *props)
-{
- if (props->async_context && !props->use_thread_context)
- g_main_context_push_thread_default (props->async_context);
-}
-
-void
-soup_socket_properties_pop_async_context (SoupSocketProperties *props)
-{
- if (props->async_context && !props->use_thread_context)
- g_main_context_pop_thread_default (props->async_context);
-}
G_DEFINE_BOXED_TYPE (SoupSocketProperties, soup_socket_properties, soup_socket_properties_ref,
soup_socket_properties_unref)
diff --git a/libsoup/soup-socket.c b/libsoup/soup-socket.c
index 4cb69e0d..686d8eec 100644
--- a/libsoup/soup-socket.c
+++ b/libsoup/soup-socket.c
@@ -55,8 +55,6 @@ enum {
PROP_SSL_CREDENTIALS,
PROP_SSL_STRICT,
PROP_SSL_FALLBACK,
- PROP_ASYNC_CONTEXT,
- PROP_USE_THREAD_CONTEXT,
PROP_TIMEOUT,
PROP_TRUSTED_CERTIFICATE,
PROP_TLS_CERTIFICATE,
@@ -83,7 +81,6 @@ typedef struct {
guint ssl_strict:1;
guint ssl_fallback:1;
guint clean_dispose:1;
- guint use_thread_context:1;
gpointer ssl_creds;
GMainContext *async_context;
@@ -119,6 +116,8 @@ soup_socket_init (SoupSocket *sock)
priv->fd = -1;
g_mutex_init (&priv->addrlock);
g_mutex_init (&priv->iolock);
+
+ priv->async_context = g_main_context_ref_thread_default ();
}
static gboolean
@@ -309,20 +308,7 @@ soup_socket_set_property (GObject *object, guint prop_id,
case PROP_SSL_FALLBACK:
priv->ssl_fallback = g_value_get_boolean (value);
break;
- case PROP_ASYNC_CONTEXT:
- if (!priv->use_thread_context) {
- priv->async_context = g_value_get_pointer (value);
- if (priv->async_context)
- g_main_context_ref (priv->async_context);
- }
- break;
- case PROP_USE_THREAD_CONTEXT:
- priv->use_thread_context = g_value_get_boolean (value);
- if (priv->use_thread_context) {
- g_clear_pointer (&priv->async_context, g_main_context_unref);
- priv->async_context = g_main_context_ref_thread_default ();
- }
- break;
+
case PROP_TIMEOUT:
priv->timeout = g_value_get_uint (value);
if (priv->conn)
@@ -331,16 +317,6 @@ soup_socket_set_property (GObject *object, guint prop_id,
case PROP_SOCKET_PROPERTIES:
props = g_value_get_boxed (value);
if (props) {
- g_clear_pointer (&priv->async_context, g_main_context_unref);
- if (props->use_thread_context) {
- priv->use_thread_context = TRUE;
- priv->async_context = g_main_context_ref_thread_default ();
- } else {
- priv->use_thread_context = FALSE;
- if (props->async_context)
- priv->async_context = g_main_context_ref (props->async_context);
- }
-
g_clear_object (&priv->proxy_resolver);
if (props->proxy_resolver)
priv->proxy_resolver = g_object_ref (props->proxy_resolver);
@@ -408,12 +384,6 @@ soup_socket_get_property (GObject *object, guint prop_id,
case PROP_TRUSTED_CERTIFICATE:
g_value_set_boolean (value, priv->tls_errors == 0);
break;
- case PROP_ASYNC_CONTEXT:
- g_value_set_pointer (value, priv->async_context ? g_main_context_ref (priv->async_context) :
NULL);
- break;
- case PROP_USE_THREAD_CONTEXT:
- g_value_set_boolean (value, priv->use_thread_context);
- break;
case PROP_TIMEOUT:
g_value_set_uint (value, priv->timeout);
break;
@@ -717,43 +687,6 @@ soup_socket_class_init (SoupSocketClass *socket_class)
FALSE,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
- /**
- * SOUP_SOCKET_ASYNC_CONTEXT:
- *
- * Alias for the #SoupSocket:async-context property. (The
- * socket's #GMainContext.)
- **/
- g_object_class_install_property (
- object_class, PROP_ASYNC_CONTEXT,
- g_param_spec_pointer (SOUP_SOCKET_ASYNC_CONTEXT,
- "Async GMainContext",
- "The GMainContext to dispatch this socket's async I/O in",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- /**
- * SOUP_SOCKET_USE_THREAD_CONTEXT:
- *
- * Alias for the #SoupSocket:use-thread-context property. (Use
- * g_main_context_get_thread_default())
- *
- * Since: 2.38
- */
- /**
- * SoupSocket:use-thread-context:
- *
- * Use g_main_context_get_thread_default().
- *
- * Since: 2.38
- */
- g_object_class_install_property (
- object_class, PROP_USE_THREAD_CONTEXT,
- g_param_spec_boolean (SOUP_SOCKET_USE_THREAD_CONTEXT,
- "Use thread context",
- "Use g_main_context_get_thread_default",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
/**
* SOUP_SOCKET_TIMEOUT:
@@ -1047,15 +980,9 @@ soup_socket_connect_async (SoupSocket *sock, GCancellable *cancellable,
sacd->callback = callback;
sacd->user_data = user_data;
- if (priv->async_context && !priv->use_thread_context)
- g_main_context_push_thread_default (priv->async_context);
-
soup_socket_connect_async_internal (sock, cancellable,
legacy_connect_async_cb,
sacd);
-
- if (priv->async_context && !priv->use_thread_context)
- g_main_context_pop_thread_default (priv->async_context);
}
gboolean
@@ -1224,9 +1151,7 @@ listen_watch (GObject *pollable, gpointer data)
new = g_object_new (SOUP_TYPE_SOCKET, NULL);
new_priv = soup_socket_get_instance_private (new);
new_priv->gsock = new_gsock;
- if (priv->async_context)
- new_priv->async_context = g_main_context_ref (priv->async_context);
- new_priv->use_thread_context = priv->use_thread_context;
+ new_priv->async_context = g_main_context_ref (priv->async_context);
new_priv->non_blocking = priv->non_blocking;
new_priv->clean_dispose = priv->clean_dispose;
new_priv->is_server = TRUE;
diff --git a/libsoup/soup-socket.h b/libsoup/soup-socket.h
index 4dfc24dc..1e70d906 100644
--- a/libsoup/soup-socket.h
+++ b/libsoup/soup-socket.h
@@ -47,8 +47,6 @@ typedef struct {
#define SOUP_SOCKET_SSL_STRICT "ssl-strict"
#define SOUP_SOCKET_SSL_FALLBACK "ssl-fallback"
#define SOUP_SOCKET_TRUSTED_CERTIFICATE "trusted-certificate"
-#define SOUP_SOCKET_ASYNC_CONTEXT "async-context"
-#define SOUP_SOCKET_USE_THREAD_CONTEXT "use-thread-context"
#define SOUP_SOCKET_TIMEOUT "timeout"
#define SOUP_SOCKET_TLS_CERTIFICATE "tls-certificate"
#define SOUP_SOCKET_TLS_ERRORS "tls-errors"
diff --git a/libsoup/soup.h b/libsoup/soup.h
index b8fedbaa..a41c9c1c 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -42,7 +42,7 @@ extern "C" {
#include "soup-request-file.h"
#include "soup-request-http.h"
#include "soup-server.h"
-#include "soup-session-async.h"
+#include "soup-session.h"
#include "soup-session-feature.h"
#include "soup-socket.h"
#include "soup-status.h"
diff --git a/tests/cache-test.c b/tests/cache-test.c
index b1e7bc93..29b409ff 100644
--- a/tests/cache-test.c
+++ b/tests/cache-test.c
@@ -294,7 +294,6 @@ do_basics_test (gconstpointer data)
debug_printf (2, " Caching to %s\n", cache_dir);
cache = soup_cache_new (cache_dir, SOUP_CACHE_SINGLE_USER);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, cache,
NULL);
@@ -489,7 +488,6 @@ do_cancel_test (gconstpointer data)
debug_printf (2, " Caching to %s\n", cache_dir);
cache = soup_cache_new (cache_dir, SOUP_CACHE_SINGLE_USER);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, cache,
NULL);
g_signal_connect (session, "request-unqueued",
@@ -523,7 +521,6 @@ do_cancel_test (gconstpointer data)
soup_test_session_abort_unref (session);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, cache,
NULL);
g_signal_connect (session, "request-unqueued",
@@ -585,7 +582,6 @@ do_refcounting_test (gconstpointer data)
debug_printf (2, " Caching to %s\n", cache_dir);
cache = soup_cache_new (cache_dir, SOUP_CACHE_SINGLE_USER);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, cache,
NULL);
@@ -641,7 +637,6 @@ do_headers_test (gconstpointer data)
debug_printf (2, " Caching to %s\n", cache_dir);
cache = soup_cache_new (cache_dir, SOUP_CACHE_SINGLE_USER);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, cache,
NULL);
@@ -719,7 +714,6 @@ do_leaks_test (gconstpointer data)
debug_printf (2, " Caching to %s\n", cache_dir);
cache = soup_cache_new (cache_dir, SOUP_CACHE_SINGLE_USER);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, cache,
NULL);
diff --git a/tests/coding-test.c b/tests/coding-test.c
index 56a5720d..a7c59650 100644
--- a/tests/coding-test.c
+++ b/tests/coding-test.c
@@ -181,7 +181,6 @@ setup_coding_test (CodingTestData *data, gconstpointer test_data)
SoupURI *uri;
data->session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
uri = soup_uri_new_with_base (base_uri, "/mbox");
diff --git a/tests/connection-test.c b/tests/connection-test.c
index bacace3b..d6e4dc6e 100644
--- a/tests/connection-test.c
+++ b/tests/connection-test.c
@@ -386,7 +386,6 @@ do_persistent_connection_timeout_test (void)
debug_printf (1, " Normal session, request API\n");
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
do_timeout_req_test_for_session (session);
soup_test_session_abort_unref (session);
diff --git a/tests/context-test.c b/tests/context-test.c
index 0aec2651..406c4560 100644
--- a/tests/context-test.c
+++ b/tests/context-test.c
@@ -188,7 +188,6 @@ do_test2 (void)
async_context = g_main_context_new ();
g_main_context_push_thread_default (async_context);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
g_main_context_unref (async_context);
@@ -247,7 +246,6 @@ do_multicontext_test (void)
GMainLoop *loop1, *loop2;
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
context1 = g_main_context_new ();
diff --git a/tests/hsts-db-test.c b/tests/hsts-db-test.c
index 1dfa9931..c01cf045 100644
--- a/tests/hsts-db-test.c
+++ b/tests/hsts-db-test.c
@@ -106,7 +106,6 @@ hsts_db_session_new (void)
SoupHSTSEnforcer *hsts_db = soup_hsts_enforcer_db_new (DB_FILE);
SoupSession *session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, hsts_db,
NULL);
g_signal_connect (session, "request-queued", G_CALLBACK (on_request_queued), NULL);
diff --git a/tests/hsts-test.c b/tests/hsts-test.c
index 5f70e4f2..2d2257ca 100644
--- a/tests/hsts-test.c
+++ b/tests/hsts-test.c
@@ -153,12 +153,10 @@ hsts_session_new (SoupHSTSEnforcer *enforcer)
if (enforcer)
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, enforcer,
NULL);
else
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_HSTS_ENFORCER,
NULL);
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 9cac3958..2522029d 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -282,7 +282,6 @@ do_callback_unref_req_test (void)
soup_test_server_quit_unref (bad_server);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
g_object_add_weak_pointer (G_OBJECT (session), (gpointer *)&session);
@@ -564,7 +563,6 @@ do_early_abort_req_test (void)
GCancellable *cancellable;
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
req = soup_session_request_uri (session, base_uri, NULL);
@@ -580,7 +578,6 @@ do_early_abort_req_test (void)
soup_test_session_abort_unref (session);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
req = soup_session_request_uri (session, base_uri, NULL);
@@ -596,7 +593,6 @@ do_early_abort_req_test (void)
soup_test_session_abort_unref (session);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
req = soup_session_request_uri (session, base_uri, NULL);
@@ -751,7 +747,6 @@ do_cancel_while_reading_immediate_req_test (void)
flags = SOUP_TEST_REQUEST_CANCEL_CANCELLABLE | SOUP_TEST_REQUEST_CANCEL_IMMEDIATE;
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
do_cancel_while_reading_req_test_for_session (session, flags);
soup_test_session_abort_unref (session);
@@ -766,7 +761,6 @@ do_cancel_while_reading_delayed_req_test (void)
flags = SOUP_TEST_REQUEST_CANCEL_CANCELLABLE | SOUP_TEST_REQUEST_CANCEL_SOON;
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
do_cancel_while_reading_req_test_for_session (session, flags);
soup_test_session_abort_unref (session);
@@ -783,7 +777,6 @@ do_cancel_while_reading_preemptive_req_test (void)
flags = SOUP_TEST_REQUEST_CANCEL_CANCELLABLE | SOUP_TEST_REQUEST_CANCEL_PREEMPTIVE;
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
do_cancel_while_reading_req_test_for_session (session, flags);
soup_test_session_abort_unref (session);
diff --git a/tests/multipart-test.c b/tests/multipart-test.c
index 50c1e1cf..c0c09dc8 100644
--- a/tests/multipart-test.c
+++ b/tests/multipart-test.c
@@ -498,7 +498,6 @@ main (int argc, char **argv)
* was hitting the limit, which indicates some connections are not dying.
*/
session = soup_test_session_new (SOUP_TYPE_SESSION,
- "use-thread-context", TRUE,
"max-conns", 20,
"max-conns-per-host", 20,
NULL);
diff --git a/tests/no-ssl-test.c b/tests/no-ssl-test.c
index 8cb4ffa2..92253a9c 100644
--- a/tests/no-ssl-test.c
+++ b/tests/no-ssl-test.c
@@ -36,39 +36,6 @@ do_ssl_tests (gconstpointer data)
soup_test_session_abort_unref (session);
}
-static void
-do_session_property_tests (void)
-{
- gboolean use_system;
- GTlsDatabase *tlsdb;
- SoupSession *session;
-
- g_test_bug ("700518");
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- session = soup_session_async_new ();
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- g_object_get (G_OBJECT (session),
- "ssl-use-system-ca-file", &use_system,
- "tls-database", &tlsdb,
- NULL);
- soup_test_assert (!use_system, "ssl-use-system-ca-file defaults to TRUE");
- soup_test_assert (tlsdb == NULL, "tls-database set by default");
-
- g_object_set (G_OBJECT (session),
- "tls-database", NULL,
- NULL);
- g_object_get (G_OBJECT (session),
- "ssl-use-system-ca-file", &use_system,
- "tls-database", &tlsdb,
- NULL);
- soup_test_assert (tlsdb == NULL, "setting tls-database NULL failed");
- soup_test_assert (!use_system, "setting tls-database NULL set ssl-use-system-ca-file");
-
- soup_test_session_abort_unref (session);
-}
-
static void
server_handler (SoupServer *server,
SoupMessage *msg,
@@ -107,7 +74,6 @@ main (int argc, char **argv)
soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTPS);
soup_uri_set_port (uri, port);
- g_test_add_func ("/no-ssl/session-properties", do_session_property_tests);
g_test_add_data_func ("/no-ssl/request-error", uri, do_ssl_tests);
ret = g_test_run ();
diff --git a/tests/proxy-test.c b/tests/proxy-test.c
index 2a3d4d41..d21b857f 100644
--- a/tests/proxy-test.c
+++ b/tests/proxy-test.c
@@ -95,7 +95,6 @@ test_url (const char *url, int proxy, guint expected, gboolean close)
*/
session = soup_test_session_new (SOUP_TYPE_SESSION,
SOUP_SESSION_PROXY_RESOLVER, proxy_resolvers[proxy],
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_SSL_STRICT, FALSE,
NULL);
g_signal_connect (session, "authenticate",
@@ -145,7 +144,6 @@ test_url_new_api (const char *url, int proxy, guint expected, gboolean close)
* connections/auth aren't cached between tests.
*/
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_PROXY_RESOLVER, proxy_resolvers[proxy],
SOUP_SESSION_SSL_STRICT, FALSE,
NULL);
@@ -366,7 +364,6 @@ do_proxy_auth_cache_test (void)
session = soup_test_session_new (SOUP_TYPE_SESSION,
SOUP_SESSION_PROXY_RESOLVER, proxy_resolvers[AUTH_PROXY],
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
SOUP_SESSION_ADD_FEATURE, cache,
NULL);
g_signal_connect (session, "authenticate",
diff --git a/tests/redirect-test.c b/tests/redirect-test.c
index e5640018..5d09f14d 100644
--- a/tests/redirect-test.c
+++ b/tests/redirect-test.c
@@ -405,7 +405,6 @@ main (int argc, char **argv)
loop = g_main_loop_new (NULL, TRUE);
async_session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
for (n = 0; n < n_tests; n++) {
diff --git a/tests/resource-test.c b/tests/resource-test.c
index 4c184a88..e048a2c8 100644
--- a/tests/resource-test.c
+++ b/tests/resource-test.c
@@ -80,7 +80,7 @@ do_async_request (SoupRequest *request)
data.body = g_string_new (NULL);
soup_request_send_async (request, NULL, async_request_sent, &data);
- data.loop = g_main_loop_new (soup_session_get_async_context (soup_request_get_session (request)),
TRUE);
+ data.loop = g_main_loop_new (g_main_context_get_thread_default (), TRUE);
g_main_loop_run (data.loop);
g_main_loop_unref (data.loop);
@@ -97,7 +97,6 @@ do_request (const char *uri_string, gconstpointer type)
GError *error = NULL;
session = soup_test_session_new (GPOINTER_TO_SIZE (type),
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
request = soup_session_request (session, uri_string, &error);
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index b1819684..f701a012 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -445,7 +445,6 @@ main (int argc, char **argv)
base_uri = soup_test_server_get_uri (server, "http", NULL);
session = soup_test_session_new (SOUP_TYPE_SESSION,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
soup_session_add_feature_by_type (session, SOUP_TYPE_CONTENT_SNIFFER);
diff --git a/tests/ssl-test.c b/tests/ssl-test.c
index 3047fe63..915f21fa 100644
--- a/tests/ssl-test.c
+++ b/tests/ssl-test.c
@@ -76,55 +76,6 @@ property_changed (GObject *object, GParamSpec *param, gpointer user_data)
*changed = TRUE;
}
-static void
-do_session_property_tests (void)
-{
- gboolean use_system_changed, tlsdb_changed;
- gboolean use_system;
- GTlsDatabase *tlsdb;
- SoupSession *session;
-
- g_test_bug ("673678");
-
- SOUP_TEST_SKIP_IF_NO_TLS;
-
- G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
- session = soup_session_async_new ();
- G_GNUC_END_IGNORE_DEPRECATIONS;
-
- g_signal_connect (session, "notify::ssl-use-system-ca-file",
- G_CALLBACK (property_changed), &use_system_changed);
- g_signal_connect (session, "notify::tls-database",
- G_CALLBACK (property_changed), &tlsdb_changed);
-
- g_object_get (G_OBJECT (session),
- "ssl-use-system-ca-file", &use_system,
- "tls-database", &tlsdb,
- NULL);
- soup_test_assert (!use_system,
- "ssl-use-system-ca-file defaults to TRUE");
- soup_test_assert (tlsdb == NULL,
- "tls-database set by default");
-
- use_system_changed = tlsdb_changed = FALSE;
- g_object_set (G_OBJECT (session),
- "ssl-use-system-ca-file", TRUE,
- NULL);
- g_object_get (G_OBJECT (session),
- "ssl-use-system-ca-file", &use_system,
- "tls-database", &tlsdb,
- NULL);
- soup_test_assert (use_system,
- "setting ssl-use-system-ca-file failed");
- g_assert_true (use_system_changed);
- soup_test_assert (tlsdb != NULL,
- "setting ssl-use-system-ca-file didn't set tls-database");
- g_assert_true (tlsdb_changed);
- g_clear_object (&tlsdb);
-
- soup_test_session_abort_unref (session);
-}
-
/* GTlsInteraction subclass for do_interaction_test */
typedef GTlsInteraction TestTlsInteraction;
typedef GTlsInteractionClass TestTlsInteractionClass;
@@ -324,7 +275,6 @@ main (int argc, char **argv)
} else
uri = NULL;
- g_test_add_func ("/ssl/session-properties", do_session_property_tests);
g_test_add_func ("/ssl/tls-interaction", do_tls_interaction_test);
for (i = 0; i < G_N_ELEMENTS (strictness_tests); i++) {
diff --git a/tests/timeout-test.c b/tests/timeout-test.c
index 9b1e7df2..430d5476 100644
--- a/tests/timeout-test.c
+++ b/tests/timeout-test.c
@@ -214,11 +214,9 @@ do_async_timeout_tests (gconstpointer data)
timeout_session = soup_test_session_new (SOUP_TYPE_SESSION,
SOUP_SESSION_TIMEOUT, extra_slow ? 3 : 1,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
idle_session = soup_test_session_new (SOUP_TYPE_SESSION,
SOUP_SESSION_IDLE_TIMEOUT, extra_slow ? 2 : 1,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
/* The "plain" session also has an idle timeout, but it's longer
* than the test takes, so for our purposes it should behave like
@@ -226,7 +224,6 @@ do_async_timeout_tests (gconstpointer data)
*/
plain_session = soup_test_session_new (SOUP_TYPE_SESSION,
SOUP_SESSION_IDLE_TIMEOUT, 20,
- SOUP_SESSION_USE_THREAD_CONTEXT, TRUE,
NULL);
do_msg_tests_for_session (timeout_session, idle_session, plain_session,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]