mirror of
https://github.com/smittix/intercept.git
synced 2026-06-08 14:11:54 -07:00
fix: guard _looked_up_icaos popitem against concurrent clear(); add eviction tests
contextlib.suppress(KeyError) around popitem prevents a crash in the SBS parser thread if stop_adsb() calls clear() concurrently between the len() check and the popitem call. Two unit tests verify FIFO eviction semantics and duplicate-key no-op.
This commit is contained in:
+2
-1
@@ -731,7 +731,8 @@ def parse_sbs_stream(service_addr):
|
||||
# Look up aircraft type from database (once per ICAO)
|
||||
if icao not in _looked_up_icaos:
|
||||
if len(_looked_up_icaos) >= _ICAO_CACHE_MAX:
|
||||
_looked_up_icaos.popitem(last=False)
|
||||
with contextlib.suppress(KeyError):
|
||||
_looked_up_icaos.popitem(last=False)
|
||||
_looked_up_icaos[icao] = None
|
||||
db_info = aircraft_db.lookup(icao)
|
||||
if db_info:
|
||||
|
||||
Reference in New Issue
Block a user