mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 23:00:58 +00:00
lib: Fix panic due to closed event subscriptions on shutdown (#8079)
This commit is contained in:
parent
bf7f82f7b2
commit
cc39341eb9
@ -178,7 +178,11 @@ func (c *folderSummaryService) listenForUpdates(ctx context.Context) error {
|
||||
// This loop needs to be fast so we don't miss too many events.
|
||||
|
||||
select {
|
||||
case ev := <-sub.C():
|
||||
case ev, ok := <-sub.C():
|
||||
if !ok {
|
||||
<-ctx.Done()
|
||||
return ctx.Err()
|
||||
}
|
||||
c.processUpdate(ev)
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
|
@ -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)
|
||||
|
@ -162,8 +162,10 @@ func (a *aggregator) mainLoop(in <-chan fs.Event, out chan<- []string, cfg confi
|
||||
select {
|
||||
case event := <-in:
|
||||
a.newEvent(event, inProgress)
|
||||
case event := <-inProgressItemSubscription.C():
|
||||
updateInProgressSet(event, inProgress)
|
||||
case event, ok := <-inProgressItemSubscription.C():
|
||||
if ok {
|
||||
updateInProgressSet(event, inProgress)
|
||||
}
|
||||
case <-a.notifyTimer.C:
|
||||
a.actOnTimer(out)
|
||||
case interval := <-a.notifyTimerResetChan:
|
||||
|
Loading…
Reference in New Issue
Block a user