mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-02-03 04:03:07 +00:00
emit new peer notification without holding the semaphore
This commit is contained in:
parent
ac4a401fd6
commit
861bb84b1e
12
notify.go
12
notify.go
@ -24,15 +24,13 @@ func (p *PubSubNotif) Connected(n network.Network, c network.Conn) {
|
||||
|
||||
select {
|
||||
case <-p.newPeersSema:
|
||||
defer func() {
|
||||
p.newPeersSema <- struct{}{}
|
||||
}()
|
||||
|
||||
case <-p.ctx.Done():
|
||||
return
|
||||
}
|
||||
|
||||
p.newPeersPend[c.RemotePeer()] = struct{}{}
|
||||
p.newPeersSema <- struct{}{}
|
||||
|
||||
select {
|
||||
case p.newPeers <- struct{}{}:
|
||||
default:
|
||||
@ -61,10 +59,6 @@ func (p *PubSubNotif) Initialize() {
|
||||
|
||||
select {
|
||||
case <-p.newPeersSema:
|
||||
defer func() {
|
||||
p.newPeersSema <- struct{}{}
|
||||
}()
|
||||
|
||||
case <-p.ctx.Done():
|
||||
return
|
||||
}
|
||||
@ -76,6 +70,8 @@ func (p *PubSubNotif) Initialize() {
|
||||
p.newPeersPend[pid] = struct{}{}
|
||||
}
|
||||
|
||||
p.newPeersSema <- struct{}{}
|
||||
|
||||
select {
|
||||
case p.newPeers <- struct{}{}:
|
||||
default:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user