From b43ca913add25cc76ed10e8b6643d866419aa348 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 4 Dec 2009 17:16:13 +0000 Subject: Always recycle the socks5_potential_proxies list 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 file changed, 5 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/bytestream-factory.c b/src/bytestream-factory.c index e63495f74..92eb39076 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); -- cgit v1.2.3