[libsoup/return-if-client_io-is-null] Refactor common code in 'soup_client_message_io_http1_finished' and 'soup_client_message_io_http1_st
- From: Diego Pino <dpino src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/return-if-client_io-is-null] Refactor common code in 'soup_client_message_io_http1_finished' and 'soup_client_message_io_http1_st
- Date: Thu, 13 May 2021 08:55:36 +0000 (UTC)
commit 3a8852d95f8cce155103b437a888a297f94df1f3
Author: Diego Pino Garcia <dpino igalia com>
Date: Thu May 13 14:32:55 2021 +0800
Refactor common code in 'soup_client_message_io_http1_finished' and 'soup_client_message_io_http1_stolen'
and disconnect signal handlers
libsoup/soup-client-message-io-http1.c | 44 ++++++++++++++++++----------------
1 file changed, 24 insertions(+), 20 deletions(-)
---
diff --git a/libsoup/soup-client-message-io-http1.c b/libsoup/soup-client-message-io-http1.c
index 4ade4e1b..12ee83ad 100644
--- a/libsoup/soup-client-message-io-http1.c
+++ b/libsoup/soup-client-message-io-http1.c
@@ -68,46 +68,50 @@ soup_client_message_io_http1_get_priority (SoupClientMessageIOHTTP1 *io)
}
static void
-soup_client_message_io_http1_finished (SoupClientMessageIO *iface,
- SoupMessage *msg)
+soup_client_message_io_complete (SoupClientMessageIOHTTP1 *io,
+ SoupMessage *msg,
+ SoupMessageIOCompletion completion)
{
- SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
+ SoupConnection* conn;
SoupMessageIOCompletionFn completion_cb;
gpointer completion_data;
- SoupMessageIOCompletion completion;
completion_cb = io->base.completion_cb;
completion_data = io->base.completion_data;
+ msg = g_object_ref (msg);
+ conn = soup_message_get_connection (msg);
+ g_signal_handlers_disconnect_by_data (conn, msg);
+ if (io->base.body_ostream)
+ g_signal_handlers_disconnect_by_data (io->base.body_ostream, msg);
+ soup_connection_message_io_finished (conn, msg);
+ if (completion_cb)
+ completion_cb (G_OBJECT (msg), completion, completion_data);
+ g_object_unref (msg);
+}
+
+static void
+soup_client_message_io_http1_finished (SoupClientMessageIO *iface,
+ SoupMessage *msg)
+{
+ SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
+ SoupMessageIOCompletion completion;
+
if ((io->base.read_state >= SOUP_MESSAGE_IO_STATE_FINISHING &&
io->base.write_state >= SOUP_MESSAGE_IO_STATE_FINISHING))
completion = SOUP_MESSAGE_IO_COMPLETE;
else
completion = SOUP_MESSAGE_IO_INTERRUPTED;
- 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);
- g_object_unref (msg);
+ soup_client_message_io_complete (io, msg, completion);
}
static void
soup_client_message_io_http1_stolen (SoupClientMessageIO *iface)
{
SoupClientMessageIOHTTP1 *io = (SoupClientMessageIOHTTP1 *)iface;
- SoupMessageIOCompletionFn completion_cb;
- gpointer completion_data;
- SoupMessage *msg;
- completion_cb = io->base.completion_cb;
- completion_data = io->base.completion_data;
-
- msg = g_object_ref (io->item->msg);
- soup_connection_message_io_finished (soup_message_get_connection (msg), msg);
- if (completion_cb)
- completion_cb (G_OBJECT (msg), SOUP_MESSAGE_IO_STOLEN, completion_data);
- g_object_unref (msg);
+ soup_client_message_io_complete (io, io->item->msg, SOUP_MESSAGE_IO_STOLEN);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]