fix(storage): Extend lock during stats fetch to prevent race

pull/10616/head
Ben Johnson 2018-12-13 11:05:14 -07:00
parent c7064463a4
commit 0541d568bd
No known key found for this signature in database
GPG Key ID: 81741CD251883081
2 changed files with 6 additions and 6 deletions

View File

@ -57,8 +57,8 @@ func (t *floatTable) Close() {
func (t *floatTable) Statistics() flux.Statistics {
t.mu.Lock()
defer t.mu.Unlock()
cur := t.cur
t.mu.Unlock()
if cur == nil {
return flux.Statistics{}
}
@ -289,8 +289,8 @@ func (t *integerTable) Close() {
func (t *integerTable) Statistics() flux.Statistics {
t.mu.Lock()
defer t.mu.Unlock()
cur := t.cur
t.mu.Unlock()
if cur == nil {
return flux.Statistics{}
}
@ -521,8 +521,8 @@ func (t *unsignedTable) Close() {
func (t *unsignedTable) Statistics() flux.Statistics {
t.mu.Lock()
defer t.mu.Unlock()
cur := t.cur
t.mu.Unlock()
if cur == nil {
return flux.Statistics{}
}
@ -753,8 +753,8 @@ func (t *stringTable) Close() {
func (t *stringTable) Statistics() flux.Statistics {
t.mu.Lock()
defer t.mu.Unlock()
cur := t.cur
t.mu.Unlock()
if cur == nil {
return flux.Statistics{}
}
@ -985,8 +985,8 @@ func (t *booleanTable) Close() {
func (t *booleanTable) Statistics() flux.Statistics {
t.mu.Lock()
defer t.mu.Unlock()
cur := t.cur
t.mu.Unlock()
if cur == nil {
return flux.Statistics{}
}

View File

@ -51,8 +51,8 @@ func (t *{{.name}}Table) Close() {
func (t *{{.name}}Table) Statistics() flux.Statistics {
t.mu.Lock()
defer t.mu.Unlock()
cur := t.cur
t.mu.Unlock()
if cur == nil {
return flux.Statistics{}
}