From fbe6767570a30fea5a1af31229394aaace3f01e0 Mon Sep 17 00:00:00 2001 From: Gyuho Lee Date: Mon, 26 Feb 2018 16:47:29 -0800 Subject: [PATCH] rafthttp: make "ActiveSince" non-blocking on write lock "ActiveSince" is read-only, and should be able to call concurrently, as long as there is no routine holding write lock (send, send snapshot). e.g. "ActiveSince" is used around etcd server "processInternalRaftRequestOnce", should be non-blocking Signed-off-by: Gyuho Lee --- rafthttp/transport.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rafthttp/transport.go b/rafthttp/transport.go index 6a127d972..07371e45b 100644 --- a/rafthttp/transport.go +++ b/rafthttp/transport.go @@ -338,8 +338,8 @@ func (t *Transport) UpdatePeer(id types.ID, us []string) { } func (t *Transport) ActiveSince(id types.ID) time.Time { - t.mu.Lock() - defer t.mu.Unlock() + t.mu.RLock() + defer t.mu.RUnlock() if p, ok := t.peers[id]; ok { return p.activeSince() }