lib: Fix panic due to closed event subscriptions on shutdown (#8079)
This commit is contained in:
@@ -38,7 +38,11 @@ func (s *auditService) Serve(ctx context.Context) error {
|
||||
|
||||
for {
|
||||
select {
|
||||
case ev := <-sub.C():
|
||||
case ev, ok := <-sub.C():
|
||||
if !ok {
|
||||
<-ctx.Done()
|
||||
return ctx.Err()
|
||||
}
|
||||
enc.Encode(ev)
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
|
||||
@@ -31,7 +31,11 @@ func (s *verboseService) Serve(ctx context.Context) error {
|
||||
defer sub.Unsubscribe()
|
||||
for {
|
||||
select {
|
||||
case ev := <-sub.C():
|
||||
case ev, ok := <-sub.C():
|
||||
if !ok {
|
||||
<-ctx.Done()
|
||||
return ctx.Err()
|
||||
}
|
||||
formatted := s.formatEvent(ev)
|
||||
if formatted != "" {
|
||||
l.Verboseln(formatted)
|
||||
|
||||
Reference in New Issue
Block a user