From 0fbe39690e21825c29d7a22a5a6860bf964f42cf Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 26 Feb 2021 12:39:13 -0500 Subject: [PATCH] Improve concurrency of SLP During a scan, unicast TCP interrogation of candidates was done serially. Do this concurrently so that poorly behaving targets do not prolong a scan. --- confluent_server/confluent/discovery/protocols/slp.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/discovery/protocols/slp.py b/confluent_server/confluent/discovery/protocols/slp.py index a2c8a220..e5ef080f 100644 --- a/confluent_server/confluent/discovery/protocols/slp.py +++ b/confluent_server/confluent/discovery/protocols/slp.py @@ -19,6 +19,7 @@ import confluent.util as util import confluent.log as log import os import random +import eventlet.greenpool import eventlet.green.select as select import eventlet.green.socket as socket import struct @@ -590,6 +591,8 @@ def scan(srvtypes=_slp_services, addresses=None, localonly=False): # reduced chance of many responses overwhelming receive buffer. _grab_rsps((net, net4), rsps, 1, xidmap) # now to analyze and flesh out the responses + handleids = set([]) + gp = eventlet.greenpool.GreenPool(128) for id in rsps: for srvurl in rsps[id].get('urls', ()): if len(srvurl) > 4: @@ -604,7 +607,10 @@ def scan(srvtypes=_slp_services, addresses=None, localonly=False): break else: continue - _add_attributes(rsps[id]) + gp.spawn_n(_add_attributes, rsps[id]) + handleids.add(id) + gp.waitall() + for id in handleids: if 'service:lighttpd' in rsps[id]['services']: currinf = rsps[id] curratt = currinf.get('attributes', {})