eth/filters: ensure API timeoutLoop terminates with event system (#31056)

Discovered from failing test introduced
https://github.com/ethereum/go-ethereum/pull/31033 . We should ensure
`timeoutLoop` terminates if the filter event system is terminated.
This commit is contained in:
jwasinger 2025-01-21 20:11:05 +08:00 committed by GitHub
parent 2bf4a8ff73
commit 6c10996bf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -90,7 +90,11 @@ func (api *FilterAPI) timeoutLoop(timeout time.Duration) {
ticker := time.NewTicker(timeout) ticker := time.NewTicker(timeout)
defer ticker.Stop() defer ticker.Stop()
for { for {
<-ticker.C select {
case <-ticker.C:
case <-api.events.chainSub.Err():
return
}
api.filtersMu.Lock() api.filtersMu.Lock()
for id, f := range api.filters { for id, f := range api.filters {
select { select {