[libsoup] soup-message-io: make disconnect-on-unfinished more implicit
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] soup-message-io: make disconnect-on-unfinished more implicit
- Date: Mon, 16 Jul 2012 16:13:09 +0000 (UTC)
commit 317910b365b595d4da4fcb21d1d319f27e541af2
Author: Dan Winship <danw gnome org>
Date: Fri Jun 8 04:04:36 2012 -0400
soup-message-io: make disconnect-on-unfinished more implicit
Rather than disconnecting the connection from soup_message_io_stop()
if the message didn't complete, do it from
SoupConnection:clear_current_item(). This makes it DTRT even if the
SoupMessageQueueItem loses its connection before
soup_message_io_stop() gets called.
libsoup/soup-connection.c | 10 +++++++++-
libsoup/soup-connection.h | 1 +
libsoup/soup-message-io.c | 8 ++++----
3 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index c9d8884..48c3d00 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -32,6 +32,7 @@ typedef struct {
time_t unused_timeout;
guint io_timeout, idle_timeout;
GSource *idle_timeout_src;
+ gboolean reusable;
} SoupConnectionPrivate;
#define SOUP_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUP_TYPE_CONNECTION, SoupConnectionPrivate))
@@ -388,6 +389,7 @@ set_current_item (SoupConnection *conn, SoupMessageQueueItem *item)
item->state = SOUP_MESSAGE_RUNNING;
priv->cur_item = item;
g_object_notify (G_OBJECT (conn), "message");
+ priv->reusable = FALSE;
g_signal_connect (item->msg, "restarted",
G_CALLBACK (current_item_restarted), conn);
@@ -432,7 +434,7 @@ clear_current_item (SoupConnection *conn)
priv->proxy_uri = NULL;
}
- if (!soup_message_is_keepalive (item->msg))
+ if (!soup_message_is_keepalive (item->msg) || !priv->reusable)
soup_connection_disconnect (conn);
}
@@ -954,6 +956,12 @@ soup_connection_set_state (SoupConnection *conn, SoupConnectionState state)
g_object_thaw_notify (G_OBJECT (conn));
}
+void
+soup_connection_set_reusable (SoupConnection *conn)
+{
+ SOUP_CONNECTION_GET_PRIVATE (conn)->reusable = TRUE;
+}
+
gboolean
soup_connection_get_ever_used (SoupConnection *conn)
{
diff --git a/libsoup/soup-connection.h b/libsoup/soup-connection.h
index 52e638f..ad3a1b1 100644
--- a/libsoup/soup-connection.h
+++ b/libsoup/soup-connection.h
@@ -76,6 +76,7 @@ gboolean soup_connection_is_tunnelled (SoupConnection *conn);
SoupConnectionState soup_connection_get_state (SoupConnection *conn);
void soup_connection_set_state (SoupConnection *conn,
SoupConnectionState state);
+void soup_connection_set_reusable (SoupConnection *conn);
gboolean soup_connection_get_ever_used (SoupConnection *conn);
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index db29b11..eeb6755 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -145,10 +145,8 @@ soup_message_io_stop (SoupMessage *msg)
io->unpause_source = NULL;
}
- if (io->read_state < SOUP_MESSAGE_IO_STATE_FINISHING) {
- if (io->item && io->item->conn)
- soup_connection_disconnect (io->item->conn);
- else
+ if (io->mode == SOUP_MESSAGE_IO_SERVER) {
+ if (io->write_state < SOUP_MESSAGE_IO_STATE_FINISHING)
g_io_stream_close (io->iostream, NULL, NULL);
}
}
@@ -630,6 +628,8 @@ io_read (SoupMessage *msg, GCancellable *cancellable, GError **error)
case SOUP_MESSAGE_IO_STATE_BODY_DONE:
io->read_state = SOUP_MESSAGE_IO_STATE_FINISHING;
+ if (io->item && io->item->conn)
+ soup_connection_set_reusable (io->item->conn);
soup_message_got_body (msg);
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]