mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
atomic close 2 channels (#3498)
This commit is contained in:
parent
2074b98568
commit
1ba95c1087
@ -121,6 +121,8 @@ func (pi *PeerInfo) ClearDeadlines(now time.Time, givePermit bool) int {
|
||||
}
|
||||
|
||||
func (pi *PeerInfo) Remove() {
|
||||
pi.lock.Lock()
|
||||
defer pi.lock.Unlock()
|
||||
pi.removeOnce.Do(func() {
|
||||
close(pi.removed)
|
||||
close(pi.tasks)
|
||||
@ -128,6 +130,8 @@ func (pi *PeerInfo) Remove() {
|
||||
}
|
||||
|
||||
func (pi *PeerInfo) Async(f func()) {
|
||||
pi.lock.Lock()
|
||||
defer pi.lock.Unlock()
|
||||
select {
|
||||
case <-pi.removed: // noop if peer removed
|
||||
case pi.tasks <- f:
|
||||
|
Loading…
Reference in New Issue
Block a user