mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
swarm/network/stream: add missing WaitGroup.Add and fix errc send blocking
This commit is contained in:
parent
2605f59bc0
commit
b3be75c537
1 changed files with 9 additions and 2 deletions
|
|
@ -300,6 +300,7 @@ func runSyncTest(chunkCount int, nodeCount int, live bool, history bool) error {
|
|||
if wsDoneC == nil {
|
||||
continue
|
||||
}
|
||||
rpcSubscriptionsWg.Add(1)
|
||||
go func() {
|
||||
<-wsDoneC
|
||||
rpcSubscriptionsWg.Done()
|
||||
|
|
@ -628,7 +629,10 @@ func watchSubscriptionEvents(ctx context.Context, id discover.NodeID, client *rp
|
|||
case <-quitC:
|
||||
return
|
||||
case <-ctx.Done():
|
||||
errc <- ctx.Err()
|
||||
select {
|
||||
case errc <- ctx.Err():
|
||||
case <-quitC:
|
||||
}
|
||||
return
|
||||
case e := <-events:
|
||||
//just catch SubscribeMsg
|
||||
|
|
@ -637,7 +641,10 @@ func watchSubscriptionEvents(ctx context.Context, id discover.NodeID, client *rp
|
|||
}
|
||||
case err := <-sub.Err():
|
||||
if err != nil {
|
||||
errc <- fmt.Errorf("error getting peer events for node %v: %v", id, err)
|
||||
select {
|
||||
case errc <- fmt.Errorf("error getting peer events for node %v: %v", id, err):
|
||||
case <-quitC:
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue