mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
Merge pull request #2938 from nspcc-dev/failing-actor-test
actor: don't close already closed channel, fix #2932
This commit is contained in:
commit
0d5613cfcb
1 changed files with 17 additions and 3 deletions
|
@ -290,6 +290,8 @@ func (w *EventWaiter) WaitAny(ctx context.Context, vub uint32, hashes ...util.Ui
|
|||
case _, ok := <-bRcvr:
|
||||
if !ok {
|
||||
// We're toast, retry with non-ws client.
|
||||
bRcvr = nil
|
||||
aerRcvr = nil
|
||||
wsWaitErr = ErrMissedEvent
|
||||
break
|
||||
}
|
||||
|
@ -297,6 +299,8 @@ func (w *EventWaiter) WaitAny(ctx context.Context, vub uint32, hashes ...util.Ui
|
|||
case aer, ok := <-aerRcvr:
|
||||
if !ok {
|
||||
// We're toast, retry with non-ws client.
|
||||
bRcvr = nil
|
||||
aerRcvr = nil
|
||||
wsWaitErr = ErrMissedEvent
|
||||
break
|
||||
}
|
||||
|
@ -314,8 +318,16 @@ func (w *EventWaiter) WaitAny(ctx context.Context, vub uint32, hashes ...util.Ui
|
|||
drainLoop:
|
||||
for {
|
||||
select {
|
||||
case <-bRcvr:
|
||||
case <-aerRcvr:
|
||||
case _, ok := <-bRcvr:
|
||||
if !ok { // Missed event means both channels are closed.
|
||||
bRcvr = nil
|
||||
aerRcvr = nil
|
||||
}
|
||||
case _, ok := <-aerRcvr:
|
||||
if !ok { // Missed event means both channels are closed.
|
||||
bRcvr = nil
|
||||
aerRcvr = nil
|
||||
}
|
||||
case unsubErr := <-unsubErrs:
|
||||
if unsubErr != nil {
|
||||
errFmt := "unsubscription error: %v"
|
||||
|
@ -334,8 +346,10 @@ func (w *EventWaiter) WaitAny(ctx context.Context, vub uint32, hashes ...util.Ui
|
|||
}
|
||||
}
|
||||
}
|
||||
if wsWaitErr == nil || !errors.Is(wsWaitErr, ErrMissedEvent) {
|
||||
if bRcvr != nil {
|
||||
close(bRcvr)
|
||||
}
|
||||
if aerRcvr != nil {
|
||||
close(aerRcvr)
|
||||
}
|
||||
close(unsubErrs)
|
||||
|
|
Loading…
Reference in a new issue