[telepathy-gabble/master] move existing proxy to the head of the list when they are re-discovered

Guillaume Desmottes guillaume.desmottes at collabora.co.uk
Fri Nov 27 06:46:20 PST 2009


---
 src/bytestream-factory.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/bytestream-factory.c b/src/bytestream-factory.c
index 2c4ce4c..c6ecea7 100644
--- a/src/bytestream-factory.c
+++ b/src/bytestream-factory.c
@@ -239,6 +239,7 @@ add_proxy_to_list (GabbleBytestreamFactory *self,
   GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (
       self);
   GSList **list;
+  GSList *found;
 
   if (fallback)
     {
@@ -249,18 +250,24 @@ add_proxy_to_list (GabbleBytestreamFactory *self,
       list = &priv->socks5_proxies;;
     }
 
-  if (g_slist_find_custom (*list, proxy, cmp_proxy) != NULL)
+  found = g_slist_find_custom (*list, proxy, cmp_proxy);
+  if (found != NULL)
     {
-      DEBUG ("%s SOCKS5 proxy (%s %s:%s) is already known; ignoring",
+      DEBUG ("%s SOCKS5 proxy (%s %s:%s) is already known; "
+          "move it to the head of the list",
           fallback ? "Fallback": "Discovered",
           proxy->jid, proxy->host, proxy->port);
-      return;
+
+      *list = g_slist_delete_link (*list, found);
+    }
+  else
+    {
+      DEBUG ("Add %s SOCKS5 proxy: %s %s:%s",
+          fallback ? "fallback": "discovered",
+          proxy->jid, proxy->host, proxy->port);
     }
 
   *list = g_slist_prepend (*list, proxy);
-
-  DEBUG ("Add %s SOCKS5 proxy: %s %s:%s", fallback ? "fallback": "discovered",
-      proxy->jid, proxy->host, proxy->port);
 }
 
 static LmHandlerResult
-- 
1.5.6.5




More information about the telepathy-commits mailing list