auto import from //depot/cupcake/@137055
diff --git a/libc/bionic/pthread-timers.c b/libc/bionic/pthread-timers.c
index 818b47d..7b9c99e 100644
--- a/libc/bionic/pthread-timers.c
+++ b/libc/bionic/pthread-timers.c
@@ -485,16 +485,19 @@
timer_gettime_internal(timer, ospec );
}
- /* compute next expiration time */
+ /* compute next expiration time. note that if the
+ * new it_interval is 0, we should disarm the timer
+ */
expires = spec->it_value;
- clock_gettime( timer->clock, &now );
- if (!(flags & TIMER_ABSTIME)) {
- timespec_add(&expires, &now);
- } else {
- if (timespec_cmp(&expires, &now) < 0)
- expires = now;
+ if (!timespec_is_zero(&expires)) {
+ clock_gettime( timer->clock, &now );
+ if (!(flags & TIMER_ABSTIME)) {
+ timespec_add(&expires, &now);
+ } else {
+ if (timespec_cmp(&expires, &now) < 0)
+ expires = now;
+ }
}
-
timer->expires = expires;
timer->period = spec->it_interval;
thr_timer_unlock( timer );