[v10.0.x] Plugins: Correct the usage of mutex for gRPC plugin implementation (#68609)

Plugins: Correct the usage of mutex for gRPC plugin implementation (#68555)

correct usage of mutex

(cherry picked from commit bb6ec1470d)

Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)andWill Browne authored and GitHub committed 2023-05-24 12:18:59 +00:00
1 parent d73bf1838e
commit 0946897262
1 file changed
+6 -4
@@ -52,7 +52,7 @@ func (p *grpcPlugin) Logger() log.Logger {
return p.logger
}
func (p *grpcPlugin) Start(ctx context.Context) error {
func (p *grpcPlugin) Start(_ context.Context) error {
p.mutex.Lock()
defer p.mutex.Unlock()
@@ -85,7 +85,7 @@ func (p *grpcPlugin) Start(ctx context.Context) error {
return nil
}
func (p *grpcPlugin) Stop(ctx context.Context) error {
func (p *grpcPlugin) Stop(_ context.Context) error {
p.mutex.Lock()
defer p.mutex.Unlock()
@@ -109,8 +109,8 @@ func (p *grpcPlugin) Exited() bool {
}
func (p *grpcPlugin) Decommission() error {
p.mutex.RLock()
defer p.mutex.RUnlock()
p.mutex.Lock()
defer p.mutex.Unlock()
p.decommissioned = true
@@ -118,6 +118,8 @@ func (p *grpcPlugin) Decommission() error {
}
func (p *grpcPlugin) IsDecommissioned() bool {
p.mutex.RLock()
defer p.mutex.RUnlock()
return p.decommissioned
}