protect writing to closed channel
This commit is contained in:
parent
67865ab530
commit
ebdc873e47
|
@ -130,7 +130,9 @@ func (f *FileRotator) nextFile() error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Purge old files if we have more files than MaxFiles
|
// 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 {
|
select {
|
||||||
case f.purgeCh <- struct{}{}:
|
case f.purgeCh <- struct{}{}:
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue