1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

Merge pull request #22885 from poettering/kill-clock-boottime-or-monotonic

time-util: assume CLOCK_BOOTTIME always exists
This commit is contained in:
Yu Watanabe 2022-03-29 03:06:54 +09:00 committed by GitHub
commit 2afb2f4a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
46 changed files with 122 additions and 176 deletions

2
README
View File

@ -30,7 +30,7 @@ LICENSE:
LGPL-2.1-or-later for all code, exceptions noted in LICENSES/README.md LGPL-2.1-or-later for all code, exceptions noted in LICENSES/README.md
REQUIREMENTS: REQUIREMENTS:
Linux kernel >= 3.13 Linux kernel >= 3.15
Linux kernel >= 4.2 for unified cgroup hierarchy support Linux kernel >= 4.2 for unified cgroup hierarchy support
Linux kernel >= 4.10 for cgroup-bpf egress and ingress hooks Linux kernel >= 4.10 for cgroup-bpf egress and ingress hooks
Linux kernel >= 4.15 for cgroup-bpf device hook Linux kernel >= 4.15 for cgroup-bpf device hook

View File

@ -77,7 +77,7 @@ triple_timestamp* triple_timestamp_get(triple_timestamp *ts) {
ts->realtime = now(CLOCK_REALTIME); ts->realtime = now(CLOCK_REALTIME);
ts->monotonic = now(CLOCK_MONOTONIC); ts->monotonic = now(CLOCK_MONOTONIC);
ts->boottime = clock_boottime_supported() ? now(CLOCK_BOOTTIME) : USEC_INFINITY; ts->boottime = now(CLOCK_BOOTTIME);
return ts; return ts;
} }
@ -150,9 +150,7 @@ triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u)
ts->realtime = u; ts->realtime = u;
ts->monotonic = map_clock_usec_internal(u, nowr, now(CLOCK_MONOTONIC)); ts->monotonic = map_clock_usec_internal(u, nowr, now(CLOCK_MONOTONIC));
ts->boottime = clock_boottime_supported() ? ts->boottime = map_clock_usec_internal(u, nowr, now(CLOCK_BOOTTIME));
map_clock_usec_internal(u, nowr, now(CLOCK_BOOTTIME)) :
USEC_INFINITY;
return ts; return ts;
} }
@ -170,8 +168,7 @@ dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) {
return ts; return ts;
} }
dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, usec_t u) { dual_timestamp* dual_timestamp_from_boottime(dual_timestamp *ts, usec_t u) {
clockid_t cid;
usec_t nowm; usec_t nowm;
if (u == USEC_INFINITY) { if (u == USEC_INFINITY) {
@ -179,14 +176,8 @@ dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, us
return ts; return ts;
} }
cid = clock_boottime_or_monotonic(); nowm = now(CLOCK_BOOTTIME);
nowm = now(cid); ts->monotonic = map_clock_usec_internal(u, nowm, now(CLOCK_MONOTONIC));
if (cid == CLOCK_MONOTONIC)
ts->monotonic = u;
else
ts->monotonic = map_clock_usec_internal(u, nowm, now(CLOCK_MONOTONIC));
ts->realtime = map_clock_usec_internal(u, nowm, now(CLOCK_REALTIME)); ts->realtime = map_clock_usec_internal(u, nowm, now(CLOCK_REALTIME));
return ts; return ts;
} }
@ -1461,33 +1452,6 @@ int verify_timezone(const char *name, int log_level) {
return 0; return 0;
} }
bool clock_boottime_supported(void) {
static int supported = -1;
/* Note that this checks whether CLOCK_BOOTTIME is available in general as well as available for timerfds()! */
if (supported < 0) {
int fd;
fd = timerfd_create(CLOCK_BOOTTIME, TFD_NONBLOCK|TFD_CLOEXEC);
if (fd < 0)
supported = false;
else {
safe_close(fd);
supported = true;
}
}
return supported;
}
clockid_t clock_boottime_or_monotonic(void) {
if (clock_boottime_supported())
return CLOCK_BOOTTIME;
else
return CLOCK_MONOTONIC;
}
bool clock_supported(clockid_t clock) { bool clock_supported(clockid_t clock) {
struct timespec ts; struct timespec ts;
@ -1495,16 +1459,10 @@ bool clock_supported(clockid_t clock) {
case CLOCK_MONOTONIC: case CLOCK_MONOTONIC:
case CLOCK_REALTIME: case CLOCK_REALTIME:
case CLOCK_BOOTTIME:
/* These three are always available in our baseline, and work in timerfd, as of kernel 3.15 */
return true; return true;
case CLOCK_BOOTTIME:
return clock_boottime_supported();
case CLOCK_BOOTTIME_ALARM:
if (!clock_boottime_supported())
return false;
_fallthrough_;
default: default:
/* For everything else, check properly */ /* For everything else, check properly */
return clock_gettime(clock, &ts) >= 0; return clock_gettime(clock, &ts) >= 0;

View File

@ -82,7 +82,7 @@ usec_t map_clock_usec(usec_t from, clockid_t from_clock, clockid_t to_clock);
dual_timestamp* dual_timestamp_get(dual_timestamp *ts); dual_timestamp* dual_timestamp_get(dual_timestamp *ts);
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u); dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u);
dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u); dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u);
dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, usec_t u); dual_timestamp* dual_timestamp_from_boottime(dual_timestamp *ts, usec_t u);
triple_timestamp* triple_timestamp_get(triple_timestamp *ts); triple_timestamp* triple_timestamp_get(triple_timestamp *ts);
triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u); triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u);
@ -155,9 +155,7 @@ static inline bool timezone_is_valid(const char *name, int log_level) {
return verify_timezone(name, log_level) >= 0; return verify_timezone(name, log_level) >= 0;
} }
bool clock_boottime_supported(void);
bool clock_supported(clockid_t clock); bool clock_supported(clockid_t clock);
clockid_t clock_boottime_or_monotonic(void);
usec_t usec_shift_clock(usec_t, clockid_t from, clockid_t to); usec_t usec_shift_clock(usec_t, clockid_t from, clockid_t to);

View File

@ -64,7 +64,7 @@ struct Timer {
char *stamp_path; char *stamp_path;
}; };
#define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system && clock_boottime_supported() ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC) #define TIMER_MONOTONIC_CLOCK(t) ((t)->wake_system ? CLOCK_BOOTTIME_ALARM : CLOCK_MONOTONIC)
void timer_free_values(Timer *t); void timer_free_values(Timer *t);

View File

@ -148,7 +148,7 @@ static int curl_glue_timer_callback(CURLM *curl, long timeout_ms, void *userdata
if (sd_event_source_set_enabled(g->timer, SD_EVENT_ONESHOT) < 0) if (sd_event_source_set_enabled(g->timer, SD_EVENT_ONESHOT) < 0)
return -1; return -1;
} else { } else {
if (sd_event_add_time_relative(g->event, &g->timer, clock_boottime_or_monotonic(), usec, 0, curl_glue_on_timer, g) < 0) if (sd_event_add_time_relative(g->event, &g->timer, CLOCK_BOOTTIME, usec, 0, curl_glue_on_timer, g) < 0)
return -1; return -1;
(void) sd_event_source_set_description(g->timer, "curl-timer"); (void) sd_event_source_set_description(g->timer, "curl-timer");

View File

@ -333,9 +333,9 @@ void lldp_neighbor_start_ttl(sd_lldp_neighbor *n) {
usec_t base; usec_t base;
/* Use the packet's timestamp if there is one known */ /* Use the packet's timestamp if there is one known */
base = triple_timestamp_by_clock(&n->timestamp, clock_boottime_or_monotonic()); base = triple_timestamp_by_clock(&n->timestamp, CLOCK_BOOTTIME);
if (!timestamp_is_set(base)) if (!timestamp_is_set(base))
base = now(clock_boottime_or_monotonic()); /* Otherwise, take the current time */ base = now(CLOCK_BOOTTIME); /* Otherwise, take the current time */
n->until = usec_add(base, n->ttl * USEC_PER_SEC); n->until = usec_add(base, n->ttl * USEC_PER_SEC);
} else } else

View File

