Fix throttle on multiple connections
authorAlban Crequy <alban.crequy@collabora.co.uk>
Fri, 21 May 2010 16:23:08 +0000 (17:23 +0100)
committerAlban Crequy <alban.crequy@collabora.co.uk>
Fri, 21 May 2010 16:27:16 +0000 (17:27 +0100)
There was a single throttle timeout for all connections but the the timeout was
rearmed when SetLocation was called on a single connection. So the location was
always published to a single connection.

This patch rearm the throttle timeout after the location is published on all
connections. When an connection just appear, the throttle does not apply and
the location is published immediately on that connection.

src/position-publisher.c

index c0c57fd..08b07c0 100644 (file)
@@ -133,16 +133,8 @@ publish_to_conn (PositionPublisher *self,
   if (priv->location == NULL)
     return;
 
-  if (priv->throttle_timeout != 0)
-    /* We are waiting */
-    return;
-
   tp_cli_connection_interface_location_call_set_location (conn, -1,
       priv->location, set_location_cb, NULL, NULL, G_OBJECT (self));
-
-  /* We won't publish during the next PUBLISH_THROTTLE seconds */
-  priv->throttle_timeout = g_timeout_add_seconds (PUBLISH_THROTTLE,
-      publish_throttle_timeout_cb, self);
 }
 
 static void
@@ -151,12 +143,20 @@ publish_to_all (PositionPublisher *self)
   PositionPublisherPrivate *priv = POSITION_PUBLISHER_GET_PRIVATE (self);
   GSList *l;
 
+  if (priv->throttle_timeout != 0)
+    /* We are waiting */
+    return;
+
   for (l = priv->connections; l != NULL; l = g_slist_next (l))
     {
       TpConnection *conn = l->data;
 
       publish_to_conn (self, conn);
     }
+
+  /* We won't publish during the next PUBLISH_THROTTLE seconds */
+  priv->throttle_timeout = g_timeout_add_seconds (PUBLISH_THROTTLE,
+      publish_throttle_timeout_cb, self);
 }
 
 static void