summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-12-04 13:30:50 +0000
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-12-07 10:43:05 +0000
commitf9cec5878b5cbb2d6ec63683353740eb3d230606 (patch)
tree23b335b311853c76d54a50ad6b880877832ce9e2 /src
parent6408ae680a85d8b7fc243e5b0eb37f27389881f1 (diff)
recycle the list of potential proxies
This avoid to get stuck with the latest proxies added in the cache once we queried all the potential proxies.
Diffstat (limited to 'src')
-rw-r--r--src/bytestream-factory.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/bytestream-factory.c b/src/bytestream-factory.c
index 1c38d9774..d1066784b 100644
--- a/src/bytestream-factory.c
+++ b/src/bytestream-factory.c
@@ -168,6 +168,9 @@ struct _GabbleBytestreamFactoryPrivate
GSList *socks5_fallback_proxies;
/* List of SOCKS5's jids that have not been queried yet */
GSList *socks5_potential_proxies;
+ /* Next proxy on socks5_potential_proxies that we'll query */
+ GSList *next_query;
+
guint socks5_proxies_timer;
gboolean dispose_has_run;
@@ -383,6 +386,10 @@ gabble_bytestream_factory_query_socks5_proxies (GabbleBytestreamFactory *self)
guint nb_proxies_needed;
guint i;
+ if (priv->socks5_potential_proxies == NULL)
+ /* No potential proxies, we can't do anything */
+ return;
+
nb_proxies_found = g_slist_length (priv->socks5_proxies) +
g_slist_length (priv->socks5_fallback_proxies);
@@ -399,17 +406,20 @@ gabble_bytestream_factory_query_socks5_proxies (GabbleBytestreamFactory *self)
DEBUG ("Need %u more proxies", nb_proxies_needed);
}
- for (i = 0; i < nb_proxies_needed &&
- priv->socks5_potential_proxies != NULL; i++)
+ for (i = 0; i < nb_proxies_needed; i++)
{
gchar *jid;
- jid = priv->socks5_potential_proxies->data;
+ if (priv->next_query == NULL)
+ {
+ /* recycle the proxies list */
+ priv->next_query = priv->socks5_potential_proxies;
+ }
+
+ jid = priv->next_query->data;
send_proxy_query (self, jid, TRUE);
- g_free (jid);
- priv->socks5_potential_proxies = g_slist_delete_link (
- priv->socks5_potential_proxies, priv->socks5_potential_proxies);
+ priv->next_query = g_slist_next (priv->next_query);
}
if (priv->socks5_potential_proxies != NULL && priv->socks5_proxies_timer == 0)
@@ -478,6 +488,8 @@ conn_status_changed_cb (GabbleConnection *conn,
priv->socks5_potential_proxies = randomize_g_slist (
priv->socks5_potential_proxies);
+ priv->next_query = priv->socks5_potential_proxies;
+
g_strfreev (jids);
}
}