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

correct usage of mutex
This commit is contained in:
Will Browne
2023-05-17 11:50:25 +02:00
committed by GitHub
parent bbb6795757
commit bb6ec1470d

View File

@ -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
}