Browse Source

Merge pull request #9366 from gyuho/rafthttp-mu

rafthttp: make "ActiveSince" non-blocking on write lock
Gyuho Lee 7 years ago
parent
commit
f802cd9db2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      rafthttp/transport.go

+ 2 - 2
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 {
 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 {
 	if p, ok := t.peers[id]; ok {
 		return p.activeSince()
 		return p.activeSince()
 	}
 	}