From 76080cb8573723bc9cfae4a33ad177da4f7e9a5b Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 23 Apr 2021 09:25:07 -0400 Subject: [PATCH] add a stop function to dbQueue to clear out the queue before we kill log. --- src/zm_db.cpp | 6 +++++- src/zm_db.h | 1 + src/zmc.cpp | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/zm_db.cpp b/src/zm_db.cpp index 1557b8b72..b296c571b 100644 --- a/src/zm_db.cpp +++ b/src/zm_db.cpp @@ -233,9 +233,13 @@ zmDbQueue::zmDbQueue() : { } zmDbQueue::~zmDbQueue() { + stop(); +} + +void zmDbQueue::stop() { mTerminate = true; mCondition.notify_all(); - mThread.join(); + if (mThread.joinable()) mThread.join(); } void zmDbQueue::process() { diff --git a/src/zm_db.h b/src/zm_db.h index e03792df0..c243aa6d6 100644 --- a/src/zm_db.h +++ b/src/zm_db.h @@ -41,6 +41,7 @@ class zmDbQueue { void push(const char *sql) { return push(std::string(sql)); }; void push(std::string &&sql); void process(); + void stop(); }; class zmDbRow { diff --git a/src/zmc.cpp b/src/zmc.cpp index 84885a583..670316791 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -376,6 +376,7 @@ int main(int argc, char *argv[]) { } Image::Deinitialise(); + dbQueue.stop(); Debug(1, "terminating"); logTerm(); zmDbClose();