mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Ensure that flush do not get called on closed file
This commit is contained in:
@@ -45,6 +45,7 @@ type FileOutput struct {
|
||||
writer io.Writer
|
||||
requestPerFile bool
|
||||
currentID string
|
||||
closed bool
|
||||
|
||||
config *FileOutputConfig
|
||||
}
|
||||
@@ -63,8 +64,13 @@ func NewFileOutput(pathTemplate string, config *FileOutputConfig) *FileOutput {
|
||||
go func() {
|
||||
for {
|
||||
time.Sleep(config.flushInterval)
|
||||
if o.closed {
|
||||
break
|
||||
}
|
||||
o.mu.Lock()
|
||||
o.updateName()
|
||||
o.flush()
|
||||
o.mu.Unlock()
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -250,5 +256,7 @@ func (o *FileOutput) Close() error {
|
||||
}
|
||||
o.file.Close()
|
||||
}
|
||||
|
||||
o.closed = true
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user