mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-04 06:53:06 +00:00
fix: noise protocol channel close race condition
This commit is contained in:
parent
42b2c0bc6d
commit
884f65ecdf
@ -95,6 +95,7 @@ func (r *NoiseWakuRelay) Subscribe(ctx context.Context, contentTopic string) <-c
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
close(sub.msgChan)
|
||||||
return
|
return
|
||||||
case env := <-sub.broadcastSub.Ch:
|
case env := <-sub.broadcastSub.Ch:
|
||||||
if env == nil {
|
if env == nil {
|
||||||
@ -137,7 +138,6 @@ func (r *NoiseWakuRelay) Stop() {
|
|||||||
for _, contentTopicSubscriptions := range r.subscriptionChPerContentTopic {
|
for _, contentTopicSubscriptions := range r.subscriptionChPerContentTopic {
|
||||||
for _, c := range contentTopicSubscriptions {
|
for _, c := range contentTopicSubscriptions {
|
||||||
c.broadcastSub.Unsubscribe()
|
c.broadcastSub.Unsubscribe()
|
||||||
close(c.msgChan)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user