From e69438b20664c629057fee0f2a971a2978c0d442 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 17 May 2023 08:26:49 +0930 Subject: [PATCH] [8.8](backport #35474) winlogbeat: allow termination while attempting to open channels (#35492) * winlogbeat: allow termination while attempting to open channels (#35474) Currently, if winlogbeat is attempting to open a channel that is not available because it is not found or there is a recoverable error, it will loop and retry. Since signals have been sent to notification handlers by this point, cancellation of the loop is not possible without agreement. So add a cancellation select at the head of the retry loop to allow termination. (cherry picked from commit a927de0fb2463273dbb0126fd9ebdd296a9a26a9) * Update CHANGELOG.next.asciidoc --------- Co-authored-by: Dan Kortschak <90160302+efd6@users.noreply.github.com> --- CHANGELOG.next.asciidoc | 1 + winlogbeat/beater/eventlogger.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index af9f24e5473..57214c76e22 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -204,6 +204,7 @@ automatic splitting at root level, if root level element is an array. {pull}3415 - Improve documentation for event_logs.name configuration. {pull}34931[34931] - Move repeated channel not found errors to debug level. {issue}35314[35314] {pull}35317[35317] - Fix panic due to misrepresented buffer use. {pull}35437[35437] +- Allow program termination when attempting to open an absent channel. {pull}35474[35474] *Functionbeat* diff --git a/winlogbeat/beater/eventlogger.go b/winlogbeat/beater/eventlogger.go index 71fcbad04ab..3176ecd7c36 100644 --- a/winlogbeat/beater/eventlogger.go +++ b/winlogbeat/beater/eventlogger.go @@ -136,6 +136,12 @@ func (e *eventLogger) run( runLoop: for stop := false; !stop; { + select { + case <-done: + return + default: + } + err = api.Open(state) switch {