Skip to content

Commit 3b9000e

Browse files
committed
sn/policer: Do not inline sync.RWMutex
This resulted in inheritance of `sync.RWMutex` interface that was not used and was not usable at all. Signed-off-by: Leonard Lyubich <[email protected]>
1 parent 30793bd commit 3b9000e

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

pkg/services/policer/check.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ type processPlacementContext struct {
185185
}
186186

187187
func (p *Policer) processNodes(ctx context.Context, plc *processPlacementContext, nodes []netmap.NodeInfo, shortage uint32) {
188-
p.cfg.RLock()
188+
p.cfg.mtx.RLock()
189189
headTimeout := p.headTimeout
190-
p.cfg.RUnlock()
190+
p.cfg.mtx.RUnlock()
191191

192192
// Number of copies that are stored on maintenance nodes.
193193
var uncheckedCopies int

pkg/services/policer/policer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ type Network interface {
9999
}
100100

101101
type cfg struct {
102-
sync.RWMutex
102+
mtx sync.RWMutex
103103
// available for runtime reconfiguration
104104
headTimeout time.Duration
105105
repCooldown time.Duration

pkg/services/policer/process.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ func (p *Policer) Run(ctx context.Context) {
2121
}
2222

2323
func (p *Policer) shardPolicyWorker(ctx context.Context) {
24-
p.cfg.RLock()
24+
p.cfg.mtx.RLock()
2525
repCooldown := p.repCooldown
2626
batchSize := p.batchSize
27-
p.cfg.RUnlock()
27+
p.cfg.mtx.RUnlock()
2828

2929
var (
3030
addrs []objectcore.AddressWithType
@@ -80,17 +80,17 @@ func (p *Policer) shardPolicyWorker(ctx context.Context) {
8080
case <-ctx.Done():
8181
return
8282
case <-t.C:
83-
p.cfg.RLock()
83+
p.cfg.mtx.RLock()
8484
t.Reset(p.repCooldown)
85-
p.cfg.RUnlock()
85+
p.cfg.mtx.RUnlock()
8686
}
8787
}
8888
}
8989

9090
func (p *Policer) poolCapacityWorker(ctx context.Context) {
91-
p.cfg.RLock()
91+
p.cfg.mtx.RLock()
9292
maxCapacity := p.maxCapacity
93-
p.cfg.RUnlock()
93+
p.cfg.mtx.RUnlock()
9494

9595
ticker := time.NewTicker(p.rebalanceFreq)
9696
for {

pkg/services/policer/reload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ func (p *Policer) Reload(opts ...Option) {
1313
o(cfg)
1414
}
1515

16-
p.cfg.Lock()
17-
defer p.cfg.Unlock()
16+
p.cfg.mtx.Lock()
17+
defer p.cfg.mtx.Unlock()
1818

1919
p.headTimeout = cfg.headTimeout
2020
p.repCooldown = cfg.repCooldown

0 commit comments

Comments
 (0)