From 738ac55d966096e4a33c6ddea634221e27ff8528 Mon Sep 17 00:00:00 2001 From: James Phillips Date: Wed, 9 Aug 2017 18:51:55 -0700 Subject: [PATCH] Switches to using a read lock for the agent's RPC dispatcher. This prevents RPC calls from getting serialized in this spot. Fixes #3376 --- CHANGELOG.md | 2 ++ agent/agent.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7422ea74..d898fa33b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ FEATURES: IMPROVEMENTS: +* agent: Switched to using a read lock for the agent's RPC dispatcher, which prevents RPC calls from getting serialized. [GH-3376] + BUG FIXES: ## 0.9.2 (August 9, 2017) diff --git a/agent/agent.go b/agent/agent.go index ecb7798f0..652143ec5 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -956,7 +956,7 @@ func (a *Agent) registerEndpoint(name string, handler interface{}) error { // RPC is used to make an RPC call to the Consul servers // This allows the agent to implement the Consul.Interface func (a *Agent) RPC(method string, args interface{}, reply interface{}) error { - a.endpointsLock.Lock() + a.endpointsLock.RLock() // fast path: only translate if there are overrides if len(a.endpoints) > 0 { p := strings.SplitN(method, ".", 2) @@ -964,7 +964,7 @@ func (a *Agent) RPC(method string, args interface{}, reply interface{}) error { method = e + "." + p[1] } } - a.endpointsLock.Unlock() + a.endpointsLock.RUnlock() return a.delegate.RPC(method, args, reply) }