[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8390: Remove duplicates from MyFamily (in tor/trunk: . src/or)



Author: weasel
Date: 2006-09-14 01:07:34 -0400 (Thu, 14 Sep 2006)
New Revision: 8390

Modified:
   tor/trunk/
   tor/trunk/src/or/router.c
Log:
 r9753@danube:  weasel | 2006-09-14 07:07:02 +0200
 Remove duplicates from MyFamily



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /local/or/tor/trunk [r9753] on 17f730b7-d419-0410-b50f-85ee4b70197a

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2006-09-14 05:07:26 UTC (rev 8389)
+++ tor/trunk/src/or/router.c	2006-09-14 05:07:34 UTC (rev 8390)
@@ -804,6 +804,7 @@
   if (authdir_mode(options))
     ri->is_valid = ri->is_named = 1; /* believe in yourself */
   if (options->MyFamily) {
+    int i;
     smartlist_t *family;
     if (!warned_nonexistent_family)
       warned_nonexistent_family = smartlist_create();
@@ -840,6 +841,18 @@
        }
        tor_free(name);
      });
+
+    smartlist_sort_strings(ri->declared_family);
+    for (i = 1; i < smartlist_len(ri->declared_family); ++i) {
+      const char *a, *b;
+      a = smartlist_get(ri->declared_family, i-1);
+      b = smartlist_get(ri->declared_family, i);
+      if (!strcmp(a,b)) {
+        tor_free(smartlist_get(ri->declared_family, i));
+        smartlist_del_keeporder(ri->declared_family, i--);
+      }
+    }
+
     smartlist_free(family);
   }
   ri->cache_info.signed_descriptor_body = tor_malloc(8192);