Allow Close to be called multiple times safely
parent
c7bbe6ef17
commit
1bcb1d033f
|
@ -36,7 +36,7 @@
|
|||
- [#5478](https://github.com/influxdata/influxdb/issues/5478): panic: interface conversion: interface is float64, not int64
|
||||
- [#5475](https://github.com/influxdata/influxdb/issues/5475): Ensure appropriate exit code returned for non-interactive use of CLI.
|
||||
- [#5479](https://github.com/influxdata/influxdb/issues/5479): Bringing up a node as a meta only node causes panic
|
||||
- [#5504](https://github.com/influxdata/influxdb/issues/5475): create retention policy on unexistant DB crash InfluxDB
|
||||
- [#5504](https://github.com/influxdata/influxdb/issues/5504): create retention policy on unexistant DB crash InfluxDB
|
||||
- [#5505](https://github.com/influxdata/influxdb/issues/5505): Clear authCache in meta.Client when password changes.
|
||||
- [#5244](https://github.com/influxdata/influxdb/issues/5244): panic: ensure it's safe to close engine multiple times.
|
||||
|
||||
|
|
|
@ -141,8 +141,15 @@ func (e *Engine) Open() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Close closes the engine.
|
||||
// Close closes the engine. Subsequent calls to Close are a nop.
|
||||
func (e *Engine) Close() error {
|
||||
e.mu.RLock()
|
||||
if e.done == nil {
|
||||
e.mu.RUnlock()
|
||||
return nil
|
||||
}
|
||||
e.mu.RUnlock()
|
||||
|
||||
// Shutdown goroutines and wait.
|
||||
close(e.done)
|
||||
e.wg.Wait()
|
||||
|
@ -150,6 +157,7 @@ func (e *Engine) Close() error {
|
|||
// Lock now and close everything else down.
|
||||
e.mu.Lock()
|
||||
defer e.mu.Unlock()
|
||||
e.done = nil // Ensures that the channel will not be closed again.
|
||||
|
||||
if err := e.FileStore.Close(); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue