telepathy-idle: Start pinging & running message queue after 001 (welcome)

Simon McVittie smcv at kemper.freedesktop.org
Wed May 1 09:01:42 PDT 2013


Module: telepathy-idle
Branch: master
Commit: 8e36adc8c429be5f5337fbaba17f4c79b82b9584
URL:    http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=8e36adc8c429be5f5337fbaba17f4c79b82b9584

Author: Will Thompson <will.thompson at collabora.co.uk>
Date:   Mon Apr 29 17:05:10 2013 +0100

Start pinging & running message queue after 001 (welcome)

Previously, keepalives and unloading messages started as soon as the TCP
session is established: before even the PASS/NICK/USER messages have
been sent! (IdleServerConnection emits ::status-changed(CONNECTED)
before connect_async() finishes.) If a message had got into the queue
already, this would break the connection process.

---

 src/idle-connection.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/idle-connection.c b/src/idle-connection.c
index 0e7e05c..79fbc58 100644
--- a/src/idle-connection.c
+++ b/src/idle-connection.c
@@ -800,13 +800,6 @@ static void sconn_status_changed_cb(IdleServerConnection *sconn, IdleServerConne
 			break;
 
 		case SERVER_CONNECTION_STATE_CONNECTED:
-			if (priv->keepalive_interval != 0 && priv->keepalive_timeout == 0)
-				priv->keepalive_timeout = g_timeout_add_seconds(priv->keepalive_interval, keepalive_timeout_cb, conn);
-
-			if (g_queue_get_length(priv->msg_queue) > 0) {
-				IDLE_DEBUG("we had messages in queue, start unloading them now");
-				idle_connection_add_queue_timeout (conn);
-			}
 			break;
 
 		default:
@@ -1227,11 +1220,21 @@ static void send_quit_request(IdleConnection *conn) {
 
 static void connection_connect_cb(IdleConnection *conn, gboolean success, TpConnectionStatusReason fail_reason) {
 	TpBaseConnection *base = TP_BASE_CONNECTION(conn);
+	IdleConnectionPrivate *priv = conn->priv;
 
-	if (success)
+	if (success) {
 		tp_base_connection_change_status(base, TP_CONNECTION_STATUS_CONNECTED, TP_CONNECTION_STATUS_REASON_REQUESTED);
-	else
+
+		if (priv->keepalive_interval != 0 && priv->keepalive_timeout == 0)
+			priv->keepalive_timeout = g_timeout_add_seconds(priv->keepalive_interval, keepalive_timeout_cb, conn);
+
+		if (g_queue_get_length(priv->msg_queue) > 0) {
+			IDLE_DEBUG("we had messages in queue, start unloading them now");
+			idle_connection_add_queue_timeout (conn);
+		}
+	} else {
 		tp_base_connection_change_status(base, TP_CONNECTION_STATUS_DISCONNECTED, fail_reason);
+	}
 }
 
 static void connection_disconnect_cb(IdleConnection *conn, TpConnectionStatusReason reason) {



More information about the telepathy-commits mailing list