diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:14 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-02 22:54:14 -0800 |
commit | fe5745033a4f397c62a4e00efd9257ac9f83755c (patch) | |
tree | 3be0c520fae17689bbf5584e1136fb820caef26f /libc | |
parent | 7d9dcdc82a871926e5e3a27143908fa3f4181b5f (diff) | |
download | bionic-fe5745033a4f397c62a4e00efd9257ac9f83755c.zip bionic-fe5745033a4f397c62a4e00efd9257ac9f83755c.tar.gz bionic-fe5745033a4f397c62a4e00efd9257ac9f83755c.tar.bz2 |
auto import from //depot/cupcake/@137055
Diffstat (limited to 'libc')
-rw-r--r-- | libc/bionic/pthread-timers.c | 19 |
1 files changed, 11 insertions, 8 deletions
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_settime( timer_t id, 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 ); |