From: Michael Tremer Date: Tue, 5 Aug 2025 17:07:57 +0000 (+0100) Subject: suricata-reporter: Replace logic on termination signals X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d59a4a0822ab6ae5e189c1e540432d64caa5948;p=ipfire-2.x.git suricata-reporter: Replace logic on termination signals Signed-off-by: Michael Tremer --- diff --git a/config/suricata/suricata-reporter b/config/suricata/suricata-reporter index c57f52ee5..a25fab284 100644 --- a/config/suricata/suricata-reporter +++ b/config/suricata/suricata-reporter @@ -45,8 +45,8 @@ class Reporter(object): # Fetch the current event loop self.loop = asyncio.get_running_loop() - # Are we running? - self.is_running = multiprocessing.Event() + # Have we terminated? + self.is_terminated = asyncio.Event() # Create an events queue self.queue = multiprocessing.Queue(1024) @@ -91,19 +91,12 @@ class Reporter(object): """ log.debug("Starting reporter...") - # We are now running - self.is_running.set() - # Start all workers for worker in self.workers: worker.start() - # Sleep for forever - while self.is_running.is_set(): - await asyncio.sleep(1) - - # Write some data into the queue - self.queue.put("ABC", block=False) + # Wait until we have terminated + await self.is_terminated.wait() log.debug("Reporter has exited") @@ -114,7 +107,7 @@ class Reporter(object): log.debug("Terminating...") # We are no longer running - self.is_running.clear() + self.is_terminated.set() # Remove the socket so we won't receive any more data try: