Skip to content

Commit

Permalink
leveldb/utils: held mutex on BufferPool.String()
Browse files Browse the repository at this point in the history
The stringer method may not called often so using mutex here should
be fine. syndtr#312
  • Loading branch information
syndtr committed Aug 15, 2020
1 parent d0f67a2 commit d9e9293
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions leveldb/util/buffer_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ func (p *BufferPool) String() string {
return "<nil>"
}

p.mu.Lock()
defer p.mu.Unlock()

return fmt.Sprintf("BufferPool{B·%d Z·%v Zm·%v Zh·%v G·%d P·%d H·%d <·%d =·%d >·%d M·%d}",
p.baseline0, p.size, p.sizeMiss, p.sizeHalf, p.get, p.put, p.half, p.less, p.equal, p.greater, p.miss)
}
Expand Down

0 comments on commit d9e9293

Please sign in to comment.