[libsoup] client-message-io: pass message as parameter of several functions
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] client-message-io: pass message as parameter of several functions
- Date: Sun, 9 May 2021 09:57:47 +0000 (UTC)
commit 167c37b07f90bca9485780e9ce3f1c84c97bc8b2
Author: Patrick Griffis <pgriffis igalia com>
Date: Sun May 2 13:20:12 2021 -0500
client-message-io: pass message as parameter of several functions
libsoup/soup-client-message-io-http1.c | 33 ++++++++++++++++++-------------
libsoup/soup-client-message-io.c | 35 +++++++++++++++++++++------------
libsoup/soup-client-message-io.h | 36 +++++++++++++++++++++++++---------
libsoup/soup-message.c | 18 ++++++++---------
4 files changed, 77 insertions(+), 45 deletions(-)
---
diff --git a/libsoup/soup-client-message-io-http1.c b/libsoup/soup-client-message-io-http1.c
index a43ca715..b2279a7c 100644
--- a/libsoup/soup-client-message-io-http1.c
+++ b/libsoup/soup-client-message-io-http1.c
@@ -68,13 +68,13 @@ soup_client_message_io_http1_get_priority (SoupClientMessageIOHTTP1 *io)
}
static void
-soup_client_message_io_http1_finished (SoupClientMessageIO *iface)
+soup_client_message_io_http1_finished (SoupClientMessageIO *iface,
+ SoupMessage *msg)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
SoupMessageIOCompletionFn completion_cb;
gpointer completion_data;
SoupMessageIOCompletion completion;
- SoupMessage *msg;
completion_cb = io->base.completion_cb;
completion_data = io->base.completion_data;
@@ -85,7 +85,7 @@ soup_client_message_io_http1_finished (SoupClientMessageIO *iface)
else
completion = SOUP_MESSAGE_IO_INTERRUPTED;
- msg = g_object_ref (io->item->msg);
+ msg = g_object_ref (msg);
soup_connection_message_io_finished (soup_message_get_connection (msg), msg);
if (completion_cb)
completion_cb (G_OBJECT (msg), completion, completion_data);
@@ -734,7 +734,7 @@ io_run_until (SoupClientMessageIOHTTP1 *client_io,
GError **error)
{
SoupMessageIOData *io = &client_io->base;
- SoupMessage *msg = client_io->item->msg;
+ SoupMessage *msg;
gboolean progress = TRUE, done;
GError *my_error = NULL;
@@ -747,6 +747,8 @@ io_run_until (SoupClientMessageIOHTTP1 *client_io,
return FALSE;
}
+ g_assert (client_io); // Silence clang static analysis
+ msg = client_io->item->msg;
g_object_ref (msg);
while (progress && (SoupClientMessageIOHTTP1 *)soup_message_get_io_data (msg) == client_io &&
@@ -841,22 +843,22 @@ soup_message_io_finish (SoupMessage *msg,
soup_message_io_finished (msg);
}
-static void soup_client_message_io_http1_run (SoupClientMessageIO *iface, gboolean blocking);
+static void soup_client_message_io_http1_run (SoupClientMessageIO *iface, SoupMessage *msg, gboolean
blocking);
static gboolean
io_run_ready (SoupMessage *msg, gpointer user_data)
{
- soup_client_message_io_http1_run (soup_message_get_io_data (msg), FALSE);
+ soup_client_message_io_http1_run (soup_message_get_io_data (msg), msg, FALSE);
return FALSE;
}
static void
soup_client_message_io_http1_run (SoupClientMessageIO *iface,
+ SoupMessage *msg,
gboolean blocking)
{
SoupClientMessageIOHTTP1 *client_io = (SoupClientMessageIOHTTP1 *)iface;
SoupMessageIOData *io = &client_io->base;
- SoupMessage *msg = client_io->item->msg;
GError *error = NULL;
if (io->io_source) {
@@ -893,11 +895,11 @@ soup_client_message_io_http1_run (SoupClientMessageIO *iface,
static gboolean
soup_client_message_io_http1_run_until_read (SoupClientMessageIO *iface,
+ SoupMessage *msg,
GCancellable *cancellable,
GError **error)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
- SoupMessage *msg = io->item->msg;
if (io_run_until (io, TRUE,
SOUP_MESSAGE_IO_STATE_BODY,
@@ -966,13 +968,13 @@ io_run_until_read_async (SoupClientMessageIOHTTP1 *client_io,
static void
soup_client_message_io_http1_run_until_read_async (SoupClientMessageIO *iface,
+ SoupMessage *msg,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
- SoupMessage *msg = io->item->msg;
GTask *task;
task = g_task_new (msg, cancellable, callback, user_data);
@@ -982,12 +984,12 @@ soup_client_message_io_http1_run_until_read_async (SoupClientMessageIO *iface,
static gboolean
soup_client_message_io_http1_run_until_finish (SoupClientMessageIO *iface,
+ SoupMessage *msg,
gboolean blocking,
GCancellable *cancellable,
GError **error)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
- SoupMessage *msg = io->item->msg;
gboolean success;
g_object_ref (msg);
@@ -1016,10 +1018,10 @@ client_stream_eof (SoupClientInputStream *stream,
static GInputStream *
soup_client_message_io_http1_get_response_stream (SoupClientMessageIO *iface,
+ SoupMessage *msg,
GError **error)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
- SoupMessage *msg = io->item->msg;
GInputStream *client_stream;
client_stream = soup_client_input_stream_new (io->base.body_istream, msg);
@@ -1054,7 +1056,8 @@ soup_client_message_io_http1_send_item (SoupClientMessageIO *iface,
}
static void
-soup_client_message_io_http1_pause (SoupClientMessageIO *iface)
+soup_client_message_io_http1_pause (SoupClientMessageIO *iface,
+ SoupMessage *msg)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
@@ -1064,7 +1067,8 @@ soup_client_message_io_http1_pause (SoupClientMessageIO *iface)
}
static void
-soup_client_message_io_http1_unpause (SoupClientMessageIO *iface)
+soup_client_message_io_http1_unpause (SoupClientMessageIO *iface,
+ SoupMessage *msg)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
@@ -1073,7 +1077,8 @@ soup_client_message_io_http1_unpause (SoupClientMessageIO *iface)
}
static gboolean
-soup_client_message_io_http1_is_paused (SoupClientMessageIO *iface)
+soup_client_message_io_http1_is_paused (SoupClientMessageIO *iface,
+ SoupMessage *msg)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
diff --git a/libsoup/soup-client-message-io.c b/libsoup/soup-client-message-io.c
index 1db0c2e3..7a48006a 100644
--- a/libsoup/soup-client-message-io.c
+++ b/libsoup/soup-client-message-io.c
@@ -19,9 +19,10 @@ soup_client_message_io_destroy (SoupClientMessageIO *io)
}
void
-soup_client_message_io_finished (SoupClientMessageIO *io)
+soup_client_message_io_finished (SoupClientMessageIO *io,
+ SoupMessage *msg)
{
- io->funcs->finished (io);
+ io->funcs->finished (io, msg);
}
void
@@ -40,60 +41,68 @@ soup_client_message_io_send_item (SoupClientMessageIO *io,
}
void
-soup_client_message_io_pause (SoupClientMessageIO *io)
+soup_client_message_io_pause (SoupClientMessageIO *io,
+ SoupMessage *msg)
{
- io->funcs->pause (io);
+ io->funcs->pause (io, msg);
}
void
-soup_client_message_io_unpause (SoupClientMessageIO *io)
+soup_client_message_io_unpause (SoupClientMessageIO *io,
+ SoupMessage *msg)
{
- io->funcs->unpause (io);
+ io->funcs->unpause (io, msg);
}
gboolean
-soup_client_message_io_is_paused (SoupClientMessageIO *io)
+soup_client_message_io_is_paused (SoupClientMessageIO *io,
+ SoupMessage *msg)
{
- return io->funcs->is_paused (io);
+ return io->funcs->is_paused (io, msg);
}
void
soup_client_message_io_run (SoupClientMessageIO *io,
+ SoupMessage *msg,
gboolean blocking)
{
- io->funcs->run (io, blocking);
+ io->funcs->run (io, msg, blocking);
}
gboolean
soup_client_message_io_run_until_read (SoupClientMessageIO *io,
+ SoupMessage *msg,
GCancellable *cancellable,
GError **error)
{
- return io->funcs->run_until_read (io, cancellable, error);
+ return io->funcs->run_until_read (io, msg, cancellable, error);
}
void
soup_client_message_io_run_until_read_async (SoupClientMessageIO *io,
+ SoupMessage *msg,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
- io->funcs->run_until_read_async (io, io_priority, cancellable, callback, user_data);
+ io->funcs->run_until_read_async (io, msg, io_priority, cancellable, callback, user_data);
}
gboolean
soup_client_message_io_run_until_finish (SoupClientMessageIO *io,
+ SoupMessage *msg,
gboolean blocking,
GCancellable *cancellable,
GError **error)
{
- return io->funcs->run_until_finish (io, blocking, cancellable, error);
+ return io->funcs->run_until_finish (io, msg, blocking, cancellable, error);
}
GInputStream *
soup_client_message_io_get_response_stream (SoupClientMessageIO *io,
+ SoupMessage *msg,
GError **error)
{
- return io->funcs->get_response_stream (io, error);
+ return io->funcs->get_response_stream (io, msg, error);
}
diff --git a/libsoup/soup-client-message-io.h b/libsoup/soup-client-message-io.h
index 22f9bc47..dfdb8690 100644
--- a/libsoup/soup-client-message-io.h
+++ b/libsoup/soup-client-message-io.h
@@ -12,28 +12,37 @@ typedef struct _SoupClientMessageIO SoupClientMessageIO;
typedef struct {
void (*destroy) (SoupClientMessageIO *io);
- void (*finished) (SoupClientMessageIO *io);
+ void (*finished) (SoupClientMessageIO *io,
+ SoupMessage *msg);
void (*stolen) (SoupClientMessageIO *io);
void (*send_item) (SoupClientMessageIO *io,
SoupMessageQueueItem *item,
SoupMessageIOCompletionFn completion_cb,
gpointer user_data);
GInputStream *(*get_response_stream) (SoupClientMessageIO *io,
+ SoupMessage *msg,
GError **error);
- void (*pause) (SoupClientMessageIO *io);
- void (*unpause) (SoupClientMessageIO *io);
- gboolean (*is_paused) (SoupClientMessageIO *io);
+ void (*pause) (SoupClientMessageIO *io,
+ SoupMessage *msg);
+ void (*unpause) (SoupClientMessageIO *io,
+ SoupMessage *msg);
+ gboolean (*is_paused) (SoupClientMessageIO *io,
+ SoupMessage *msg);
void (*run) (SoupClientMessageIO *io,
+ SoupMessage *msg,
gboolean blocking);
gboolean (*run_until_read) (SoupClientMessageIO *io,
+ SoupMessage *msg,
GCancellable *cancellable,
GError **error);
void (*run_until_read_async) (SoupClientMessageIO *io,
+ SoupMessage *msg,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*run_until_finish) (SoupClientMessageIO *io,
+ SoupMessage *msg,
gboolean blocking,
GCancellable *cancellable,
GError **error);
@@ -44,28 +53,37 @@ struct _SoupClientMessageIO {
};
void soup_client_message_io_destroy (SoupClientMessageIO *io);
-void soup_client_message_io_finished (SoupClientMessageIO *io);
+void soup_client_message_io_finished (SoupClientMessageIO *io,
+ SoupMessage *msg);
void soup_client_message_io_stolen (SoupClientMessageIO *io);
void soup_client_message_io_send_item (SoupClientMessageIO *io,
SoupMessageQueueItem *item,
SoupMessageIOCompletionFn completion_cb,
gpointer user_data);
-void soup_client_message_io_pause (SoupClientMessageIO *io);
-void soup_client_message_io_unpause (SoupClientMessageIO *io);
-gboolean soup_client_message_io_is_paused (SoupClientMessageIO *io);
+void soup_client_message_io_pause (SoupClientMessageIO *io,
+ SoupMessage *msg);
+void soup_client_message_io_unpause (SoupClientMessageIO *io,
+ SoupMessage *msg);
+gboolean soup_client_message_io_is_paused (SoupClientMessageIO *io,
+ SoupMessage *msg);
void soup_client_message_io_run (SoupClientMessageIO *io,
+ SoupMessage *msg,
gboolean blocking);
gboolean soup_client_message_io_run_until_read (SoupClientMessageIO *io,
+ SoupMessage *msg,
GCancellable *cancellable,
GError **error);
void soup_client_message_io_run_until_read_async (SoupClientMessageIO *io,
+ SoupMessage *msg,
int io_priority,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean soup_client_message_io_run_until_finish (SoupClientMessageIO *io,
+ SoupMessage *msg,
gboolean blocking,
GCancellable *cancellable,
GError **error);
GInputStream *soup_client_message_io_get_response_stream (SoupClientMessageIO *io,
- GError **error);
+ SoupMessage *msg,
+ GError **error);
\ No newline at end of file
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index b5c177dd..68328d45 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -2187,7 +2187,7 @@ soup_message_io_finished (SoupMessage *msg)
return;
g_assert (priv->connection != NULL);
- soup_client_message_io_finished (g_steal_pointer (&priv->io_data));
+ soup_client_message_io_finished (g_steal_pointer (&priv->io_data), msg);
}
void
@@ -2197,7 +2197,7 @@ soup_message_io_pause (SoupMessage *msg)
g_return_if_fail (priv->io_data != NULL);
- soup_client_message_io_pause (priv->io_data);
+ soup_client_message_io_pause (priv->io_data, msg);
}
void
@@ -2207,7 +2207,7 @@ soup_message_io_unpause (SoupMessage *msg)
g_return_if_fail (priv->io_data != NULL);
- soup_client_message_io_unpause (priv->io_data);
+ soup_client_message_io_unpause (priv->io_data, msg);
}
gboolean
@@ -2215,7 +2215,7 @@ soup_message_is_io_paused (SoupMessage *msg)
{
SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
- return priv->io_data && soup_client_message_io_is_paused (priv->io_data);
+ return priv->io_data && soup_client_message_io_is_paused (priv->io_data, msg);
}
/**
@@ -2240,7 +2240,7 @@ soup_message_io_run (SoupMessage *msg,
{
SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
- soup_client_message_io_run (priv->io_data, blocking);
+ soup_client_message_io_run (priv->io_data, msg, blocking);
}
gboolean
@@ -2250,7 +2250,7 @@ soup_message_io_run_until_read (SoupMessage *msg,
{
SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
- return soup_client_message_io_run_until_read (priv->io_data, cancellable, error);
+ return soup_client_message_io_run_until_read (priv->io_data, msg, cancellable, error);
}
void
@@ -2262,7 +2262,7 @@ soup_message_io_run_until_read_async (SoupMessage *msg,
{
SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
- soup_client_message_io_run_until_read_async (priv->io_data, io_priority, cancellable, callback,
user_data);
+ soup_client_message_io_run_until_read_async (priv->io_data, msg, io_priority, cancellable, callback,
user_data);
}
gboolean
@@ -2281,7 +2281,7 @@ soup_message_io_run_until_finish (SoupMessage *msg,
{
SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
- return soup_client_message_io_run_until_finish (priv->io_data, blocking, cancellable, error);
+ return soup_client_message_io_run_until_finish (priv->io_data, msg, blocking, cancellable, error);
}
void
@@ -2303,7 +2303,7 @@ soup_message_io_get_response_istream (SoupMessage *msg,
{
SoupMessagePrivate *priv = soup_message_get_instance_private (msg);
- return soup_client_message_io_get_response_stream (priv->io_data, error);
+ return soup_client_message_io_get_response_stream (priv->io_data, msg, error);
}
SoupContentSniffer *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]