forked from TrueCloudLab/frostfs-node
[#1693] storage: Replace conditional panics with asserts
Change-Id: I9d8ccde3c71fca716856c7bfc53da20ee0542f20 Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
a285d8924f
commit
fc6abe30b8
4 changed files with 17 additions and 26 deletions
|
@ -3,6 +3,8 @@ package writecache
|
|||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/assert"
|
||||
)
|
||||
|
||||
var errLimiterClosed = errors.New("acquire failed: limiter closed")
|
||||
|
@ -45,17 +47,11 @@ func (l *flushLimiter) release(size uint64) {
|
|||
l.cond.L.Lock()
|
||||
defer l.cond.L.Unlock()
|
||||
|
||||
if l.size >= size {
|
||||
l.size -= size
|
||||
} else {
|
||||
panic("flushLimiter: invalid size")
|
||||
}
|
||||
assert.True(l.size >= size, "flushLimiter: invalid size")
|
||||
l.size -= size
|
||||
|
||||
if l.count > 0 {
|
||||
l.count--
|
||||
} else {
|
||||
panic("flushLimiter: invalid count")
|
||||
}
|
||||
assert.True(l.count > 0, "flushLimiter: invalid count")
|
||||
l.count--
|
||||
|
||||
l.cond.Broadcast()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue