Merge pull request #9366 from gyuho/rafthttp-mu

rafthttp: make "ActiveSince" non-blocking on write lock
This commit is contained in:
Gyuho Lee 2018-02-26 19:19:27 -08:00 committed by GitHub
commit f802cd9db2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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