mirror of
https://github.com/tladesignz/dnstt.git
synced 2026-10-09 15:09:46 +03:00
Before go1.23, calling Stop, and draining the channel if the timer did not already fire, is necessary before calling Reset: https://pkg.go.dev/time@go1.22.12#Timer.Reset This changed in go1.23: now Reset automatically effectively drains the channel, and calling Stop is no longer necessary. https://pkg.go.dev/time@go1.23.9#Timer.Reset However, the changes in go1.23 only take effect if go.mod specifies 1.23 or later. We currently specify 1.21. https://go.dev/doc/go1.23#timer-changes For compatibility, do the Stop/drain procedure before calling Reset. We were already doing this for pollTimer in DNSPacketConn) sendLoop in dnstt-client. This change may not have any observable effect. The duration we Reset the timer to was 0, so if there had been a stale value in the channel because of a failure to drain it, the effect would be the same as waiting 0 seconds. We were already calling Stop when finished with the timer, so it would have been garbage-collectable even before go1.23.