change check_timer() to handle timer wraparound correctly

it's important that the compared values can never become more
than 2^31 apart, so separate the timer subtraction from the
comparison against the desired interval.