Skip to content

Commit

Permalink
runtime: don't call sleepTicks with a negative duration
Browse files Browse the repository at this point in the history
There are rare cases where this can happen, see for example
#4568
  • Loading branch information
aykevl committed Oct 30, 2024
1 parent 0edeaf6 commit c93697f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/runtime/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ func scheduler(returnAtDeadlock bool) {
println("--- timer waiting:", tim, tim.whenTicks())
}
}
sleepTicks(timeLeft)
if asyncScheduler {
// The sleepTicks function above only sets a timeout at which
// point the scheduler will be called again. It does not really
// sleep. So instead of sleeping, we return and expect to be
// called again.
break
if timeLeft > 0 {
sleepTicks(timeLeft)
if asyncScheduler {
// The sleepTicks function above only sets a timeout at
// which point the scheduler will be called again. It does
// not really sleep. So instead of sleeping, we return and
// expect to be called again.
break
}
}
continue
}
Expand Down

0 comments on commit c93697f

Please sign in to comment.