@ -821,7 +821,7 @@ static int client_message_init(
/* Although 'secs' field is a SHOULD in RFC 2131, certain DHCP servers /* Although 'secs' field is a SHOULD in RFC 2131, certain DHCP servers
refuse to issue an DHCP lease if 'secs' is set to zero */ refuse to issue an DHCP lease if 'secs' is set to zero */
r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
return r; return r;
assert(time_now >= client->start_time); assert(time_now >= client->start_time);
@ -1246,7 +1246,7 @@ static int client_timeout_resend(
assert(client); assert(client);
assert(client->event); assert(client->event);
r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
goto error; goto error;
@ -1294,7 +1294,7 @@ static int client_timeout_resend(
} }
r = event_reset_time(client->event, &client->timeout_resend, r = event_reset_time(client->event, &client->timeout_resend,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
next_timeout, 10 * USEC_PER_MSEC, next_timeout, 10 * USEC_PER_MSEC,
client_timeout_resend, client, client_timeout_resend, client,
client->event_priority, "dhcp4-resend-timer", true); client->event_priority, "dhcp4-resend-timer", true);
@ -1394,12 +1394,12 @@ static int client_initialize_time_events(sd_dhcp_client *client) {
assert(client->event); assert(client->event);
if (client->start_delay > 0) { if (client->start_delay > 0) {
assert_se(sd_event_now(client->event, clock_boottime_or_monotonic(), &usec) >= 0); assert_se(sd_event_now(client->event, CLOCK_BOOTTIME, &usec) >= 0);
usec += client->start_delay; usec += client->start_delay;
} }
r = event_reset_time(client->event, &client->timeout_resend, r = event_reset_time(client->event, &client->timeout_resend,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
usec, 0, usec, 0,
client_timeout_resend, client, client_timeout_resend, client,
client->event_priority, "dhcp4-resend-timer", true); client->event_priority, "dhcp4-resend-timer", true);
@ -1440,7 +1440,7 @@ static int client_start_delayed(sd_dhcp_client *client) {
client->fd = r; client->fd = r;
if (IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_INIT_REBOOT)) if (IN_SET(client->state, DHCP_STATE_INIT, DHCP_STATE_INIT_REBOOT))
client->start_time = now(clock_boottime_or_monotonic()); client->start_time = now(CLOCK_BOOTTIME);
return client_initialize_events(client, client_receive_message_raw); return client_initialize_events(client, client_receive_message_raw);
} }
@ -1684,7 +1684,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
return 0; return 0;
} }
r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
return r; return r;
assert(client->request_sent <= time_now); assert(client->request_sent <= time_now);
@ -1717,7 +1717,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
/* arm lifetime timeout */ /* arm lifetime timeout */
r = event_reset_time(client->event, &client->timeout_expire, r = event_reset_time(client->event, &client->timeout_expire,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
client->expire_time, 10 * USEC_PER_MSEC, client->expire_time, 10 * USEC_PER_MSEC,
client_timeout_expire, client, client_timeout_expire, client,
client->event_priority, "dhcp4-lifetime", true); client->event_priority, "dhcp4-lifetime", true);
@ -1733,7 +1733,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
/* arm T2 timeout */ /* arm T2 timeout */
r = event_reset_time(client->event, &client->timeout_t2, r = event_reset_time(client->event, &client->timeout_t2,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
client->t2_time, 10 * USEC_PER_MSEC, client->t2_time, 10 * USEC_PER_MSEC,
client_timeout_t2, client, client_timeout_t2, client,
client->event_priority, "dhcp4-t2-timeout", true); client->event_priority, "dhcp4-t2-timeout", true);
@ -1749,7 +1749,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
/* arm T1 timeout */ /* arm T1 timeout */
r = event_reset_time(client->event, &client->timeout_t1, r = event_reset_time(client->event, &client->timeout_t1,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
client->t1_time, 10 * USEC_PER_MSEC, client->t1_time, 10 * USEC_PER_MSEC,
client_timeout_t1, client, client_timeout_t1, client,
client->event_priority, "dhcp4-t1-timer", true); client->event_priority, "dhcp4-t1-timer", true);
@ -1784,7 +1784,7 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, i
client->attempt = 0; client->attempt = 0;
r = event_reset_time(client->event, &client->timeout_resend, r = event_reset_time(client->event, &client->timeout_resend,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
0, 0, 0, 0,
client_timeout_resend, client, client_timeout_resend, client,
client->event_priority, "dhcp4-resend-timer", true); client->event_priority, "dhcp4-resend-timer", true);

View File

