rpc, eth/filters: use non-blocking timer drain pattern

This commit is contained in:
JukLee0ira 2025-02-07 16:22:25 +08:00
parent d11e9c0b51
commit ff6c6d4a92
2 changed files with 8 additions and 2 deletions

View file

@ -435,7 +435,10 @@ func (api *FilterAPI) GetFilterChanges(id rpc.ID) (interface{}, error) {
if !f.deadline.Stop() { if !f.deadline.Stop() {
// timer expired but filter is not yet removed in timeout loop // timer expired but filter is not yet removed in timeout loop
// receive timer value and reset timer // receive timer value and reset timer
<-f.deadline.C select {
case <-f.deadline.C:
default:
}
} }
f.deadline.Reset(api.timeout) f.deadline.Reset(api.timeout)

View file

@ -357,7 +357,10 @@ func (wc *websocketCodec) pingLoop() {
case <-wc.pingReset: case <-wc.pingReset:
if !pingTimer.Stop() { if !pingTimer.Stop() {
<-pingTimer.C select {
case <-pingTimer.C:
default:
}
} }
pingTimer.Reset(wsPingInterval) pingTimer.Reset(wsPingInterval)