summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2023-04-13 12:32:04 +0100
committerPatrick Griffis <pgriffis@igalia.com>2023-04-13 18:17:06 +0000
commit816a38a601c8453db39082db1a54a2a426e07263 (patch)
treeb380f140ebca536bf71c6e4ad47367f31b30c0c3
parent888b6018ebb8cf3c9c33803ce9f0ea99635c4428 (diff)
downloadlibsoup-816a38a601c8453db39082db1a54a2a426e07263.tar.gz
lib: Add names to various GSources
This helps in identifying what’s attached to a `GMainContext` when debugging runtime problems with libsoup. The names added in `soup-misc.c` are fairly rough; if they turn out to not be specific enough, those methods could be changed to accept a `const gchar *name` argument so the caller can provide a more specific name. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--libsoup/http1/soup-message-io-data.c5
-rw-r--r--libsoup/http2/soup-client-message-io-http2.c17
-rw-r--r--libsoup/server/http2/soup-server-message-io-http2.c10
-rw-r--r--libsoup/server/soup-listener.c5
-rw-r--r--libsoup/soup-connection.c4
-rw-r--r--libsoup/soup-misc.c10
-rw-r--r--libsoup/websocket/soup-websocket-connection.c20
7 files changed, 70 insertions, 1 deletions
diff --git a/libsoup/http1/soup-message-io-data.c b/libsoup/http1/soup-message-io-data.c
index 49f2e591..16d5cbd0 100644
--- a/libsoup/http1/soup-message-io-data.c
+++ b/libsoup/http1/soup-message-io-data.c
@@ -177,6 +177,11 @@ soup_message_io_data_get_source (SoupMessageIOData *io,
base_source = g_timeout_source_new (0);
source = soup_message_io_source_new (base_source, msg, io && io->paused, message_io_source_check);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (source, "SoupMessageIOData");
+#else
+ g_source_set_name (source, "SoupMessageIOData");
+#endif
g_source_set_callback (source, (GSourceFunc) callback, user_data, NULL);
return source;
}
diff --git a/libsoup/http2/soup-client-message-io-http2.c b/libsoup/http2/soup-client-message-io-http2.c
index 13dcde20..3babf8a6 100644
--- a/libsoup/http2/soup-client-message-io-http2.c
+++ b/libsoup/http2/soup-client-message-io-http2.c
@@ -374,7 +374,11 @@ io_try_write (SoupClientMessageIOHTTP2 *io,
if (!blocking && (io->in_callback || g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))) {
g_clear_error (&error);
io->write_source = g_pollable_output_stream_create_source (G_POLLABLE_OUTPUT_STREAM (io->ostream), NULL);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (io->write_source, "Soup HTTP/2 write source");
+#else
g_source_set_name (io->write_source, "Soup HTTP/2 write source");
+#endif
/* Give write more priority than read */
g_source_set_priority (io->write_source, G_PRIORITY_DEFAULT - 1);
g_source_set_callback (io->write_source, (GSourceFunc)io_write_ready, io, NULL);
@@ -917,7 +921,11 @@ on_frame_send_callback (nghttp2_session *session,
/* Close in idle to ensure all pending io is finished first */
source = g_idle_source_new ();
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (source, "Soup HTTP/2 close source");
+#else
g_source_set_name (source, "Soup HTTP/2 close source");
+#endif
g_source_set_callback (source, (GSourceFunc)close_in_idle_cb, io, NULL);
g_source_attach (source, g_task_get_context (io->close_task));
g_source_unref (source);
@@ -1134,6 +1142,11 @@ on_data_source_read_callback (nghttp2_session *session,
h2_debug (data->io, data, "[SEND_BODY] Polling");
data->data_source_poll = g_pollable_input_stream_create_source (in_stream, data->item->cancellable);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (data->data_source_poll, "Soup HTTP/2 data polling");
+#else
+ g_source_set_name (data->data_source_poll, "Soup HTTP/2 data polling");
+#endif
g_source_set_callback (data->data_source_poll, (GSourceFunc)on_data_readable, data, NULL);
g_source_set_priority (data->data_source_poll, get_data_io_priority (data));
g_source_attach (data->data_source_poll, g_main_context_get_thread_default ());
@@ -1771,7 +1784,11 @@ soup_client_message_io_http2_set_owner (SoupClientMessageIOHTTP2 *io,
return;
io->read_source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (io->istream), NULL);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (io->read_source, "Soup HTTP/2 read source");
+#else
g_source_set_name (io->read_source, "Soup HTTP/2 read source");
+#endif
g_source_set_priority (io->read_source, G_PRIORITY_DEFAULT);
g_source_set_callback (io->read_source, (GSourceFunc)io_read_ready, io, NULL);
g_source_attach (io->read_source, g_main_context_get_thread_default ());
diff --git a/libsoup/server/http2/soup-server-message-io-http2.c b/libsoup/server/http2/soup-server-message-io-http2.c
index f782dcef..743ff7fb 100644
--- a/libsoup/server/http2/soup-server-message-io-http2.c
+++ b/libsoup/server/http2/soup-server-message-io-http2.c
@@ -398,7 +398,11 @@ io_try_write (SoupServerMessageIOHTTP2 *io)
if (io->in_callback || g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) {
g_clear_error (&error);
io->write_source = g_pollable_output_stream_create_source (G_POLLABLE_OUTPUT_STREAM (io->ostream), NULL);
- g_source_set_name (io->write_source, "S oup server HTTP/2 write source");
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (io->write_source, "Soup server HTTP/2 write source");
+#else
+ g_source_set_name (io->write_source, "Soup server HTTP/2 write source");
+#endif
g_source_set_callback (io->write_source, (GSourceFunc)io_write_ready, io, NULL);
g_source_attach (io->write_source, g_main_context_get_thread_default ());
}
@@ -860,7 +864,11 @@ soup_server_message_io_http2_new (SoupServerConnection *conn,
soup_server_message_io_http2_init (io);
io->read_source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (io->istream), NULL);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (io->read_source, "Soup server HTTP/2 read source");
+#else
g_source_set_name (io->read_source, "Soup server HTTP/2 read source");
+#endif
g_source_set_callback (io->read_source, (GSourceFunc)io_read_ready, io, NULL);
g_source_attach (io->read_source, g_main_context_get_thread_default ());
diff --git a/libsoup/server/soup-listener.c b/libsoup/server/soup-listener.c
index 13fe6704..2ad9799a 100644
--- a/libsoup/server/soup-listener.c
+++ b/libsoup/server/soup-listener.c
@@ -96,6 +96,11 @@ soup_listener_constructed (GObject *object)
priv->conn = (GIOStream *)g_socket_connection_factory_create_connection (priv->socket);
priv->iostream = soup_io_stream_new (priv->conn, FALSE);
priv->source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (g_io_stream_get_input_stream (priv->iostream)), NULL);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (priv->source, "SoupListener");
+#else
+ g_source_set_name (priv->source, "SoupListener");
+#endif
g_source_set_callback (priv->source, (GSourceFunc)listen_watch, listener, NULL);
g_source_attach (priv->source, g_main_context_get_thread_default ());
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index d764ceca..4007f282 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -170,7 +170,11 @@ soup_connection_set_property (GObject *object, guint prop_id,
case PROP_CONTEXT:
priv->idle_timeout_src = g_timeout_source_new (0);
g_source_set_ready_time (priv->idle_timeout_src, -1);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (priv->idle_timeout_src, "Soup connection idle timeout");
+#else
g_source_set_name (priv->idle_timeout_src, "Soup connection idle timeout");
+#endif
g_source_set_callback (priv->idle_timeout_src, idle_timeout, object, NULL);
g_source_attach (priv->idle_timeout_src, g_value_get_pointer (value));
break;
diff --git a/libsoup/soup-misc.c b/libsoup/soup-misc.c
index 21018075..414b0874 100644
--- a/libsoup/soup-misc.c
+++ b/libsoup/soup-misc.c
@@ -61,6 +61,11 @@ soup_add_completion_reffed (GMainContext *async_context,
{
GSource *source = g_idle_source_new ();
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (source, "SoupCompletion");
+#else
+ g_source_set_name (source, "SoupCompletion");
+#endif
g_source_set_priority (source, G_PRIORITY_DEFAULT);
g_source_set_callback (source, function, data, dnotify);
g_source_attach (source, async_context);
@@ -109,6 +114,11 @@ soup_add_timeout (GMainContext *async_context,
GSourceFunc function, gpointer data)
{
GSource *source = g_timeout_source_new (interval);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (source, "SoupTimeout");
+#else
+ g_source_set_name (source, "SoupTimeout");
+#endif
g_source_set_callback (source, function, data, NULL);
g_source_attach (source, async_context);
return source;
diff --git a/libsoup/websocket/soup-websocket-connection.c b/libsoup/websocket/soup-websocket-connection.c
index f1aaba24..2f7d9204 100644
--- a/libsoup/websocket/soup-websocket-connection.c
+++ b/libsoup/websocket/soup-websocket-connection.c
@@ -299,6 +299,11 @@ soup_websocket_connection_start_input_source (SoupWebsocketConnection *self)
return;
priv->input_source = g_pollable_input_stream_create_source (priv->input, NULL);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (priv->input_source, "SoupWebsocketConnection input");
+#else
+ g_source_set_name (priv->input_source, "SoupWebsocketConnection input");
+#endif
g_source_set_callback (priv->input_source, (GSourceFunc)on_web_socket_input, self, NULL);
g_source_attach (priv->input_source, g_main_context_get_thread_default ());
}
@@ -325,6 +330,11 @@ soup_websocket_connection_start_output_source (SoupWebsocketConnection *self)
return;
priv->output_source = g_pollable_output_stream_create_source (priv->output, NULL);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (priv->output_source, "SoupWebsocketConnection output");
+#else
+ g_source_set_name (priv->output_source, "SoupWebsocketConnection output");
+#endif
g_source_set_callback (priv->output_source, (GSourceFunc)on_web_socket_output, self, NULL);
g_source_attach (priv->output_source, g_main_context_get_thread_default ());
}
@@ -437,6 +447,11 @@ close_io_after_timeout (SoupWebsocketConnection *self)
g_debug ("waiting %d seconds for peer to close io", timeout);
priv->close_timeout = g_timeout_source_new_seconds (timeout);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (priv->close_timeout, "SoupWebsocketConnection close timeout");
+#else
+ g_source_set_name (priv->close_timeout, "SoupWebsocketConnection close timeout");
+#endif
g_source_set_callback (priv->close_timeout, on_timeout_close_io, self, NULL);
g_source_attach (priv->close_timeout, g_main_context_get_thread_default ());
}
@@ -2153,6 +2168,11 @@ soup_websocket_connection_set_keepalive_interval (SoupWebsocketConnection *self,
if (interval > 0) {
priv->keepalive_timeout = g_timeout_source_new_seconds (interval);
+#if GLIB_CHECK_VERSION(2, 70, 0)
+ g_source_set_static_name (priv->keepalive_timeout, "SoupWebsocketConnection keepalive timeout");
+#else
+ g_source_set_name (priv->keepalive_timeout, "SoupWebsocketConnection keepalive timeout");
+#endif
g_source_set_callback (priv->keepalive_timeout, on_queue_ping, self, NULL);
g_source_attach (priv->keepalive_timeout, g_main_context_get_thread_default ());
}