protect writing to closed channel
This commit is contained in:
parent
67865ab530
commit
ebdc873e47
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue