tree-wide: use usec_add() and usec_sub_unsigned()
This commit is contained in:
@@ -756,7 +756,7 @@ int wait_for_terminate_with_timeout(pid_t pid, usec_t timeout) {
|
||||
|
||||
/* Drop into a sigtimewait-based timeout. Waiting for the
|
||||
* pid to exit. */
|
||||
until = now(CLOCK_MONOTONIC) + timeout;
|
||||
until = usec_add(now(CLOCK_MONOTONIC), timeout);
|
||||
for (;;) {
|
||||
usec_t n;
|
||||
siginfo_t status = {};
|
||||
|
||||
@@ -19,7 +19,7 @@ bool ratelimit_below(RateLimit *r) {
|
||||
ts = now(CLOCK_MONOTONIC);
|
||||
|
||||
if (r->begin <= 0 ||
|
||||
ts - r->begin > r->interval) {
|
||||
usec_sub_unsigned(ts, r->begin) > r->interval) {
|
||||
r->begin = ts;
|
||||
|
||||
/* Reset counter */
|
||||
|
||||
@@ -440,11 +440,11 @@ int acquire_terminal(
|
||||
|
||||
assert(ts != USEC_INFINITY);
|
||||
|
||||
n = now(CLOCK_MONOTONIC);
|
||||
if (ts + timeout < n)
|
||||
n = usec_sub_unsigned(now(CLOCK_MONOTONIC), ts);
|
||||
if (n >= timeout)
|
||||
return -ETIMEDOUT;
|
||||
|
||||
r = fd_wait_for_event(notify, POLLIN, ts + timeout - n);
|
||||
r = fd_wait_for_event(notify, POLLIN, usec_sub_unsigned(timeout, n));
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
|
||||
Reference in New Issue
Block a user