From 0fd07e842748d60cc67d125bdbf9540adae569bf Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 5 Aug 2024 13:09:50 -0400 Subject: [PATCH] Fix race condition in SSDP snoop If an asynchronous handler is slow to enroll a target while another target causes an iteration of the snoop loop, the various modified structures had been discarded in the interim. Now persist the data structures iteration to iteration, using 'clear()' to empty them rather than getting brand new data structures each loop. --- .../confluent/discovery/protocols/ssdp.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/discovery/protocols/ssdp.py b/confluent_server/confluent/discovery/protocols/ssdp.py index e2688d66..c7063838 100644 --- a/confluent_server/confluent/discovery/protocols/ssdp.py +++ b/confluent_server/confluent/discovery/protocols/ssdp.py @@ -116,10 +116,11 @@ def _process_snoop(peer, rsp, mac, known_peers, newmacs, peerbymacaddress, byeha if '/eth' in value and value.endswith('.xml'): targurl = '/redfish/v1/' targtype = 'megarac-bmc' - continue # MegaRAC redfish + continue # MegaRAC redfish elif value.endswith('/DeviceDescription.json'): targurl = '/DeviceDescription.json' - targtype = 'megarac-bmc' + targtype = 'lenovo-xcc' + continue else: return if handler and targurl: @@ -179,11 +180,14 @@ def snoop(handler, byehandler=None, protocol=None, uuidlookup=None): net4.bind(('', 1900)) net6.bind(('', 1900)) peerbymacaddress = {} + newmacs = set([]) + deferrednotifies = [] + machandlers = {} while True: try: - newmacs = set([]) - deferrednotifies = [] - machandlers = {} + newmacs.clear() + deferrednotifies.clear() + machandlers.clear() r = select.select((net4, net6), (), (), 60) if r: r = r[0]