Skip to content

Commit

Permalink
[RC][FA] Move mutex usage (#29974)
Browse files Browse the repository at this point in the history
  • Loading branch information
coignetp authored Oct 9, 2024
1 parent e4f8069 commit 0ea8e91
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions comp/remote-config/rcclient/rcclientimpl/rcclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,6 @@ func (rc rcClient) agentConfigUpdateCallback(updates map[string]state.RawConfig,
// The RCClient can directly call back listeners, because there would be no way to send back
// RCTE2 configuration applied state to RC backend.
func (rc rcClient) agentTaskUpdateCallback(updates map[string]state.RawConfig, applyStateCallback func(string, state.ApplyStatus)) {
rc.m.Lock()
defer rc.m.Unlock()

wg := &sync.WaitGroup{}
wg.Add(len(updates))

Expand All @@ -332,9 +329,11 @@ func (rc rcClient) agentTaskUpdateCallback(updates map[string]state.RawConfig, a
return
}

rc.m.Lock()
// Check that the flare task wasn't already processed
if !rc.taskProcessed[task.Config.UUID] {
rc.taskProcessed[task.Config.UUID] = true
rc.m.Unlock()

// Mark it as unack first
applyStateCallback(configPath, state.ApplyStatus{
Expand Down Expand Up @@ -373,6 +372,8 @@ func (rc rcClient) agentTaskUpdateCallback(updates map[string]state.RawConfig, a
State: state.ApplyStateUnknown,
})
}
} else {
rc.m.Unlock()
}
}(originalConfigPath, originalConfig)
}
Expand Down

0 comments on commit 0ea8e91

Please sign in to comment.