From 8c4bdc8c617670e0bd2bb66c9e9e642a17c476a4 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Fri, 14 Jul 2017 01:16:30 +0100 Subject: [PATCH] Change the behaviour of multithreaded scans to return results as soon as possible (at the cost of ordering). --- volatility/framework/interfaces/layers.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/volatility/framework/interfaces/layers.py b/volatility/framework/interfaces/layers.py index 3c005e68d..63815fddc 100644 --- a/volatility/framework/interfaces/layers.py +++ b/volatility/framework/interfaces/layers.py @@ -163,6 +163,7 @@ class DataLayerInterface(configuration.ConfigurableInterface, validity.ValidityR """Scans a Translation layer by chunk Note: this will skip missing/unmappable chunks of memory + It will also potentially return results out-of-order based on generators returning as quickly as possible """ if progress_callback is not None: self._check_type(progress_callback, collections.Callable) @@ -190,16 +191,11 @@ class DataLayerInterface(configuration.ConfigurableInterface, validity.ValidityR scan_metric = functools.partial(self._scan_metric, scanner, min_address, max_address) if scanner.thread_safe and not constants.DISABLE_MULTITHREADED_SCANNING: with multiprocessing.Pool() as pool: - result = pool.map_async(scan_chunk, scan_iterator()) - while not result.ready(): + for result in pool.imap_unordered(scan_chunk, scan_iterator()): if progress_callback: # Run the progress_callback progress_callback(scan_metric(progress.value), "Scanning {}".format(self.name)) - # Ensures we don't burn CPU cycles going round in a ready waiting loop - # without delaying the user too long between progress updates/results - result.wait(0.1) - for value in result.get(): - yield from value + yield from result else: for value in scan_iterator(): if progress_callback: