Skip to content

Commit

Permalink
[7.17](backport #30006) Fix loop while reading from standalone evtx (#…
Browse files Browse the repository at this point in the history
…30188)

* Fix loop while reading from standalone evtx (#30006)

- Fix loop while reading from standalone evtx file
- Moved stop variable and check to outer loop

Co-authored-by: Taylor Swanson <[email protected]>
(cherry picked from commit 3c6724a)
  • Loading branch information
mergify[bot] authored Feb 3, 2022
1 parent 13c9079 commit 31a6c5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Winlogbeat*

- Fix run loop when reading from evtx file {pull}30006[30006]

*Functionbeat*

Expand Down
7 changes: 5 additions & 2 deletions winlogbeat/beater/eventlogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (e *eventLogger) run(
}()

runLoop:
for {
for stop := false; !stop; {
err = api.Open(state)
if eventlog.IsRecoverable(err) {
e.log.Warnw("Open() encountered recoverable error. Trying again...", "error", err)
Expand All @@ -142,7 +142,7 @@ runLoop:
}
e.log.Debug("Opened successfully.")

for stop := false; !stop; {
for !stop {
select {
case <-done:
return
Expand Down Expand Up @@ -171,6 +171,9 @@ runLoop:
e.log.Debugf("Read() returned %d records.", len(records))
if len(records) == 0 {
time.Sleep(time.Second)
if stop {
return
}
continue
}

Expand Down

0 comments on commit 31a6c5d

Please sign in to comment.