void resetTimerfd(int timerfd, Timestamp expiration) { struct itimerspec newValue; struct itimerspec oldValue; bzero(&newValue, sizeof newValue); bzero(&oldValue, sizeof oldValue); newValue.it_value = howMuchTimeFromNow(expiration); int ret = ::timerfd_settime(timerfd, 0, &newValue, &oldValue); if (ret) { LOG_SYSERR << "timerfd_settime()"; } }
void TimerfdHandler::resetTimerfd(Timestamp expiration, int interval_us/* = 0*/) { struct itimerspec newValue; struct itimerspec oldValue; bzero(&newValue, sizeof(newValue)); bzero(&oldValue, sizeof(oldValue)); newValue.it_value = howMuchTimeFromNow(expiration); if(interval_us > 0) { newValue.it_interval.tv_sec = interval_us / 1000000; newValue.it_interval.tv_nsec = interval_us % 1000000; } int ret = ::timerfd_settime(timerfd_, 0, &newValue, &oldValue); if (ret) { LOG_ERROR("resetTimerfd [%d] [%d] [%s]", timerfd_, ret, strerror(errno)); } }