@ -987,7 +987,7 @@ static int server_ack_request(sd_dhcp_server *server, DHCPRequest *req, DHCPLeas
assert(req); assert(req);
assert(address != 0); assert(address != 0);
r = sd_event_now(server->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(server->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
return r; return r;
@ -1039,7 +1039,7 @@ static int dhcp_server_cleanup_expired_leases(sd_dhcp_server *server) {
assert(server); assert(server);
r = sd_event_now(server->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(server->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -649,7 +649,7 @@ int dhcp6_client_send_message(sd_dhcp6_client *client) {
assert(client); assert(client);
assert(client->event); assert(client->event);
r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
return r; return r;
@ -830,7 +830,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, void *userda
FORMAT_TIMESPAN(client->retransmit_time, USEC_PER_SEC)); FORMAT_TIMESPAN(client->retransmit_time, USEC_PER_SEC));
r = event_reset_time_relative(client->event, &client->timeout_resend, r = event_reset_time_relative(client->event, &client->timeout_resend,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
client->retransmit_time, 10 * USEC_PER_MSEC, client->retransmit_time, 10 * USEC_PER_MSEC,
client_timeout_resend, client, client_timeout_resend, client,
client->event_priority, "dhcp6-resend-timer", true); client->event_priority, "dhcp6-resend-timer", true);
@ -872,12 +872,12 @@ static int client_start_transaction(sd_dhcp6_client *client, DHCP6State state) {
client->retransmit_count = 0; client->retransmit_count = 0;
client->transaction_id = random_u32() & htobe32(0x00ffffff); client->transaction_id = random_u32() & htobe32(0x00ffffff);
r = sd_event_now(client->event, clock_boottime_or_monotonic(), &client->transaction_start); r = sd_event_now(client->event, CLOCK_BOOTTIME, &client->transaction_start);
if (r < 0) if (r < 0)
goto error; goto error;
r = event_reset_time(client->event, &client->timeout_resend, r = event_reset_time(client->event, &client->timeout_resend,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
0, 0, 0, 0,
client_timeout_resend, client, client_timeout_resend, client,
client->event_priority, "dhcp6-resend-timeout", true); client->event_priority, "dhcp6-resend-timeout", true);
@ -969,7 +969,7 @@ static int client_enter_bound_state(sd_dhcp6_client *client) {
} else { } else {
log_dhcp6_client(client, "T1 expires in %s", FORMAT_TIMESPAN(lifetime_t1, USEC_PER_SEC)); log_dhcp6_client(client, "T1 expires in %s", FORMAT_TIMESPAN(lifetime_t1, USEC_PER_SEC));
r = event_reset_time_relative(client->event, &client->timeout_t1, r = event_reset_time_relative(client->event, &client->timeout_t1,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
lifetime_t1, 10 * USEC_PER_SEC, lifetime_t1, 10 * USEC_PER_SEC,
client_timeout_t1, client, client_timeout_t1, client,
client->event_priority, "dhcp6-t1-timeout", true); client->event_priority, "dhcp6-t1-timeout", true);
@ -983,7 +983,7 @@ static int client_enter_bound_state(sd_dhcp6_client *client) {
} else { } else {
log_dhcp6_client(client, "T2 expires in %s", FORMAT_TIMESPAN(lifetime_t2, USEC_PER_SEC)); log_dhcp6_client(client, "T2 expires in %s", FORMAT_TIMESPAN(lifetime_t2, USEC_PER_SEC));
r = event_reset_time_relative(client->event, &client->timeout_t2, r = event_reset_time_relative(client->event, &client->timeout_t2,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
lifetime_t2, 10 * USEC_PER_SEC, lifetime_t2, 10 * USEC_PER_SEC,
client_timeout_t2, client, client_timeout_t2, client,
client->event_priority, "dhcp6-t2-timeout", true); client->event_priority, "dhcp6-t2-timeout", true);
@ -998,7 +998,7 @@ static int client_enter_bound_state(sd_dhcp6_client *client) {
log_dhcp6_client(client, "Valid lifetime expires in %s", FORMAT_TIMESPAN(lifetime_valid, USEC_PER_SEC)); log_dhcp6_client(client, "Valid lifetime expires in %s", FORMAT_TIMESPAN(lifetime_valid, USEC_PER_SEC));
r = event_reset_time_relative(client->event, &client->timeout_expire, r = event_reset_time_relative(client->event, &client->timeout_expire,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
lifetime_valid, USEC_PER_SEC, lifetime_valid, USEC_PER_SEC,
client_timeout_expire, client, client_timeout_expire, client,
client->event_priority, "dhcp6-lease-expire", true); client->event_priority, "dhcp6-lease-expire", true);

View File

@ -200,10 +200,10 @@ static int ipv4acd_set_next_wakeup(sd_ipv4acd *acd, usec_t usec, usec_t random_u
if (random_usec > 0) if (random_usec > 0)
next_timeout += (usec_t) random_u64() % random_usec; next_timeout += (usec_t) random_u64() % random_usec;
assert_se(sd_event_now(acd->event, clock_boottime_or_monotonic(), &time_now) >= 0); assert_se(sd_event_now(acd->event, CLOCK_BOOTTIME, &time_now) >= 0);
return event_reset_time(acd->event, &acd->timer_event_source, return event_reset_time(acd->event, &acd->timer_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
time_now + next_timeout, 0, time_now + next_timeout, 0,
ipv4acd_on_timeout, acd, ipv4acd_on_timeout, acd,
acd->event_priority, "ipv4acd-timer", true); acd->event_priority, "ipv4acd-timer", true);
@ -381,7 +381,7 @@ static int ipv4acd_on_packet(
if (ipv4acd_arp_conflict(acd, &packet, true)) { if (ipv4acd_arp_conflict(acd, &packet, true)) {
usec_t ts; usec_t ts;
assert_se(sd_event_now(acd->event, clock_boottime_or_monotonic(), &ts) >= 0); assert_se(sd_event_now(acd->event, CLOCK_BOOTTIME, &ts) >= 0);
/* Defend address */ /* Defend address */
if (ts > acd->defend_window) { if (ts > acd->defend_window) {

View File

@ -69,7 +69,7 @@ static int lldp_rx_make_space(sd_lldp_rx *lldp_rx, size_t extra) {
goto remove_one; goto remove_one;
if (t == USEC_INFINITY) if (t == USEC_INFINITY)
t = now(clock_boottime_or_monotonic()); t = now(CLOCK_BOOTTIME);
if (n->until > t) if (n->until > t)
break; break;
@ -448,7 +448,7 @@ static int lldp_rx_start_timer(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *neighbor)
return event_source_disable(lldp_rx->timer_event_source); return event_source_disable(lldp_rx->timer_event_source);
return event_reset_time(lldp_rx->event, &lldp_rx->timer_event_source, return event_reset_time(lldp_rx->event, &lldp_rx->timer_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
n->until, 0, n->until, 0,
on_timer_event, lldp_rx, on_timer_event, lldp_rx,
lldp_rx->event_priority, "lldp-rx-timer", true); lldp_rx->event_priority, "lldp-rx-timer", true);

View File

@ -609,7 +609,7 @@ int sd_lldp_tx_start(sd_lldp_tx *lldp_tx) {
delay = lldp_tx_get_delay(lldp_tx); delay = lldp_tx_get_delay(lldp_tx);
r = sd_event_add_time_relative(lldp_tx->event, &lldp_tx->timer_event_source, r = sd_event_add_time_relative(lldp_tx->event, &lldp_tx->timer_event_source,
clock_boottime_or_monotonic(), delay, 0, CLOCK_BOOTTIME, delay, 0,
on_timer_event, lldp_tx); on_timer_event, lldp_tx);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -269,7 +269,7 @@ static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
assert(nd); assert(nd);
assert(nd->event); assert(nd->event);
assert_se(sd_event_now(nd->event, clock_boottime_or_monotonic(), &time_now) >= 0); assert_se(sd_event_now(nd->event, CLOCK_BOOTTIME, &time_now) >= 0);
if (!nd->retransmit_time) if (!nd->retransmit_time)
nd->retransmit_time = ndisc_timeout_compute_random(NDISC_ROUTER_SOLICITATION_INTERVAL); nd->retransmit_time = ndisc_timeout_compute_random(NDISC_ROUTER_SOLICITATION_INTERVAL);
@ -281,7 +281,7 @@ static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
} }
r = event_reset_time(nd->event, &nd->timeout_event_source, r = event_reset_time(nd->event, &nd->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
time_now + nd->retransmit_time, 10 * USEC_PER_MSEC, time_now + nd->retransmit_time, 10 * USEC_PER_MSEC,
ndisc_timeout, nd, ndisc_timeout, nd,
nd->event_priority, "ndisc-timeout-no-ra", true); nd->event_priority, "ndisc-timeout-no-ra", true);
@ -344,7 +344,7 @@ int sd_ndisc_start(sd_ndisc *nd) {
assert(!nd->recv_event_source); assert(!nd->recv_event_source);
r = sd_event_now(nd->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(nd->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -363,7 +363,7 @@ int sd_ndisc_start(sd_ndisc *nd) {
(void) sd_event_source_set_description(nd->recv_event_source, "ndisc-receive-message"); (void) sd_event_source_set_description(nd->recv_event_source, "ndisc-receive-message");
r = event_reset_time(nd->event, &nd->timeout_event_source, r = event_reset_time(nd->event, &nd->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
time_now + USEC_PER_SEC / 2, 1 * USEC_PER_SEC, /* See RFC 8415 sec. 18.2.1 */ time_now + USEC_PER_SEC / 2, 1 * USEC_PER_SEC, /* See RFC 8415 sec. 18.2.1 */
ndisc_timeout, nd, ndisc_timeout, nd,
nd->event_priority, "ndisc-timeout", true); nd->event_priority, "ndisc-timeout", true);
@ -371,7 +371,7 @@ int sd_ndisc_start(sd_ndisc *nd) {
goto fail; goto fail;
r = event_reset_time(nd->event, &nd->timeout_no_ra, r = event_reset_time(nd->event, &nd->timeout_no_ra,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
time_now + NDISC_TIMEOUT_NO_RA_USEC, 10 * USEC_PER_MSEC, time_now + NDISC_TIMEOUT_NO_RA_USEC, 10 * USEC_PER_MSEC,
ndisc_timeout_no_ra, nd, ndisc_timeout_no_ra, nd,
nd->event_priority, "ndisc-timeout-no-ra", true); nd->event_priority, "ndisc-timeout-no-ra", true);

View File

@ -181,7 +181,7 @@ static int radv_send(sd_radv *ra, const struct in6_addr *dst, usec_t lifetime_us
assert(ra); assert(ra);
assert(router_lifetime_is_valid(lifetime_usec)); assert(router_lifetime_is_valid(lifetime_usec));
r = sd_event_now(ra->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(ra->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
return r; return r;
@ -321,7 +321,7 @@ static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
assert(ra->event); assert(ra->event);
assert(router_lifetime_is_valid(ra->lifetime_usec)); assert(router_lifetime_is_valid(ra->lifetime_usec));
r = sd_event_now(ra->event, clock_boottime_or_monotonic(), &time_now); r = sd_event_now(ra->event, CLOCK_BOOTTIME, &time_now);
if (r < 0) if (r < 0)
goto fail; goto fail;
@ -357,7 +357,7 @@ static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
log_radv(ra, "Next Router Advertisement in %s", FORMAT_TIMESPAN(timeout, USEC_PER_SEC)); log_radv(ra, "Next Router Advertisement in %s", FORMAT_TIMESPAN(timeout, USEC_PER_SEC));
r = event_reset_time(ra->event, &ra->timeout_event_source, r = event_reset_time(ra->event, &ra->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
usec_add(time_now, timeout), MSEC_PER_SEC, usec_add(time_now, timeout), MSEC_PER_SEC,
radv_timeout, ra, radv_timeout, ra,
ra->event_priority, "radv-timeout", true); ra->event_priority, "radv-timeout", true);
@ -409,7 +409,7 @@ int sd_radv_start(sd_radv *ra) {
return 0; return 0;
r = event_reset_time(ra->event, &ra->timeout_event_source, r = event_reset_time(ra->event, &ra->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
0, 0, 0, 0,
radv_timeout, ra, radv_timeout, ra,
ra->event_priority, "radv-timeout", true); ra->event_priority, "radv-timeout", true);

View File

@ -507,7 +507,7 @@ static void test_addr_acq(sd_event *e) {
callback_recv = test_addr_acq_recv_discover; callback_recv = test_addr_acq_recv_discover;
assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(), assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
2 * USEC_PER_SEC, 0, 2 * USEC_PER_SEC, 0,
NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0); NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);

View File

@ -965,7 +965,7 @@ TEST(dhcp6_client) {
_cleanup_(sd_event_unrefp) sd_event *e = NULL; _cleanup_(sd_event_unrefp) sd_event *e = NULL;
assert_se(sd_event_new(&e) >= 0); assert_se(sd_event_new(&e) >= 0);
assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(), assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
2 * USEC_PER_SEC, 0, 2 * USEC_PER_SEC, 0,
NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0); NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);

View File

@ -327,7 +327,7 @@ TEST(ra) {
assert_se(sd_event_add_io(e, &recv_router_advertisement, test_fd[0], assert_se(sd_event_add_io(e, &recv_router_advertisement, test_fd[0],
EPOLLIN, radv_recv, ra) >= 0); EPOLLIN, radv_recv, ra) >= 0);
assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(), assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
2 * USEC_PER_SEC, 0, 2 * USEC_PER_SEC, 0,
NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0); NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);

View File

@ -274,7 +274,7 @@ TEST(rs) {
assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0); assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
assert_se(sd_ndisc_set_callback(nd, test_callback, e) >= 0); assert_se(sd_ndisc_set_callback(nd, test_callback, e) >= 0);
assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(), assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
30 * USEC_PER_SEC, 0, 30 * USEC_PER_SEC, 0,
NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0); NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);
@ -362,7 +362,7 @@ TEST(timeout) {
assert_se(sd_ndisc_set_ifindex(nd, 42) >= 0); assert_se(sd_ndisc_set_ifindex(nd, 42) >= 0);
assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0); assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
assert_se(sd_event_add_time_relative(e, NULL, clock_boottime_or_monotonic(), assert_se(sd_event_add_time_relative(e, NULL, CLOCK_BOOTTIME,
30 * USEC_PER_SEC, 0, 30 * USEC_PER_SEC, 0,
NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0); NULL, INT_TO_PTR(-ETIMEDOUT)) >= 0);

View File

@ -4313,12 +4313,6 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
if (!TRIPLE_TIMESTAMP_HAS_CLOCK(clock)) if (!TRIPLE_TIMESTAMP_HAS_CLOCK(clock))
return -EOPNOTSUPP; return -EOPNOTSUPP;
/* Generate a clean error in case CLOCK_BOOTTIME is not available. Note that don't use clock_supported() here,
* for a reason: there are systems where CLOCK_BOOTTIME is supported, but CLOCK_BOOTTIME_ALARM is not, but for
* the purpose of getting the time this doesn't matter. */
if (IN_SET(clock, CLOCK_BOOTTIME, CLOCK_BOOTTIME_ALARM) && !clock_boottime_supported())
return -EOPNOTSUPP;
if (!triple_timestamp_is_set(&e->timestamp)) { if (!triple_timestamp_is_set(&e->timestamp)) {
/* Implicitly fall back to now() if we never ran before and thus have no cached time. */ /* Implicitly fall back to now() if we never ran before and thus have no cached time. */
*usec = now(clock); *usec = now(clock);

View File

@ -315,10 +315,8 @@ TEST(sd_event_now) {
assert_se(sd_event_now(e, CLOCK_MONOTONIC, &event_now) > 0); assert_se(sd_event_now(e, CLOCK_MONOTONIC, &event_now) > 0);
assert_se(sd_event_now(e, CLOCK_REALTIME, &event_now) > 0); assert_se(sd_event_now(e, CLOCK_REALTIME, &event_now) > 0);
assert_se(sd_event_now(e, CLOCK_REALTIME_ALARM, &event_now) > 0); assert_se(sd_event_now(e, CLOCK_REALTIME_ALARM, &event_now) > 0);
if (clock_boottime_supported()) { assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) > 0);
assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) > 0); assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) > 0);
assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) > 0);
}
assert_se(sd_event_now(e, -1, &event_now) == -EOPNOTSUPP); assert_se(sd_event_now(e, -1, &event_now) == -EOPNOTSUPP);
assert_se(sd_event_now(e, 900 /* arbitrary big number */, &event_now) == -EOPNOTSUPP); assert_se(sd_event_now(e, 900 /* arbitrary big number */, &event_now) == -EOPNOTSUPP);
@ -327,10 +325,8 @@ TEST(sd_event_now) {
assert_se(sd_event_now(e, CLOCK_MONOTONIC, &event_now) == 0); assert_se(sd_event_now(e, CLOCK_MONOTONIC, &event_now) == 0);
assert_se(sd_event_now(e, CLOCK_REALTIME, &event_now) == 0); assert_se(sd_event_now(e, CLOCK_REALTIME, &event_now) == 0);
assert_se(sd_event_now(e, CLOCK_REALTIME_ALARM, &event_now) == 0); assert_se(sd_event_now(e, CLOCK_REALTIME_ALARM, &event_now) == 0);
if (clock_boottime_supported()) { assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) == 0);
assert_se(sd_event_now(e, CLOCK_BOOTTIME, &event_now) == 0); assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) == 0);
assert_se(sd_event_now(e, CLOCK_BOOTTIME_ALARM, &event_now) == 0);
}
assert_se(sd_event_now(e, -1, &event_now) == -EOPNOTSUPP); assert_se(sd_event_now(e, -1, &event_now) == -EOPNOTSUPP);
assert_se(sd_event_now(e, 900 /* arbitrary big number */, &event_now) == -EOPNOTSUPP); assert_se(sd_event_now(e, 900 /* arbitrary big number */, &event_now) == -EOPNOTSUPP);
} }

View File

@ -127,7 +127,7 @@ static int manager_add_host_machine(Manager *m) {
t->root_directory = TAKE_PTR(rd); t->root_directory = TAKE_PTR(rd);
t->unit = TAKE_PTR(unit); t->unit = TAKE_PTR(unit);
dual_timestamp_from_boottime_or_monotonic(&t->timestamp, 0); dual_timestamp_from_boottime(&t->timestamp, 0);
m->host_machine = t; m->host_machine = t;

View File

@ -375,7 +375,7 @@ static int wireguard_peer_resolve_handler(
if (peer->n_retries > 0) { if (peer->n_retries > 0) {
r = event_reset_time_relative(netdev->manager->event, r = event_reset_time_relative(netdev->manager->event,
&peer->resolve_retry_event_source, &peer->resolve_retry_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
peer_next_resolve_usec(peer), 0, peer_next_resolve_usec(peer), 0,
on_resolve_retry, peer, 0, "wireguard-resolve-retry", true); on_resolve_retry, peer, 0, "wireguard-resolve-retry", true);
if (r < 0) if (r < 0)

View File

@ -218,7 +218,7 @@ static struct ifa_cacheinfo *address_set_cinfo(const Address *a, struct ifa_cach
assert(a); assert(a);
assert(cinfo); assert(cinfo);
now_usec = now(clock_boottime_or_monotonic()); now_usec = now(CLOCK_BOOTTIME);
*cinfo = (struct ifa_cacheinfo) { *cinfo = (struct ifa_cacheinfo) {
.ifa_valid = MIN(usec_sub_unsigned(a->lifetime_valid_usec, now_usec) / USEC_PER_SEC, UINT32_MAX), .ifa_valid = MIN(usec_sub_unsigned(a->lifetime_valid_usec, now_usec) / USEC_PER_SEC, UINT32_MAX),
@ -234,7 +234,7 @@ static void address_set_lifetime(Address *a, const struct ifa_cacheinfo *cinfo)
assert(a); assert(a);
assert(cinfo); assert(cinfo);
now_usec = now(clock_boottime_or_monotonic()); now_usec = now(CLOCK_BOOTTIME);
if (cinfo->ifa_valid == UINT32_MAX) if (cinfo->ifa_valid == UINT32_MAX)
a->lifetime_valid_usec = USEC_INFINITY; a->lifetime_valid_usec = USEC_INFINITY;
@ -643,7 +643,7 @@ const char* format_lifetime(char *buf, size_t l, usec_t lifetime_usec) {
sprintf(buf, "for "); sprintf(buf, "for ");
/* format_timespan() never fails */ /* format_timespan() never fails */
assert_se(format_timespan(buf + 4, l - 4, usec_sub_unsigned(lifetime_usec, now(clock_boottime_or_monotonic())), USEC_PER_SEC)); assert_se(format_timespan(buf + 4, l - 4, usec_sub_unsigned(lifetime_usec, now(CLOCK_BOOTTIME)), USEC_PER_SEC));
return buf; return buf;
} }

View File

@ -886,7 +886,7 @@ static int dhcp4_pd_assign_subnet_prefix(Link *link, Link *uplink) {
if (r < 0) if (r < 0)
return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m"); return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m");
lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(clock_boottime_or_monotonic())); lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME));
r = sd_dhcp_lease_get_6rd(uplink->dhcp_lease, &ipv4masklen, &sixrd_prefixlen, &sixrd_prefix, &br_addresses, NULL); r = sd_dhcp_lease_get_6rd(uplink->dhcp_lease, &ipv4masklen, &sixrd_prefixlen, &sixrd_prefix, &br_addresses, NULL);
if (r < 0) if (r < 0)
@ -958,7 +958,7 @@ int dhcp4_pd_prefix_acquired(Link *uplink) {
if (r < 0) if (r < 0)
return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m"); return log_link_warning_errno(uplink, r, "Failed to get lifetime of DHCPv4 lease: %m");
lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(clock_boottime_or_monotonic())); lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME));
r = sd_dhcp_lease_get_server_identifier(uplink->dhcp_lease, &server_address.in); r = sd_dhcp_lease_get_server_identifier(uplink->dhcp_lease, &server_address.in);
if (r < 0) if (r < 0)
@ -1045,7 +1045,7 @@ static int dhcp6_pd_assign_subnet_prefixes(Link *link, Link *uplink) {
if (r <= 0) if (r <= 0)
return r; return r;
r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return r; return r;
@ -1094,7 +1094,7 @@ int dhcp6_pd_prefix_acquired(Link *uplink) {
if (r < 0) if (r < 0)
return log_link_warning_errno(uplink, r, "Failed to get server address of DHCPv6 lease: %m"); return log_link_warning_errno(uplink, r, "Failed to get server address of DHCPv6 lease: %m");
r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_dhcp6_lease_get_timestamp(uplink->dhcp6_lease, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_warning_errno(uplink, r, "Failed to get timestamp of DHCPv6 lease: %m"); return log_link_warning_errno(uplink, r, "Failed to get timestamp of DHCPv6 lease: %m");

View File

@ -871,7 +871,7 @@ static int dhcp4_request_address(Link *link, bool announce) {
if (r < 0) if (r < 0)
return log_link_warning_errno(link, r, "DHCP error: no lifetime: %m"); return log_link_warning_errno(link, r, "DHCP error: no lifetime: %m");
lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(clock_boottime_or_monotonic())); lifetime_usec = usec_add(lifetime_sec * USEC_PER_SEC, now(CLOCK_BOOTTIME));
} else } else
lifetime_usec = USEC_INFINITY; lifetime_usec = USEC_INFINITY;

View File

@ -258,7 +258,7 @@ static int dhcp6_address_acquired(Link *link) {
if (r < 0) if (r < 0)
return log_link_warning_errno(link, r, "Failed to get server address of DHCPv6 lease: %m"); return log_link_warning_errno(link, r, "Failed to get server address of DHCPv6 lease: %m");
r = sd_dhcp6_lease_get_timestamp(link->dhcp6_lease, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_dhcp6_lease_get_timestamp(link->dhcp6_lease, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_warning_errno(link, r, "Failed to get timestamp of DHCPv6 lease: %m"); return log_link_warning_errno(link, r, "Failed to get timestamp of DHCPv6 lease: %m");

View File

@ -1659,7 +1659,7 @@ static int link_carrier_lost(Link *link) {
return event_reset_time_relative(link->manager->event, return event_reset_time_relative(link->manager->event,
&link->carrier_lost_timer, &link->carrier_lost_timer,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
link->network->ignore_carrier_loss_usec, link->network->ignore_carrier_loss_usec,
0, 0,
link_carrier_lost_handler, link_carrier_lost_handler,

View File

@ -316,7 +316,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
if (lifetime_sec == 0) /* not a default router */ if (lifetime_sec == 0) /* not a default router */
return 0; return 0;
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
@ -410,7 +410,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
if (!link->network->ipv6_accept_ra_use_autonomous_prefix) if (!link->network->ipv6_accept_ra_use_autonomous_prefix)
return 0; return 0;
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
@ -510,7 +510,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
if (lifetime_sec == 0) if (lifetime_sec == 0)
return 0; return 0;
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
@ -652,7 +652,7 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get default router preference from RA: %m"); return log_link_error_errno(link, r, "Failed to get default router preference from RA: %m");
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
@ -709,7 +709,7 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get router address from RA: %m"); return log_link_error_errno(link, r, "Failed to get router address from RA: %m");
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
@ -803,7 +803,7 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get router address from RA: %m"); return log_link_error_errno(link, r, "Failed to get router address from RA: %m");
r = sd_ndisc_router_get_timestamp(rt, clock_boottime_or_monotonic(), &timestamp_usec); r = sd_ndisc_router_get_timestamp(rt, CLOCK_BOOTTIME, &timestamp_usec);
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
@ -1168,7 +1168,7 @@ void ndisc_vacuum(Link *link) {
/* Removes all RDNSS and DNSSL entries whose validity time has passed */ /* Removes all RDNSS and DNSSL entries whose validity time has passed */
time_now = now(clock_boottime_or_monotonic()); time_now = now(CLOCK_BOOTTIME);
SET_FOREACH(r, link->ndisc_rdnss) SET_FOREACH(r, link->ndisc_rdnss)
if (r->lifetime_usec < time_now) if (r->lifetime_usec < time_now)

View File

@ -1041,7 +1041,7 @@ static int route_setup_timer(Route *route, const struct rta_cacheinfo *cacheinfo
/* Assume that non-zero rta_expires means kernel will handle the route expiration. */ /* Assume that non-zero rta_expires means kernel will handle the route expiration. */
return 0; return 0;
r = event_reset_time(manager->event, &route->expire, clock_boottime_or_monotonic(), r = event_reset_time(manager->event, &route->expire, CLOCK_BOOTTIME,
route->lifetime_usec, 0, route_expire_handler, route, 0, "route-expiration", true); route->lifetime_usec, 0, route_expire_handler, route, 0, "route-expiration", true);
if (r < 0) if (r < 0)
return r; return r;
@ -1179,7 +1179,7 @@ static int route_configure(const Route *route, Link *link, Request *req) {
if (route->lifetime_usec != USEC_INFINITY) { if (route->lifetime_usec != USEC_INFINITY) {
r = sd_netlink_message_append_u32(m, RTA_EXPIRES, r = sd_netlink_message_append_u32(m, RTA_EXPIRES,
MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime_usec, now(clock_boottime_or_monotonic())), USEC_PER_SEC), UINT32_MAX)); MIN(DIV_ROUND_UP(usec_sub_unsigned(route->lifetime_usec, now(CLOCK_BOOTTIME)), USEC_PER_SEC), UINT32_MAX));
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -14,7 +14,7 @@ static void test_FORMAT_LIFETIME_one(usec_t lifetime, const char *expected) {
TEST(FORMAT_LIFETIME) { TEST(FORMAT_LIFETIME) {
usec_t now_usec; usec_t now_usec;
now_usec = now(clock_boottime_or_monotonic()); now_usec = now(CLOCK_BOOTTIME);
test_FORMAT_LIFETIME_one(now_usec, "for 0"); test_FORMAT_LIFETIME_one(now_usec, "for 0");
test_FORMAT_LIFETIME_one(usec_add(now_usec, 2 * USEC_PER_SEC - 1), "for 1s"); test_FORMAT_LIFETIME_one(usec_add(now_usec, 2 * USEC_PER_SEC - 1), "for 1s");

View File

@ -380,7 +380,7 @@ int manager_new(Manager **ret,
(void) sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL); (void) sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
if (timeout > 0) { if (timeout > 0) {
r = sd_event_add_time_relative(m->event, NULL, clock_boottime_or_monotonic(), timeout, 0, NULL, INT_TO_PTR(-ETIMEDOUT)); r = sd_event_add_time_relative(m->event, NULL, CLOCK_BOOTTIME, timeout, 0, NULL, INT_TO_PTR(-ETIMEDOUT));
if (r < 0 && r != -EOVERFLOW) if (r < 0 && r != -EOVERFLOW)
return r; return r;
} }

View File

@ -214,7 +214,7 @@ void dns_cache_prune(DnsCache *c) {
break; break;
if (t <= 0) if (t <= 0)
t = now(clock_boottime_or_monotonic()); t = now(CLOCK_BOOTTIME);
if (i->until > t) if (i->until > t)
break; break;
@ -735,7 +735,7 @@ int dns_cache_put(
/* Make some space for our new entries */ /* Make some space for our new entries */
dns_cache_make_space(c, cache_keys); dns_cache_make_space(c, cache_keys);
timestamp = now(clock_boottime_or_monotonic()); timestamp = now(CLOCK_BOOTTIME);
/* Second, add in positive entries for all contained RRs */ /* Second, add in positive entries for all contained RRs */
DNS_ANSWER_FOREACH_ITEM(item, answer) { DNS_ANSWER_FOREACH_ITEM(item, answer) {
@ -1016,7 +1016,7 @@ int dns_cache_lookup(
if (FLAGS_SET(query_flags, SD_RESOLVED_CLAMP_TTL)) { if (FLAGS_SET(query_flags, SD_RESOLVED_CLAMP_TTL)) {
/* 'current' is always passed to answer_add_clamp_ttl(), but is only used conditionally. /* 'current' is always passed to answer_add_clamp_ttl(), but is only used conditionally.
* We'll do the same assert there to make sure that it was initialized properly. */ * We'll do the same assert there to make sure that it was initialized properly. */
current = now(clock_boottime_or_monotonic()); current = now(CLOCK_BOOTTIME);
assert(current > 0); assert(current > 0);
} }

View File

@ -2502,7 +2502,7 @@ int dns_packet_patch_ttls(DnsPacket *p, usec_t timestamp) {
usec_t k; usec_t k;
int r; int r;
k = now(clock_boottime_or_monotonic()); k = now(CLOCK_BOOTTIME);
assert(k >= timestamp); assert(k >= timestamp);
k -= timestamp; k -= timestamp;

View File

@ -777,7 +777,7 @@ int dns_query_go(DnsQuery *q) {
r = event_reset_time_relative( r = event_reset_time_relative(
q->manager->event, q->manager->event,
&q->timeout_event_source, &q->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
SD_RESOLVED_QUERY_TIMEOUT_USEC, SD_RESOLVED_QUERY_TIMEOUT_USEC,
0, on_query_timeout, q, 0, on_query_timeout, q,
0, "query-timeout", true); 0, "query-timeout", true);

View File

@ -1239,7 +1239,7 @@ int dns_scope_notify_conflict(DnsScope *scope, DnsResourceRecord *rr) {
r = sd_event_add_time_relative( r = sd_event_add_time_relative(
scope->manager->event, scope->manager->event,
&scope->conflict_event_source, &scope->conflict_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
jitter, jitter,
LLMNR_JITTER_INTERVAL_USEC, LLMNR_JITTER_INTERVAL_USEC,
on_conflict_dispatch, scope); on_conflict_dispatch, scope);
@ -1509,7 +1509,7 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
r = sd_event_add_time_relative( r = sd_event_add_time_relative(
scope->manager->event, scope->manager->event,
&scope->announce_event_source, &scope->announce_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
MDNS_ANNOUNCE_DELAY, MDNS_ANNOUNCE_DELAY,
MDNS_JITTER_RANGE_USEC, MDNS_JITTER_RANGE_USEC,
on_announcement_timeout, scope); on_announcement_timeout, scope);

View File

@ -230,7 +230,7 @@ static void dns_server_verified(DnsServer *s, DnsServerFeatureLevel level) {
s->verified_feature_level = level; s->verified_feature_level = level;
} }
assert_se(sd_event_now(s->manager->event, clock_boottime_or_monotonic(), &s->verified_usec) >= 0); assert_se(sd_event_now(s->manager->event, CLOCK_BOOTTIME, &s->verified_usec) >= 0);
} }
static void dns_server_reset_counters(DnsServer *s) { static void dns_server_reset_counters(DnsServer *s) {
@ -405,7 +405,7 @@ static bool dns_server_grace_period_expired(DnsServer *s) {
if (s->verified_usec == 0) if (s->verified_usec == 0)
return false; return false;
assert_se(sd_event_now(s->manager->event, clock_boottime_or_monotonic(), &ts) >= 0); assert_se(sd_event_now(s->manager->event, CLOCK_BOOTTIME, &ts) >= 0);
if (s->verified_usec + s->features_grace_period_usec > ts) if (s->verified_usec + s->features_grace_period_usec > ts)
return false; return false;

View File

@ -390,7 +390,7 @@ static int on_stream_io(sd_event_source *es, int fd, uint32_t revents, void *use
s->read_packet->family = s->peer.sa.sa_family; s->read_packet->family = s->peer.sa.sa_family;
s->read_packet->ttl = s->ttl; s->read_packet->ttl = s->ttl;
s->read_packet->ifindex = s->ifindex; s->read_packet->ifindex = s->ifindex;
s->read_packet->timestamp = now(clock_boottime_or_monotonic()); s->read_packet->timestamp = now(CLOCK_BOOTTIME);
if (s->read_packet->family == AF_INET) { if (s->read_packet->family == AF_INET) {
s->read_packet->sender.in = s->peer.in.sin_addr; s->read_packet->sender.in = s->peer.in.sin_addr;
@ -543,7 +543,7 @@ int dns_stream_new(
r = sd_event_add_time_relative( r = sd_event_add_time_relative(
m->event, m->event,
&s->timeout_event_source, &s->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
connect_timeout_usec, 0, connect_timeout_usec, 0,
on_stream_timeout, s); on_stream_timeout, s);
if (r < 0) if (r < 0)

View File

@ -1422,7 +1422,7 @@ static int on_dns_packet(sd_event_source *s, int fd, uint32_t revents, void *use
* next recvmsg(). Treat this like a lost packet. */ * next recvmsg(). Treat this like a lost packet. */
log_debug_errno(r, "Connection failure for DNS UDP packet: %m"); log_debug_errno(r, "Connection failure for DNS UDP packet: %m");
assert_se(sd_event_now(t->scope->manager->event, clock_boottime_or_monotonic(), &usec) >= 0); assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &usec) >= 0);
dns_server_packet_lost(t->server, IPPROTO_UDP, t->current_feature_level); dns_server_packet_lost(t->server, IPPROTO_UDP, t->current_feature_level);
dns_transaction_close_connection(t, /* use_graveyard = */ false); dns_transaction_close_connection(t, /* use_graveyard = */ false);
@ -1797,7 +1797,7 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
* in our current scope, and see whether their timing constraints allow them to be sent. * in our current scope, and see whether their timing constraints allow them to be sent.
*/ */
assert_se(sd_event_now(t->scope->manager->event, clock_boottime_or_monotonic(), &ts) >= 0); assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &ts) >= 0);
LIST_FOREACH(transactions_by_scope, other, t->scope->transactions) { LIST_FOREACH(transactions_by_scope, other, t->scope->transactions) {
@ -1835,7 +1835,7 @@ static int dns_transaction_make_packet_mdns(DnsTransaction *t) {
r = sd_event_add_time( r = sd_event_add_time(
other->scope->manager->event, other->scope->manager->event,
&other->timeout_event_source, &other->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
ts, 0, ts, 0,
on_transaction_timeout, other); on_transaction_timeout, other);
if (r < 0) if (r < 0)
@ -1937,7 +1937,7 @@ int dns_transaction_go(DnsTransaction *t) {
* finished now. In the latter case, the transaction and query candidate objects must not be accessed. * finished now. In the latter case, the transaction and query candidate objects must not be accessed.
*/ */
assert_se(sd_event_now(t->scope->manager->event, clock_boottime_or_monotonic(), &ts) >= 0); assert_se(sd_event_now(t->scope->manager->event, CLOCK_BOOTTIME, &ts) >= 0);
r = dns_transaction_prepare(t, ts); r = dns_transaction_prepare(t, ts);
if (r <= 0) if (r <= 0)
@ -1981,7 +1981,7 @@ int dns_transaction_go(DnsTransaction *t) {
r = sd_event_add_time_relative( r = sd_event_add_time_relative(
t->scope->manager->event, t->scope->manager->event,
&t->timeout_event_source, &t->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
jitter, accuracy, jitter, accuracy,
on_transaction_timeout, t); on_transaction_timeout, t);
if (r < 0) if (r < 0)
@ -2071,7 +2071,7 @@ int dns_transaction_go(DnsTransaction *t) {
r = sd_event_add_time( r = sd_event_add_time(
t->scope->manager->event, t->scope->manager->event,
&t->timeout_event_source, &t->timeout_event_source,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
ts, 0, ts, 0,
on_transaction_timeout, t); on_transaction_timeout, t);
if (r < 0) if (r < 0)

View File

@ -294,7 +294,7 @@ static int manager_etc_hosts_read(Manager *m) {
usec_t ts; usec_t ts;
int r; int r;
assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &ts) >= 0); assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &ts) >= 0);
/* See if we checked /etc/hosts recently already */ /* See if we checked /etc/hosts recently already */
if (m->etc_hosts_last != USEC_INFINITY && m->etc_hosts_last + ETC_HOSTS_RECHECK_USEC > ts) if (m->etc_hosts_last != USEC_INFINITY && m->etc_hosts_last + ETC_HOSTS_RECHECK_USEC > ts)

View File

@ -803,7 +803,7 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
} else } else
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
p->timestamp = now(clock_boottime_or_monotonic()); p->timestamp = now(CLOCK_BOOTTIME);
CMSG_FOREACH(cmsg, &mh) { CMSG_FOREACH(cmsg, &mh) {

View File

@ -53,7 +53,7 @@ void manager_socket_graveyard_process(Manager *m) {
SocketGraveyard *g = m->socket_graveyard_oldest; SocketGraveyard *g = m->socket_graveyard_oldest;
if (n == USEC_INFINITY) if (n == USEC_INFINITY)
assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &n) >= 0); assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &n) >= 0);
if (g->deadline > n) if (g->deadline > n)
break; break;
@ -113,7 +113,7 @@ int manager_add_socket_to_graveyard(Manager *m, int fd) {
m->n_socket_graveyard++; m->n_socket_graveyard++;
assert_se(sd_event_now(m->event, clock_boottime_or_monotonic(), &g->deadline) >= 0); assert_se(sd_event_now(m->event, CLOCK_BOOTTIME, &g->deadline) >= 0);
g->deadline += SOCKET_GRAVEYARD_USEC; g->deadline += SOCKET_GRAVEYARD_USEC;
r = sd_event_add_io(m->event, &g->io_event_source, fd, EPOLLIN, on_io_event, g); r = sd_event_add_io(m->event, &g->io_event_source, fd, EPOLLIN, on_io_event, g);

View File

@ -195,7 +195,7 @@ static int watchdog_ping_now(void) {
if (ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0) < 0) if (ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0) < 0)
return log_warning_errno(errno, "Failed to ping hardware watchdog, ignoring: %m"); return log_warning_errno(errno, "Failed to ping hardware watchdog, ignoring: %m");
watchdog_last_ping = now(clock_boottime_or_monotonic()); watchdog_last_ping = now(CLOCK_BOOTTIME);
return 0; return 0;
} }
@ -411,7 +411,7 @@ usec_t watchdog_runtime_wait(void) {
/* Sleep half the watchdog timeout since the last successful ping at most */ /* Sleep half the watchdog timeout since the last successful ping at most */
if (timestamp_is_set(watchdog_last_ping)) { if (timestamp_is_set(watchdog_last_ping)) {
usec_t ntime = now(clock_boottime_or_monotonic()); usec_t ntime = now(CLOCK_BOOTTIME);
assert(ntime >= watchdog_last_ping); assert(ntime >= watchdog_last_ping);
return usec_sub_unsigned(watchdog_last_ping + (timeout / 2), ntime); return usec_sub_unsigned(watchdog_last_ping + (timeout / 2), ntime);
@ -430,7 +430,7 @@ int watchdog_ping(void) {
/* open_watchdog() will automatically ping the device for us if necessary */ /* open_watchdog() will automatically ping the device for us if necessary */
return open_watchdog(); return open_watchdog();
ntime = now(clock_boottime_or_monotonic()); ntime = now(CLOCK_BOOTTIME);
timeout = calc_timeout(); timeout = calc_timeout();
/* Never ping earlier than watchdog_timeout/4 and try to ping /* Never ping earlier than watchdog_timeout/4 and try to ping

View File

@ -522,25 +522,25 @@ TEST(usec_shift_clock) {
rt = now(CLOCK_REALTIME); rt = now(CLOCK_REALTIME);
mn = now(CLOCK_MONOTONIC); mn = now(CLOCK_MONOTONIC);
bt = now(clock_boottime_or_monotonic()); bt = now(CLOCK_BOOTTIME);
assert_se(usec_shift_clock(USEC_INFINITY, CLOCK_REALTIME, CLOCK_MONOTONIC) == USEC_INFINITY); assert_se(usec_shift_clock(USEC_INFINITY, CLOCK_REALTIME, CLOCK_MONOTONIC) == USEC_INFINITY);
assert_similar(usec_shift_clock(rt + USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_MONOTONIC), mn + USEC_PER_HOUR); assert_similar(usec_shift_clock(rt + USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_MONOTONIC), mn + USEC_PER_HOUR);
assert_similar(usec_shift_clock(rt + 2*USEC_PER_HOUR, CLOCK_REALTIME, clock_boottime_or_monotonic()), bt + 2*USEC_PER_HOUR); assert_similar(usec_shift_clock(rt + 2*USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_BOOTTIME), bt + 2*USEC_PER_HOUR);
assert_se(usec_shift_clock(rt + 3*USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_REALTIME_ALARM) == rt + 3*USEC_PER_HOUR); assert_se(usec_shift_clock(rt + 3*USEC_PER_HOUR, CLOCK_REALTIME, CLOCK_REALTIME_ALARM) == rt + 3*USEC_PER_HOUR);
assert_similar(usec_shift_clock(mn + 4*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_REALTIME_ALARM), rt + 4*USEC_PER_HOUR); assert_similar(usec_shift_clock(mn + 4*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_REALTIME_ALARM), rt + 4*USEC_PER_HOUR);
assert_similar(usec_shift_clock(mn + 5*USEC_PER_HOUR, CLOCK_MONOTONIC, clock_boottime_or_monotonic()), bt + 5*USEC_PER_HOUR); assert_similar(usec_shift_clock(mn + 5*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_BOOTTIME), bt + 5*USEC_PER_HOUR);
assert_se(usec_shift_clock(mn + 6*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_MONOTONIC) == mn + 6*USEC_PER_HOUR); assert_se(usec_shift_clock(mn + 6*USEC_PER_HOUR, CLOCK_MONOTONIC, CLOCK_MONOTONIC) == mn + 6*USEC_PER_HOUR);
assert_similar(usec_shift_clock(bt + 7*USEC_PER_HOUR, clock_boottime_or_monotonic(), CLOCK_MONOTONIC), mn + 7*USEC_PER_HOUR); assert_similar(usec_shift_clock(bt + 7*USEC_PER_HOUR, CLOCK_BOOTTIME, CLOCK_MONOTONIC), mn + 7*USEC_PER_HOUR);
assert_similar(usec_shift_clock(bt + 8*USEC_PER_HOUR, clock_boottime_or_monotonic(), CLOCK_REALTIME_ALARM), rt + 8*USEC_PER_HOUR); assert_similar(usec_shift_clock(bt + 8*USEC_PER_HOUR, CLOCK_BOOTTIME, CLOCK_REALTIME_ALARM), rt + 8*USEC_PER_HOUR);
assert_se(usec_shift_clock(bt + 9*USEC_PER_HOUR, clock_boottime_or_monotonic(), clock_boottime_or_monotonic()) == bt + 9*USEC_PER_HOUR); assert_se(usec_shift_clock(bt + 9*USEC_PER_HOUR, CLOCK_BOOTTIME, CLOCK_BOOTTIME) == bt + 9*USEC_PER_HOUR);
if (mn > USEC_PER_MINUTE) { if (mn > USEC_PER_MINUTE) {
assert_similar(usec_shift_clock(rt - 30 * USEC_PER_SEC, CLOCK_REALTIME_ALARM, CLOCK_MONOTONIC), mn - 30 * USEC_PER_SEC); assert_similar(usec_shift_clock(rt - 30 * USEC_PER_SEC, CLOCK_REALTIME_ALARM, CLOCK_MONOTONIC), mn - 30 * USEC_PER_SEC);
assert_similar(usec_shift_clock(rt - 50 * USEC_PER_SEC, CLOCK_REALTIME, clock_boottime_or_monotonic()), bt - 50 * USEC_PER_SEC); assert_similar(usec_shift_clock(rt - 50 * USEC_PER_SEC, CLOCK_REALTIME, CLOCK_BOOTTIME), bt - 50 * USEC_PER_SEC);
} }
} }
@ -598,7 +598,7 @@ static int intro(void) {
"boottime=" USEC_FMT "\n", "boottime=" USEC_FMT "\n",
now(CLOCK_REALTIME), now(CLOCK_REALTIME),
now(CLOCK_MONOTONIC), now(CLOCK_MONOTONIC),
now(clock_boottime_or_monotonic())); now(CLOCK_BOOTTIME));
/* Ensure time_t is signed */ /* Ensure time_t is signed */
assert_cc((time_t) -1 < (time_t) 1); assert_cc((time_t) -1 < (time_t) 1);

View File

@ -130,7 +130,7 @@ static int manager_send_request(Manager *m) {
* The actual value does not matter, We do not care about the correct * The actual value does not matter, We do not care about the correct
* NTP UINT_MAX fraction; we just pass the plain nanosecond value. * NTP UINT_MAX fraction; we just pass the plain nanosecond value.
*/ */
assert_se(clock_gettime(clock_boottime_or_monotonic(), &m->trans_time_mon) >= 0); assert_se(clock_gettime(CLOCK_BOOTTIME, &m->trans_time_mon) >= 0);
assert_se(clock_gettime(CLOCK_REALTIME, &m->trans_time) >= 0); assert_se(clock_gettime(CLOCK_REALTIME, &m->trans_time) >= 0);
ntpmsg.trans_time.sec = htobe32(graceful_add_offset_1900_1970(m->trans_time.tv_sec)); ntpmsg.trans_time.sec = htobe32(graceful_add_offset_1900_1970(m->trans_time.tv_sec));
ntpmsg.trans_time.frac = htobe32(m->trans_time.tv_nsec); ntpmsg.trans_time.frac = htobe32(m->trans_time.tv_nsec);
@ -161,8 +161,8 @@ static int manager_send_request(Manager *m) {
r = sd_event_add_time( r = sd_event_add_time(
m->event, m->event,
&m->event_timeout, &m->event_timeout,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
now(clock_boottime_or_monotonic()) + TIMEOUT_USEC, 0, now(CLOCK_BOOTTIME) + TIMEOUT_USEC, 0,
manager_timeout, m); manager_timeout, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to arm timeout timer: %m"); return log_error_errno(r, "Failed to arm timeout timer: %m");
@ -200,7 +200,7 @@ static int manager_arm_timer(Manager *m, usec_t next) {
return sd_event_add_time_relative( return sd_event_add_time_relative(
m->event, m->event,
&m->event_timer, &m->event_timer,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
next, 0, next, 0,
manager_timer, m); manager_timer, m);
} }
@ -799,7 +799,7 @@ int manager_connect(Manager *m) {
if (!ratelimit_below(&m->ratelimit)) { if (!ratelimit_below(&m->ratelimit)) {
log_debug("Delaying attempts to contact servers."); log_debug("Delaying attempts to contact servers.");
r = sd_event_add_time_relative(m->event, &m->event_retry, clock_boottime_or_monotonic(), m->connection_retry_usec, r = sd_event_add_time_relative(m->event, &m->event_retry, CLOCK_BOOTTIME, m->connection_retry_usec,
0, manager_retry_connect, m); 0, manager_retry_connect, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to create retry timer: %m"); return log_error_errno(r, "Failed to create retry timer: %m");
@ -854,7 +854,7 @@ int manager_connect(Manager *m) {
if (restart && !m->exhausted_servers && m->poll_interval_usec) { if (restart && !m->exhausted_servers && m->poll_interval_usec) {
log_debug("Waiting after exhausting servers."); log_debug("Waiting after exhausting servers.");
r = sd_event_add_time_relative(m->event, &m->event_retry, clock_boottime_or_monotonic(), m->poll_interval_usec, 0, manager_retry_connect, m); r = sd_event_add_time_relative(m->event, &m->event_retry, CLOCK_BOOTTIME, m->poll_interval_usec, 0, manager_retry_connect, m);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to create retry timer: %m"); return log_error_errno(r, "Failed to create retry timer: %m");
@ -1165,7 +1165,7 @@ int manager_setup_save_time_event(Manager *m) {
/* NB: we'll accumulate scheduling latencies here, but this doesn't matter */ /* NB: we'll accumulate scheduling latencies here, but this doesn't matter */
r = sd_event_add_time_relative( r = sd_event_add_time_relative(
m->event, &m->event_save_time, m->event, &m->event_save_time,
clock_boottime_or_monotonic(), CLOCK_BOOTTIME,
m->save_time_interval_usec, m->save_time_interval_usec,
10 * USEC_PER_SEC, 10 * USEC_PER_SEC,
manager_save_time_handler, m); manager_save_time_handler, m);

View File

@ -356,7 +356,7 @@ int udev_ctrl_wait(UdevCtrl *uctrl, usec_t timeout) {
if (timeout != USEC_INFINITY) { if (timeout != USEC_INFINITY) {
r = sd_event_add_time_relative( r = sd_event_add_time_relative(
uctrl->event, &source_timeout, clock_boottime_or_monotonic(), uctrl->event, &source_timeout, CLOCK_BOOTTIME,
timeout, timeout,
0, NULL, INT_TO_PTR(-ETIMEDOUT)); 0, NULL, INT_TO_PTR(-ETIMEDOUT));
if (r < 0) if (r < 0)

View File

@ -807,7 +807,7 @@ static int event_is_blocked(Event *event) {
if (event->retry_again_next_usec > 0) { if (event->retry_again_next_usec > 0) {
usec_t now_usec; usec_t now_usec;
r = sd_event_now(event->manager->event, clock_boottime_or_monotonic(), &now_usec); r = sd_event_now(event->manager->event, CLOCK_BOOTTIME, &now_usec);
if (r < 0) if (r < 0)
return r; return r;
@ -1013,7 +1013,7 @@ static int event_requeue(Event *event) {
event->timeout_event = sd_event_source_disable_unref(event->timeout_event); event->timeout_event = sd_event_source_disable_unref(event->timeout_event);
/* add a short delay to suppress busy loop */ /* add a short delay to suppress busy loop */
r = sd_event_now(event->manager->event, clock_boottime_or_monotonic(), &now_usec); r = sd_event_now(event->manager->event, CLOCK_BOOTTIME, &now_usec);
if (r < 0) if (r < 0)
return log_device_warning_errno(event->dev, r, return log_device_warning_errno(event->dev, r,
"Failed to get current time, " "Failed to get current time, "