From: Michael Tremer Date: Tue, 5 Aug 2025 17:07:30 +0000 (+0100) Subject: suricata-reporter: Close the queue on termination X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d0831c07693abb93e511e40dacc34a37fae8e6dd;p=ipfire-2.x.git suricata-reporter: Close the queue on termination This will allow us to not have an extra signal to check across processes. Signed-off-by: Michael Tremer --- diff --git a/config/suricata/suricata-reporter b/config/suricata/suricata-reporter index e95e51f1e..c57f52ee5 100644 --- a/config/suricata/suricata-reporter +++ b/config/suricata/suricata-reporter @@ -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))