Skip to content

Commit

Permalink
Prepare timers for go1.23. (#1552)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickeskov authored Dec 2, 2024
1 parent a665f90 commit b7d5cb5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
5 changes: 4 additions & 1 deletion pkg/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ func (a *App) TransactionsBroadcast(ctx context.Context, b []byte) (proto.Transa
)
defer func() {
if !delay.Stop() && !fired {
<-delay.C
select {
case <-delay.C:
default:
}
}
}()
select {
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/metamask/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,10 @@ func (s RPCService) Eth_SendRawTransaction(signedTxData string) (proto.EthereumH
return proto.EthereumHash{}, errors.New("timeout waiting response from internal FSM")
case err := <-respCh:
if !timer.Stop() {
<-timer.C
select {
case <-timer.C:
default:
}
}
if err != nil {
zap.S().Debugf("Eth_SendRawTransaction: error from internal FSM for ethereum tx (ethTxID=%q, to=%q, from=%q): %v",
Expand Down
5 changes: 4 additions & 1 deletion pkg/libs/ntptime/ntptime.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ func (a *ntpTimeImpl) Run(ctx context.Context, duration time.Duration) {
select {
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
select {
case <-timer.C:
default:
}
}
return
case <-timer.C:
Expand Down
5 changes: 4 additions & 1 deletion pkg/node/fsm/tasks/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,10 @@ func (a SnapshotTimeoutTask) Run(ctx context.Context, output chan AsyncTask) err
t := time.NewTimer(a.timeout)
defer func() {
if !t.Stop() {
<-t.C
select {
case <-t.C:
default:
}
}
}()
select {
Expand Down
10 changes: 8 additions & 2 deletions pkg/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ func (a *Node) runInternalMetrics(ctx context.Context, ch chan peer.ProtoMessage
select {
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
select {
case <-timer.C:
default:
}
}
return
case <-timer.C:
Expand All @@ -238,7 +241,10 @@ func (a *Node) runOutgoingConnections(ctx context.Context) {
select {
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
select {
case <-timer.C:
default:
}
}
return
case <-timer.C:
Expand Down
5 changes: 4 additions & 1 deletion pkg/util/limit_listener/listen.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ func (l *limitListener) acquire() bool {
timer := time.NewTimer(l.waitConnQuotaTimeout)
stopTimer := func() {
if !timer.Stop() {
<-timer.C
select {
case <-timer.C:
default:
}
}
}
select {
Expand Down

0 comments on commit b7d5cb5

Please sign in to comment.