mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-28 18:51:53 +01:00
actually this is the real fix.
This commit is contained in:
parent
181234d774
commit
4ca8320e18
18
pool.go
18
pool.go
@ -263,13 +263,11 @@ func (pool *SimplePool) subMany(
|
|||||||
seenAlready := xsync.NewMapOf[string, Timestamp]()
|
seenAlready := xsync.NewMapOf[string, Timestamp]()
|
||||||
ticker := time.NewTicker(seenAlreadyDropTick)
|
ticker := time.NewTicker(seenAlreadyDropTick)
|
||||||
|
|
||||||
eosed := false
|
|
||||||
eoseWg := sync.WaitGroup{}
|
eoseWg := sync.WaitGroup{}
|
||||||
eoseWg.Add(len(urls))
|
eoseWg.Add(len(urls))
|
||||||
if eoseChan != nil {
|
if eoseChan != nil {
|
||||||
go func() {
|
go func() {
|
||||||
eoseWg.Wait()
|
eoseWg.Wait()
|
||||||
eosed = true
|
|
||||||
close(eoseChan)
|
close(eoseChan)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -285,12 +283,18 @@ func (pool *SimplePool) subMany(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eosed := false
|
||||||
|
firstConnection := true
|
||||||
|
|
||||||
go func(nm string) {
|
go func(nm string) {
|
||||||
defer func() {
|
defer func() {
|
||||||
pending.Dec()
|
pending.Dec()
|
||||||
if pending.Value() == 0 {
|
if pending.Value() == 0 {
|
||||||
close(events)
|
close(events)
|
||||||
}
|
}
|
||||||
|
if !eosed {
|
||||||
|
eoseWg.Done()
|
||||||
|
}
|
||||||
cancel()
|
cancel()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -319,8 +323,15 @@ func (pool *SimplePool) subMany(
|
|||||||
|
|
||||||
relay, err := pool.EnsureRelay(nm)
|
relay, err := pool.EnsureRelay(nm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// if we never connected to this just fail
|
||||||
|
if firstConnection {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise (if we were connected and got disconnected) keep trying to reconnect
|
||||||
goto reconnect
|
goto reconnect
|
||||||
}
|
}
|
||||||
|
firstConnection = false
|
||||||
hasAuthed = false
|
hasAuthed = false
|
||||||
|
|
||||||
subscribe:
|
subscribe:
|
||||||
@ -340,6 +351,7 @@ func (pool *SimplePool) subMany(
|
|||||||
|
|
||||||
// guard here otherwise a resubscription will trigger a duplicate call to eoseWg.Done()
|
// guard here otherwise a resubscription will trigger a duplicate call to eoseWg.Done()
|
||||||
if !eosed {
|
if !eosed {
|
||||||
|
eosed = true
|
||||||
eoseWg.Done()
|
eoseWg.Done()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -396,8 +408,6 @@ func (pool *SimplePool) subMany(
|
|||||||
log.Printf("CLOSED from %s: '%s'\n", nm, reason)
|
log.Printf("CLOSED from %s: '%s'\n", nm, reason)
|
||||||
}
|
}
|
||||||
|
|
||||||
eoseWg.Done()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user