Fix throttle on multiple connections
[azimuth] / 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