mirror of https://github.com/gofiber/fiber.git
🐛 fix: treat case for possible timer memory leak (#2488)
parent
369494cf25
commit
5d53263572
|
@ -11,6 +11,9 @@ func Sleep(ctx context.Context, interval time.Duration) error {
|
|||
var timer = time.NewTimer(interval)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
if !timer.Stop() {
|
||||
<-timer.C
|
||||
}
|
||||
return ctx.Err()
|
||||
case <-timer.C:
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue