[tor-commits] [bridgedb/master] Temporary fix for duplicate bridge entries

isis at torproject.org isis at torproject.org
Fri Aug 9 19:28:01 UTC 2013


commit 975380d9a959db89f07521fc6da64fadee5922d7
Author: Matthew Finkel <Matthew.Finkel at gmail.com>
Date:   Sun Aug 4 05:48:48 2013 +0000

    Temporary fix for duplicate bridge entries
    
    There exists a bug (somewhere) that causes some bridges to
    be added multiple times. The cause is currently unknown. This
    should prevent bridges from being added more than once, due to
    the way bridges are linked between the bridge descriptors and
    the extra-info descriptors. Temporary Bug fix for #9264.
---
 lib/bridgedb/Main.py |   37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/lib/bridgedb/Main.py b/lib/bridgedb/Main.py
index f5ebc4e..fd9fbda 100644
--- a/lib/bridgedb/Main.py
+++ b/lib/bridgedb/Main.py
@@ -205,22 +205,27 @@ def load(cfg, splitter, clear=False):
         logging.debug("Parsing document for purpose=%s", cfg.BRIDGE_PURPOSE)
         f = open(fname, 'r')
         for bridge in Bridges.parseDescFile(f, cfg.BRIDGE_PURPOSE):
-            bridges[bridge.getID()] = bridge
-            s = status.get(bridge.getID())
-            if s is not None:
-                running, stable = s
-                bridge.setStatus(running=running, stable=stable)
-            bridge.or_addresses = addresses.get(bridge.getID())
-            splitter.insert(bridge)
-            # add or update BridgeHistory entries into the database
-            # XXX: what do we do with all these or_addresses?
-            # The bridge stability metrics are only concerned with a single ip:port
-            # So for now, we will only consider the bridges primary IP:port
-            if bridge.getID() in timestamps.keys():
-                ts = timestamps[bridge.getID()][:]
-                ts.sort()
-                for timestamp in ts:
-                    bridgedb.Stability.addOrUpdateBridgeHistory(bridge, timestamp)
+            if bridge.getID() in bridges:
+                logging.warn("Parsed bridge that we've already added. Skipping.")
+                logging.debug("  Bridge: %s" % bridge.getID())
+                continue
+            else:
+                bridges[bridge.getID()] = bridge
+                s = status.get(bridge.getID())
+                if s is not None:
+                    running, stable = s
+                    bridge.setStatus(running=running, stable=stable)
+                bridge.or_addresses = addresses.get(bridge.getID())
+                splitter.insert(bridge)
+                # add or update BridgeHistory entries into the database
+                # XXX: what do we do with all these or_addresses?
+                # The bridge stability metrics are only concerned with a single ip:port
+                # So for now, we will only consider the bridges primary IP:port
+                if bridge.getID() in timestamps.keys():
+                    ts = timestamps[bridge.getID()][:]
+                    ts.sort()
+                    for timestamp in ts:
+                        bridgedb.Stability.addOrUpdateBridgeHistory(bridge, timestamp)
         logging.debug("Closing descriptor document")
         f.close()
     # read pluggable transports from extra-info document





More information about the tor-commits mailing list