diff --git a/daemon/ice.c b/daemon/ice.c index 3467ed8cb..83a2ad725 100644 --- a/daemon/ice.c +++ b/daemon/ice.c @@ -839,7 +839,7 @@ static void __do_ice_checks(struct ice_agent *ag) { if (AGENT_ISSET(ag, CONTROLLING) && !AGENT_ISSET(ag, NOMINATING) && ag->start_nominating) { if (rtpe_now >= ag->start_nominating) __nominate_pairs(ag); - next_run = timeval_us(timeval_lowest(timeval_from_us(next_run), timeval_from_us(ag->start_nominating))); + next_run = timeval_lowest(next_run, ag->start_nominating); } /* triggered checks are preferred */ @@ -878,7 +878,7 @@ static void __do_ice_checks(struct ice_agent *ag) { g_queue_push_tail(&retransmits, pair); /* can't run check directly due to locks */ else - next_run = timeval_us(timeval_lowest(timeval_from_us(next_run), timeval_from_us(pair->retransmit))); + next_run = timeval_lowest(next_run, pair->retransmit); continue; } diff --git a/lib/auxlib.h b/lib/auxlib.h index a0a2f1dd2..d4a81bcd6 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -386,19 +386,12 @@ INLINE int long_cmp(long long a, long long b) { return -1; return 1; } -__attribute__((warn_unused_result)) -INLINE int timeval_cmp(const struct timeval a, const struct timeval b) { - int r = long_cmp(a.tv_sec, b.tv_sec); - if (r != 0) - return r; - return long_cmp(a.tv_usec, b.tv_usec); -} __attribute__((warn_unused_result)) -INLINE struct timeval timeval_lowest(const struct timeval l, const struct timeval n) { - if (!n.tv_sec) +INLINE int64_t timeval_lowest(const int64_t l, const int64_t n) { + if (!n) return l; - if (!l.tv_sec || timeval_cmp(l, n) == 1) + if (!l || l > n) return n; return l; }