Commit e884fcbd authored by Damian Johnson's avatar Damian Johnson
Browse files

fix: concurrency issue could crash from CIRC event

If we got a CIRC event while populating the cache of relays that we're attached
to we could reset _fingerprintsAttachedCache to None while we were in the
middle of populating it. Manipulation of this cache is supposed to be governed
by the connection lock, so fixing that for the CIRC event's reset.
parent 73de20de
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2004,7 +2004,9 @@ class Controller(TorCtl.PostEventListener):
    
    # CIRC events aren't required, but if one's received then flush this cache
    # since it uses circuit-status results.
    self.connLock.acquire()
    self._fingerprintsAttachedCache = None
    self.connLock.release()
    
    self._cachedParam["circuits"] = None
  
@@ -2085,6 +2087,10 @@ class Controller(TorCtl.PostEventListener):
      relayPort    - orport of relay (to further narrow the results)
    """
    
    # Events can reset _fingerprintsAttachedCache to None, so all uses of this
    # function need to be under the connection lock (skipping that might also
    # scew with the conn usage of this function...)
    
    # If we were provided with a string port then convert to an int (so
    # lookups won't mismatch based on type).
    if isinstance(relayPort, str): relayPort = int(relayPort)