diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2013-04-29 17:05:10 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2013-04-29 17:22:22 +0100 |
commit | 8e36adc8c429be5f5337fbaba17f4c79b82b9584 (patch) | |
tree | 48b03d145a4c35e07b24bd52881c949b8d1c1046 | |
parent | af34b5de9f32289a73af3e90d68f776d7166f7dd (diff) |
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.
-rw-r--r-- | 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) { |