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
2 changed files with 15 additions and 10 deletions
+2
View File
@@ -179,12 +179,14 @@ func (h *Target) startHTTPLogger() {
go func() { go func() {
defer h.wg.Done() defer h.wg.Done()
for {
select { select {
case entry := <-h.logCh: case entry := <-h.logCh:
h.logEntry(entry) h.logEntry(entry)
case <-h.doneCh: case <-h.doneCh:
return return
} }
}
}() }()
} }
+3
View File
@@ -96,12 +96,14 @@ func (h *Target) startKakfaLogger() {
go func() { go func() {
defer h.wg.Done() defer h.wg.Done()
for {
select { select {
case entry := <-h.logCh: case entry := <-h.logCh:
h.logEntry(entry) h.logEntry(entry)
case <-h.doneCh: case <-h.doneCh:
return return
} }
}
}() }()
} }
@@ -230,6 +232,7 @@ func (h *Target) Cancel() {
func New(config Config) *Target { func New(config Config) *Target {
target := &Target{ target := &Target{
logCh: make(chan interface{}, 10000), logCh: make(chan interface{}, 10000),
doneCh: make(chan struct{}),
kconfig: config, kconfig: config,
} }
return target return target