add ps.lock.Unlock() before return

This commit is contained in:
cpusoft 2018-03-22 11:38:52 +08:00 committed by GitHub
parent 933972d139
commit 2e436fb9a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -545,9 +545,11 @@ func (ps *peerSet) notify(n peerSetNotify) {
func (ps *peerSet) Register(p *peer) error {
ps.lock.Lock()
if ps.closed {
ps.lock.Unlock()
return errClosed
}
if _, ok := ps.peers[p.id]; ok {
ps.lock.Unlock()
return errAlreadyRegistered
}
ps.peers[p.id] = p