From 505552220d5ab7eee3071cfe8ec981f98744b815 Mon Sep 17 00:00:00 2001 From: Davin McCall Date: Wed, 1 Jan 2020 15:46:49 +1000 Subject: [PATCH] Make sure we don't try to enable log watcher after deregistration If the watcher for the log has been deregistered (log closed), set the release flag to prevent attempts to enable the watcher. --- src/dinit-log.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/dinit-log.cc b/src/dinit-log.cc index 60c447a..d9e733a 100644 --- a/src/dinit-log.cc +++ b/src/dinit-log.cc @@ -140,6 +140,8 @@ void buffered_log_stream::release_console() void buffered_log_stream::flush_for_release() { + if (release) return; + release = true; // Try to flush any messages that are currently buffered. (Console is non-blocking @@ -268,8 +270,10 @@ void buffered_log_stream::watch_removed() noexcept { if (fd > STDERR_FILENO) { bp_sys::close(fd); - fd = -1; } + fd = -1; + release = true; // prevent attempt to enable watch + // Here we rely on there only being two logs, console and "main"; we can check if we are the // main log via identity: if (&log_stream[DLOG_MAIN] == this) { -- 2.25.1