mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-02-21 21:13:13 +00:00
do the notification in a goroutine
don't block the swarm while waiting for the semaphore.
This commit is contained in:
parent
861bb84b1e
commit
0732576319
24
notify.go
24
notify.go
@ -22,19 +22,21 @@ func (p *PubSubNotif) Connected(n network.Network, c network.Conn) {
|
||||
return
|
||||
}
|
||||
|
||||
select {
|
||||
case <-p.newPeersSema:
|
||||
case <-p.ctx.Done():
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
select {
|
||||
case <-p.newPeersSema:
|
||||
case <-p.ctx.Done():
|
||||
return
|
||||
}
|
||||
|
||||
p.newPeersPend[c.RemotePeer()] = struct{}{}
|
||||
p.newPeersSema <- struct{}{}
|
||||
p.newPeersPend[c.RemotePeer()] = struct{}{}
|
||||
p.newPeersSema <- struct{}{}
|
||||
|
||||
select {
|
||||
case p.newPeers <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
select {
|
||||
case p.newPeers <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func (p *PubSubNotif) Disconnected(n network.Network, c network.Conn) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user