From: Davin McCall Date: Wed, 1 Jan 2020 05:46:49 +0000 (+1000) Subject: Make sure we don't try to enable log watcher after deregistration X-Git-Tag: v0.8.1~1 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=505552220d5ab7eee3071cfe8ec981f98744b815;p=oweals%2Fdinit.git 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. --- 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) {