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)
|
var timer = time.NewTimer(interval)
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
if !timer.Stop() {
|
||||||
|
<-timer.C
|
||||||
|
}
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue