]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
suricata-reporter: Replace logic on termination signals
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Aug 2025 17:07:57 +0000 (18:07 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Sep 2025 17:42:00 +0000 (18:42 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/suricata/suricata-reporter

index c57f52ee596d7e04b9dfc713f503fc00d804d143..a25fab28421e9adc43d439fce706ef951bf89969 100644 (file)
@@ -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: