From f5592ff01b760a6c325a7f039b1d83bea395afc4 Mon Sep 17 00:00:00 2001 From: Jie Shen Date: Thu, 5 Sep 2019 14:12:52 +0800 Subject: [PATCH] Prevent sending data to closed dirtyResult channel --- storage/storage.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/storage/storage.go b/storage/storage.go index 427bd0df..aec6b3ae 100644 --- a/storage/storage.go +++ b/storage/storage.go @@ -517,9 +517,10 @@ func (sl *LeaserCheckpointer) persistDirtyPartitions(ctx context.Context) error for _, pid := range pids { go func(id string) { err := sl.persistLease(ctx, id) - resCh <- dirtyResult{ - Err: err, - PartitionID: id, + select { + case <-ctx.Done(): + return + case resCh <- dirtyResult{PartitionID: id, Err: err}: } }(pid) }