mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Revert "event: fix Resubscribe deadlock when unsubscribing after inner sub ends (#28359)"
This reverts commit 3a1adc8a6e.
This commit is contained in:
parent
190c6c8923
commit
b2c2e00212
2 changed files with 1 additions and 25 deletions
|
|
@ -120,7 +120,7 @@ func ResubscribeErr(backoffMax time.Duration, fn ResubscribeErrFunc) Subscriptio
|
||||||
backoffMax: backoffMax,
|
backoffMax: backoffMax,
|
||||||
fn: fn,
|
fn: fn,
|
||||||
err: make(chan error),
|
err: make(chan error),
|
||||||
unsub: make(chan struct{}, 1),
|
unsub: make(chan struct{}),
|
||||||
}
|
}
|
||||||
go s.loop()
|
go s.loop()
|
||||||
return s
|
return s
|
||||||
|
|
|
||||||
|
|
@ -154,27 +154,3 @@ func TestResubscribeWithErrorHandler(t *testing.T) {
|
||||||
t.Fatalf("unexpected subscription errors %v, want %v", subErrs, expectedSubErrs)
|
t.Fatalf("unexpected subscription errors %v, want %v", subErrs, expectedSubErrs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResubscribeWithCompletedSubscription(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
quitProducerAck := make(chan struct{})
|
|
||||||
quitProducer := make(chan struct{})
|
|
||||||
|
|
||||||
sub := ResubscribeErr(100*time.Millisecond, func(ctx context.Context, lastErr error) (Subscription, error) {
|
|
||||||
return NewSubscription(func(unsubscribed <-chan struct{}) error {
|
|
||||||
select {
|
|
||||||
case <-quitProducer:
|
|
||||||
quitProducerAck <- struct{}{}
|
|
||||||
return nil
|
|
||||||
case <-unsubscribed:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}), nil
|
|
||||||
})
|
|
||||||
|
|
||||||
// Ensure producer has started and exited before Unsubscribe
|
|
||||||
close(quitProducer)
|
|
||||||
<-quitProducerAck
|
|
||||||
sub.Unsubscribe()
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue