Skip to content

Commit

Permalink
protect writing to closed channel
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Apr 18, 2016
1 parent fcd9a55 commit c3c3b66
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/driver/logging/rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c3c3b66

Please sign in to comment.