From ebdc873e478fe6bd67256d4fa31746bc382d3117 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Mon, 18 Apr 2016 11:46:57 -0700 Subject: [PATCH] protect writing to closed channel --- client/driver/logging/rotator.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/driver/logging/rotator.go b/client/driver/logging/rotator.go index 5606d600f..5cf200ee2 100644 --- a/client/driver/logging/rotator.go +++ b/client/driver/logging/rotator.go @@ -130,7 +130,9 @@ func (f *FileRotator) nextFile() error { break } // Purge old files if we have more files than MaxFiles - if f.logFileIdx-f.oldestLogFileIdx >= f.MaxFiles { + f.closedLock.Lock() + defer f.closedLock.Unlock() + if f.logFileIdx-f.oldestLogFileIdx >= f.MaxFiles && !f.closed { select { case f.purgeCh <- struct{}{}: default: