]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
suricata-reporter: Close the queue on termination
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 5 Aug 2025 17:07:30 +0000 (18:07 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 3 Sep 2025 17:42:00 +0000 (18:42 +0100)
This will allow us to not have an extra signal to check across
processes.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/suricata/suricata-reporter

index e95e51f1eb940969c767de2ba552890592a9a109..c57f52ee596d7e04b9dfc713f503fc00d804d143 100644 (file)
@@ -122,6 +122,9 @@ class Reporter(object):
                except OSError as e:
                        log.error("Failed to remove %s: %s" % (SOCKET_PATH, e))
 
+               # Close the queue
+               self.queue.close()
+
                # Terminate all workers
                for worker in self.workers:
                        worker.terminate()
@@ -166,8 +169,13 @@ class Worker(multiprocessing.Process):
                        signal.signal(signo, signal.SIG_DFL)
 
                # Loop for forever
-               while self.reporter.is_running.is_set():
-                       event = self.reporter.queue.get(block=True)
+               while True:
+                       try:
+                               event = self.reporter.queue.get(block=True)
+
+                       # If the queue has been closed, we immediately exit
+                       except ValueError:
+                               break
 
                        # Log the event
                        log.debug("Received event in worker %s: %s" % (self.pid, event))