mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 12:14:36 -05:00
test: have the logger reload test's workers just log
The workers copied what zmDbDo() did before #5197: hold the Logger pointer across a query and set the database level to NOLOG around it. #5197 removed that. The workers now fetch and log, as the threads that still log during a reload do (the dbQueue thread, the stream socket threads), and the comment names those. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
47ac523ed6
commit
6d3e869949
1 file changed
+4
-10
@@ -36,11 +36,10 @@ static std::string slurp(const std::string &path) {
|
||||
}
|
||||
|
||||
// zmc and zm_rtsp_server reload their configuration on SIGHUP and call
|
||||
// logReload() from their main loop. Other threads keep running through that:
|
||||
// the dbQueue thread writing Logs rows (zmDbDo holds the Logger pointer across
|
||||
// its query to restore the database level), stream socket threads, and
|
||||
// anything else that logs. The reload must leave the instance those threads
|
||||
// hold valid. When the reload deleted and recreated the logger
|
||||
// logReload() from their main loop. Other threads keep logging through that,
|
||||
// the dbQueue thread and the stream socket threads among them, each through
|
||||
// the instance Logger::fetch() gave it. The reload must leave that instance
|
||||
// valid. When the reload deleted and recreated the logger
|
||||
// (logTerm(); logInit()), AddressSanitizer reported a heap-use-after-free here.
|
||||
TEST_CASE("logReload while other threads log keeps the logger they hold") {
|
||||
std::string path = stringtf("/tmp/zm_test_logreload_%d.log", getpid());
|
||||
@@ -58,12 +57,7 @@ TEST_CASE("logReload while other threads log keeps the logger they hold") {
|
||||
for (int t = 0; t < 4; t++) {
|
||||
workers.emplace_back([&stop, &lines, t]() {
|
||||
while (!stop) {
|
||||
// What zmDbDo does around every query.
|
||||
Logger *logger = Logger::fetch();
|
||||
Logger::Level old_level = logger->databaseLevel();
|
||||
logger->databaseLevel(Logger::NOLOG);
|
||||
Info("worker %d line %d", t, lines++);
|
||||
logger->databaseLevel(old_level);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user