From 0f7b6b13580f2d73c20c5ea5efc7606b47a68485 Mon Sep 17 00:00:00 2001 From: Anshul Pundir Date: Mon, 11 Jun 2018 14:04:20 -0700 Subject: [PATCH] [manager/dispatcher] Replace call to isRunning() to isRunningLocked() in dispatcher Heartbeat() Signed-off-by: Anshul Pundir (cherry picked from commit caee4da2afedf487d98d4e66da3de5721ba415fa) Signed-off-by: Sebastiaan van Stijn --- manager/dispatcher/dispatcher.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/manager/dispatcher/dispatcher.go b/manager/dispatcher/dispatcher.go index a343a543e2..0bdbb09e72 100644 --- a/manager/dispatcher/dispatcher.go +++ b/manager/dispatcher/dispatcher.go @@ -1143,11 +1143,8 @@ func (d *Dispatcher) Heartbeat(ctx context.Context, r *api.HeartbeatRequest) (*a d.rpcRW.RLock() defer d.rpcRW.RUnlock() - // Its OK to call isRunning() here instead of isRunningLocked() - // because of the rpcRW readlock above. - // TODO(anshul) other uses of isRunningLocked() can probably - // also be removed. - if !d.isRunning() { + // TODO(anshul) Explore if its possible to check context here without locking. + if _, err := d.isRunningLocked(); err != nil { return nil, status.Errorf(codes.Aborted, "dispatcher is stopped") }