[telepathy-gabble/master] Always recycle the socks5_potential_proxies list

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Dec 4 09:16:13 PST 2009


We ensure that we won't query twice the same proxy by clamping the number of
proxy needed to the length of the list of the potential proxies.
This add the nice side effect of prioritizing a different proxy every time.
---
 src/bytestream-factory.c |   21 +++++----------------
 1 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/src/bytestream-factory.c b/src/bytestream-factory.c
index e63495f..92eb390 100644
--- a/src/bytestream-factory.c
+++ b/src/bytestream-factory.c
@@ -382,27 +382,16 @@ query_proxies (GabbleBytestreamFactory *self,
       self);
   guint i;
 
+  /* We don't want to query more than once the same proxy */
+  nb_proxies_needed = MIN (nb_proxies_needed,
+      g_slist_length (priv->socks5_potential_proxies));
+
   for (i = 0; i < nb_proxies_needed; i++)
     {
       gchar *jid;
 
       if (priv->next_query == NULL)
-        {
-          if (g_slist_length (priv->socks5_potential_proxies) >
-                FALLBACK_PROXY_CACHE_SIZE)
-            {
-              /* recycle the proxies list */
-              priv->next_query = priv->socks5_potential_proxies;
-            }
-          else
-            {
-              /* There is no point to recycle the list as we'll never exceed
-               * the size of the cache. Furthermore, if we have, say, one
-               * proxy we don't want to flood it with useless requests. */
-              DEBUG ("Can't recycle proxies list");
-              return;
-            }
-        }
+        priv->next_query = priv->socks5_potential_proxies;
 
       jid = priv->next_query->data;
       send_proxy_query (self, jid, TRUE);
-- 
1.5.6.5




More information about the telepathy-commits mailing list