[#598] Hold mode mutex when setting mode

Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
Alejandro Lopez 2023-08-11 16:43:23 +03:00 committed by Evgenii Stratonikov
parent ad87493c41
commit 376f03a445
2 changed files with 6 additions and 0 deletions

View file

@ -22,6 +22,9 @@ func (c *cache) SetMode(m mode.Mode) error {
)) ))
defer span.End() defer span.End()
c.modeMtx.Lock()
defer c.modeMtx.Unlock()
err := c.setMode(ctx, m) err := c.setMode(ctx, m)
if err == nil { if err == nil {
c.metrics.SetMode(m) c.metrics.SetMode(m)

View file

@ -22,6 +22,9 @@ func (c *cache) SetMode(m mode.Mode) error {
)) ))
defer span.End() defer span.End()
c.modeMtx.Lock()
defer c.modeMtx.Unlock()
err := c.setMode(ctx, m) err := c.setMode(ctx, m)
if err == nil { if err == nil {
c.metrics.SetMode(m) c.metrics.SetMode(m)