audit/kafka: Fix quitting early after first logging (#14932)

A recent commit created some regressions:
- Kafka/Audit goroutines quit when the first log is sent
- Missing doneCh initialization in Kafka audit
This commit is contained in:
Anis Elleuch 2022-05-17 15:43:25 +01:00 committed by GitHub
parent 040ac5cad8
commit e952e2a691
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View file

@ -179,11 +179,13 @@ func (h *Target) startHTTPLogger() {
go func() {
defer h.wg.Done()
select {
case entry := <-h.logCh:
h.logEntry(entry)
case <-h.doneCh:
return
for {
select {
case entry := <-h.logCh:
h.logEntry(entry)
case <-h.doneCh:
return
}
}
}()
}

View file

@ -96,11 +96,13 @@ func (h *Target) startKakfaLogger() {
go func() {
defer h.wg.Done()
select {
case entry := <-h.logCh:
h.logEntry(entry)
case <-h.doneCh:
return
for {
select {
case entry := <-h.logCh:
h.logEntry(entry)
case <-h.doneCh:
return
}
}
}()
}
@ -230,6 +232,7 @@ func (h *Target) Cancel() {
func New(config Config) *Target {
target := &Target{
logCh: make(chan interface{}, 10000),
doneCh: make(chan struct{}),
kconfig: config,
}
return target