[systemd-commits] 3 commits - src/libsystemd src/libsystemd-network src/shared
Tom Gundersen
tomegun at kemper.freedesktop.org
Thu Jul 24 10:08:15 PDT 2014
src/libsystemd-network/sd-dhcp-client.c | 20 ++++++++--------
src/libsystemd-network/sd-dhcp-server.c | 4 +--
src/libsystemd-network/sd-dhcp6-client.c | 14 +++++------
src/libsystemd-network/sd-icmp6-nd.c | 6 ++--
src/libsystemd-network/sd-ipv4ll.c | 12 ++++-----
src/libsystemd-network/test-dhcp-client.c | 4 +--
src/libsystemd-network/test-dhcp6-client.c | 4 +--
src/libsystemd-network/test-icmp6-rs.c | 4 +--
src/libsystemd/sd-event/sd-event.c | 35 +++++++++++++++++++++++++----
src/shared/time-util.c | 19 +++++++++++++++
src/shared/time-util.h | 2 +
11 files changed, 86 insertions(+), 38 deletions(-)
New commits:
commit fa94c34b083b5b4019975624453e53d0cbad2a5d
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Jul 24 18:53:01 2014 +0200
libsystemd-network: use CLOCK_BOOTTIME instead of CLOCK_MONOTONIC where possible
The timeouts in the networking library (DHCP lease timeouts and similar) should not be affected
by suspend. In the cases where CLOCK_BOOTTIME is not implemented, it is still safe to fallback to
CLOCK_MONOTONIC, as the consumers of the library (i.e., networkd) _should_ renew the leases when
coming out of suspend.
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index f7a4018..e622564 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -412,7 +412,7 @@ static int client_send_discover(sd_dhcp_client *client) {
/* See RFC2131 section 4.4.1 */
- r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
return r;
assert(time_now >= client->start_time);
@@ -612,7 +612,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
assert(client);
assert(client->event);
- r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
goto error;
@@ -674,7 +674,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
r = sd_event_add_time(client->event,
&client->timeout_resend,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
next_timeout, 10 * USEC_PER_MSEC,
client_timeout_resend, client);
if (r < 0)
@@ -762,7 +762,7 @@ static int client_initialize_events(sd_dhcp_client *client,
r = sd_event_add_time(client->event,
&client->timeout_resend,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
0, 0,
client_timeout_resend, client);
if (r < 0)
@@ -800,7 +800,7 @@ static int client_start(sd_dhcp_client *client) {
client->fd = r;
if (client->state == DHCP_STATE_INIT) {
- client->start_time = now(CLOCK_MONOTONIC);
+ client->start_time = now(clock_boottime_or_monotonic());
client->secs = 0;
}
@@ -1006,7 +1006,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
if (client->lease->lifetime == 0xffffffff)
return 0;
- r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
return r;
assert(client->request_sent <= time_now);
@@ -1057,7 +1057,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
/* arm lifetime timeout */
r = sd_event_add_time(client->event, &client->timeout_expire,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
lifetime_timeout, 10 * USEC_PER_MSEC,
client_timeout_expire, client);
if (r < 0)
@@ -1079,7 +1079,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
/* arm T2 timeout */
r = sd_event_add_time(client->event,
&client->timeout_t2,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
t2_timeout,
10 * USEC_PER_MSEC,
client_timeout_t2, client);
@@ -1102,7 +1102,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
/* arm T1 timeout */
r = sd_event_add_time(client->event,
&client->timeout_t1,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
t1_timeout, 10 * USEC_PER_MSEC,
client_timeout_t1, client);
if (r < 0)
@@ -1172,7 +1172,7 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message,
r = sd_event_add_time(client->event,
&client->timeout_resend,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
0, 0,
client_timeout_resend, client);
if (r < 0)
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index 53cf0d7..bcf7d1f 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -712,9 +712,9 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
} else
lease = existing_lease;
- r = sd_event_now(server->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(server->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
- time_now = now(CLOCK_MONOTONIC);
+ time_now = now(clock_boottime_or_monotonic());
lease->expiration = req->lifetime * USEC_PER_SEC + time_now;
r = server_send_ack(server, req, address);
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 13bed67..c6c82eb 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -460,7 +460,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
client->retransmit_count++;
- r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
goto error;
@@ -484,7 +484,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
client->retransmit_time, 0));
r = sd_event_add_time(client->event, &client->timeout_resend,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
time_now + client->retransmit_time,
10 * USEC_PER_MSEC, client_timeout_resend,
client);
@@ -503,7 +503,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
r = sd_event_add_time(client->event,
&client->timeout_resend_expire,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
time_now + max_retransmit_duration,
USEC_PER_SEC,
client_timeout_resend_expire, client);
@@ -908,7 +908,7 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
case DHCP6_STATE_BOUND:
- r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(client->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
return r;
@@ -931,7 +931,7 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
r = sd_event_add_time(client->event,
&client->lease->ia.timeout_t1,
- CLOCK_MONOTONIC, time_now + timeout,
+ clock_boottime_or_monotonic(), time_now + timeout,
10 * USEC_PER_SEC, client_timeout_t1,
client);
if (r < 0)
@@ -951,7 +951,7 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
r = sd_event_add_time(client->event,
&client->lease->ia.timeout_t2,
- CLOCK_MONOTONIC, time_now + timeout,
+ clock_boottime_or_monotonic(), time_now + timeout,
10 * USEC_PER_SEC, client_timeout_t2,
client);
if (r < 0)
@@ -970,7 +970,7 @@ static int client_start(sd_dhcp6_client *client, enum DHCP6State state)
client->transaction_id = random_u32() & htobe32(0x00ffffff);
r = sd_event_add_time(client->event, &client->timeout_resend,
- CLOCK_MONOTONIC, 0, 0, client_timeout_resend,
+ clock_boottime_or_monotonic(), 0, 0, client_timeout_resend,
client);
if (r < 0)
return r;
diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c
index 80915c3..b264e79 100644
--- a/src/libsystemd-network/sd-icmp6-nd.c
+++ b/src/libsystemd-network/sd-icmp6-nd.c
@@ -255,7 +255,7 @@ static int icmp6_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
nd->nd_sent++;
- r = sd_event_now(nd->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(nd->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0) {
icmp6_nd_notify(nd, r);
return 0;
@@ -263,7 +263,7 @@ static int icmp6_router_solicitation_timeout(sd_event_source *s, uint64_t usec,
next_timeout = time_now + ICMP6_ROUTER_SOLICITATION_INTERVAL;
- r = sd_event_add_time(nd->event, &nd->timeout, CLOCK_MONOTONIC,
+ r = sd_event_add_time(nd->event, &nd->timeout, clock_boottime_or_monotonic(),
next_timeout, 0,
icmp6_router_solicitation_timeout, nd);
if (r < 0) {
@@ -322,7 +322,7 @@ int sd_icmp6_router_solicitation_start(sd_icmp6_nd *nd) {
if (r < 0)
goto error;
- r = sd_event_add_time(nd->event, &nd->timeout, CLOCK_MONOTONIC,
+ r = sd_event_add_time(nd->event, &nd->timeout, clock_boottime_or_monotonic(),
0, 0, icmp6_router_solicitation_timeout, nd);
if (r < 0)
goto error;
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index fd39c12..b179879 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -186,8 +186,8 @@ static void ipv4ll_set_next_wakeup(sd_ipv4ll *ll, int sec, int random_sec) {
if (random_sec)
next_timeout += random_u32() % (random_sec * USEC_PER_SEC);
- if (sd_event_now(ll->event, CLOCK_MONOTONIC, &time_now) < 0)
- time_now = now(CLOCK_MONOTONIC);
+ if (sd_event_now(ll->event, clock_boottime_or_monotonic(), &time_now) < 0)
+ time_now = now(clock_boottime_or_monotonic());
ll->next_wakeup = time_now + next_timeout;
ll->next_wakeup_valid = 1;
@@ -289,7 +289,7 @@ static void ipv4ll_run_state_machine(sd_ipv4ll *ll, IPv4LLTrigger trigger, void
if (ipv4ll_arp_conflict(ll, in_packet)) {
- r = sd_event_now(ll->event, CLOCK_MONOTONIC, &time_now);
+ r = sd_event_now(ll->event, clock_boottime_or_monotonic(), &time_now);
if (r < 0)
goto out;
@@ -344,7 +344,7 @@ static void ipv4ll_run_state_machine(sd_ipv4ll *ll, IPv4LLTrigger trigger, void
if (ll->next_wakeup_valid) {
ll->timer = sd_event_source_unref(ll->timer);
- r = sd_event_add_time(ll->event, &ll->timer, CLOCK_MONOTONIC,
+ r = sd_event_add_time(ll->event, &ll->timer, clock_boottime_or_monotonic(),
ll->next_wakeup, 0, ipv4ll_timer, ll);
if (r < 0)
goto out;
@@ -562,8 +562,8 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
r = sd_event_add_time(ll->event,
&ll->timer,
- CLOCK_MONOTONIC,
- now(CLOCK_MONOTONIC), 0,
+ clock_boottime_or_monotonic(),
+ now(clock_boottime_or_monotonic()), 0,
ipv4ll_timer, ll);
if (r < 0)
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index 7cbe10d..c48aa04 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -447,7 +447,7 @@ static int test_addr_acq_recv_discover(size_t size, DHCPMessage *discover) {
}
static void test_addr_acq(sd_event *e) {
- usec_t time_now = now(CLOCK_MONOTONIC);
+ usec_t time_now = now(clock_boottime_or_monotonic());
sd_dhcp_client *client;
int res, r;
@@ -470,7 +470,7 @@ static void test_addr_acq(sd_event *e) {
callback_recv = test_addr_acq_recv_discover;
assert_se(sd_event_add_time(e, &test_hangcheck,
- CLOCK_MONOTONIC,
+ clock_boottime_or_monotonic(),
time_now + 2 * USEC_PER_SEC, 0,
test_dhcp_hangcheck, NULL) >= 0);
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
index 5bb410d..96c68e1 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -537,7 +537,7 @@ static void test_client_solicit_cb(sd_dhcp6_client *client, int event,
static int test_client_solicit(sd_event *e) {
sd_dhcp6_client *client;
- usec_t time_now = now(CLOCK_MONOTONIC);
+ usec_t time_now = now(clock_boottime_or_monotonic());
if (verbose)
printf("* %s\n", __FUNCTION__);
@@ -553,7 +553,7 @@ static int test_client_solicit(sd_event *e) {
assert_se(sd_dhcp6_client_set_callback(client,
test_client_solicit_cb, e) >= 0);
- assert_se(sd_event_add_time(e, &hangcheck, CLOCK_MONOTONIC,
+ assert_se(sd_event_add_time(e, &hangcheck, clock_boottime_or_monotonic(),
time_now + 2 * USEC_PER_SEC, 0,
test_hangcheck, NULL) >= 0);
diff --git a/src/libsystemd-network/test-icmp6-rs.c b/src/libsystemd-network/test-icmp6-rs.c
index b81211f..afa8562 100644
--- a/src/libsystemd-network/test-icmp6-rs.c
+++ b/src/libsystemd-network/test-icmp6-rs.c
@@ -108,7 +108,7 @@ static void test_rs_done(sd_icmp6_nd *nd, int event, void *userdata) {
}
static void test_rs(sd_event *e) {
- usec_t time_now = now(CLOCK_MONOTONIC);
+ usec_t time_now = now(clock_boottime_or_monotonic());
sd_icmp6_nd *nd;
if (verbose)
@@ -123,7 +123,7 @@ static void test_rs(sd_event *e) {
assert(sd_icmp6_nd_set_mac(nd, &mac_addr) >= 0);
assert(sd_icmp6_nd_set_callback(nd, test_rs_done, e) >= 0);
- assert(sd_event_add_time(e, &test_hangcheck, CLOCK_MONOTONIC,
+ assert(sd_event_add_time(e, &test_hangcheck, clock_boottime_or_monotonic(),
time_now + 2 *USEC_PER_SEC, 0,
test_rs_hangcheck, NULL) >= 0);
commit 77ff2de999b7ea6b1b4a3a218fbd9d62bb07cd54
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Jul 24 18:36:37 2014 +0200
time-util: add clock_boottime_or_monotonic
CLOCK_BOOTTIME is not supported by timerfd on older kernels, so for the time beeing,
use this helper instead which will fallback to CLOCK_MONOTONIC if CLOCK_BOOTTIME is
not supported.
diff --git a/src/shared/time-util.c b/src/shared/time-util.c
index fc79c56..76ab143 100644
--- a/src/shared/time-util.c
+++ b/src/shared/time-util.c
@@ -22,6 +22,7 @@
#include <time.h>
#include <string.h>
#include <sys/timex.h>
+#include <sys/timerfd.h>
#include "util.h"
#include "time-util.h"
@@ -929,3 +930,21 @@ bool timezone_is_valid(const char *name) {
return true;
}
+
+clockid_t clock_boottime_or_monotonic(void) {
+ static clockid_t clock = -1;
+ int fd;
+
+ if (clock != -1)
+ return clock;
+
+ fd = timerfd_create(CLOCK_BOOTTIME, TFD_NONBLOCK|TFD_CLOEXEC);
+ if (fd < 0)
+ clock = CLOCK_MONOTONIC;
+ else {
+ safe_close(fd);
+ clock = CLOCK_BOOTTIME;
+ }
+
+ return clock;
+}
diff --git a/src/shared/time-util.h b/src/shared/time-util.h
index 792cd27..69a48c6 100644
--- a/src/shared/time-util.h
+++ b/src/shared/time-util.h
@@ -98,3 +98,5 @@ bool ntp_synced(void);
int get_timezones(char ***l);
bool timezone_is_valid(const char *name);
+
+clockid_t clock_boottime_or_monotonic(void);
commit a854881616afbe4c4f55396d3fc2f922bbbe716b
Author: Tom Gundersen <teg at jklm.no>
Date: Thu Jul 24 16:08:07 2014 +0200
sd-event: add support for CLOCK_BOOTTIME
This requires a very recent kernel (3.15), so care should be taken
when using this functionality.
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 9a9664c..b285017 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -43,6 +43,7 @@
typedef enum EventSourceType {
SOURCE_IO,
SOURCE_TIME_REALTIME,
+ SOURCE_TIME_BOOTTIME,
SOURCE_TIME_MONOTONIC,
SOURCE_TIME_REALTIME_ALARM,
SOURCE_TIME_BOOTTIME_ALARM,
@@ -56,7 +57,7 @@ typedef enum EventSourceType {
_SOURCE_EVENT_SOURCE_TYPE_INVALID = -1
} EventSourceType;
-#define EVENT_SOURCE_IS_TIME(t) IN_SET((t), SOURCE_TIME_REALTIME, SOURCE_TIME_MONOTONIC, SOURCE_TIME_REALTIME_ALARM, SOURCE_TIME_BOOTTIME_ALARM)
+#define EVENT_SOURCE_IS_TIME(t) IN_SET((t), SOURCE_TIME_REALTIME, SOURCE_TIME_BOOTTIME, SOURCE_TIME_MONOTONIC, SOURCE_TIME_REALTIME_ALARM, SOURCE_TIME_BOOTTIME_ALARM)
struct sd_event_source {
unsigned n_ref;
@@ -142,10 +143,11 @@ struct sd_event {
Prioq *pending;
Prioq *prepare;
- /* timerfd_create() only supports these four clocks so far. We
+ /* timerfd_create() only supports these five clocks so far. We
* can add support for more clocks when the kernel learns to
* deal with them, too. */
struct clock_data realtime;
+ struct clock_data boottime;
struct clock_data monotonic;
struct clock_data realtime_alarm;
struct clock_data boottime_alarm;
@@ -377,6 +379,7 @@ static void event_free(sd_event *e) {
safe_close(e->watchdog_fd);
free_clock_data(&e->realtime);
+ free_clock_data(&e->boottime);
free_clock_data(&e->monotonic);
free_clock_data(&e->realtime_alarm);
free_clock_data(&e->boottime_alarm);
@@ -403,8 +406,8 @@ _public_ int sd_event_new(sd_event** ret) {
return -ENOMEM;
e->n_ref = 1;
- e->signal_fd = e->watchdog_fd = e->epoll_fd = e->realtime.fd = e->monotonic.fd = e->realtime_alarm.fd = e->boottime_alarm.fd = -1;
- e->realtime.next = e->monotonic.next = e->realtime_alarm.next = e->boottime_alarm.next = (usec_t) -1;
+ e->signal_fd = e->watchdog_fd = e->epoll_fd = e->realtime.fd = e->boottime.fd = e->monotonic.fd = e->realtime_alarm.fd = e->boottime_alarm.fd = -1;
+ e->realtime.next = e->boottime.next = e->monotonic.next = e->realtime_alarm.next = e->boottime_alarm.next = (usec_t) -1;
e->original_pid = getpid();
e->perturb = (usec_t) -1;
@@ -517,6 +520,9 @@ static clockid_t event_source_type_to_clock(EventSourceType t) {
case SOURCE_TIME_REALTIME:
return CLOCK_REALTIME;
+ case SOURCE_TIME_BOOTTIME:
+ return CLOCK_BOOTTIME;
+
case SOURCE_TIME_MONOTONIC:
return CLOCK_MONOTONIC;
@@ -538,6 +544,9 @@ static EventSourceType clock_to_event_source_type(clockid_t clock) {
case CLOCK_REALTIME:
return SOURCE_TIME_REALTIME;
+ case CLOCK_BOOTTIME:
+ return SOURCE_TIME_BOOTTIME;
+
case CLOCK_MONOTONIC:
return SOURCE_TIME_MONOTONIC;
@@ -560,6 +569,9 @@ static struct clock_data* event_get_clock_data(sd_event *e, EventSourceType t) {
case SOURCE_TIME_REALTIME:
return &e->realtime;
+ case SOURCE_TIME_BOOTTIME:
+ return &e->boottime;
+
case SOURCE_TIME_MONOTONIC:
return &e->monotonic;
@@ -593,6 +605,7 @@ static void source_disconnect(sd_event_source *s) {
break;
case SOURCE_TIME_REALTIME:
+ case SOURCE_TIME_BOOTTIME:
case SOURCE_TIME_MONOTONIC:
case SOURCE_TIME_REALTIME_ALARM:
case SOURCE_TIME_BOOTTIME_ALARM: {
@@ -1383,6 +1396,7 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
break;
case SOURCE_TIME_REALTIME:
+ case SOURCE_TIME_BOOTTIME:
case SOURCE_TIME_MONOTONIC:
case SOURCE_TIME_REALTIME_ALARM:
case SOURCE_TIME_BOOTTIME_ALARM: {
@@ -1445,6 +1459,7 @@ _public_ int sd_event_source_set_enabled(sd_event_source *s, int m) {
break;
case SOURCE_TIME_REALTIME:
+ case SOURCE_TIME_BOOTTIME:
case SOURCE_TIME_MONOTONIC:
case SOURCE_TIME_REALTIME_ALARM:
case SOURCE_TIME_BOOTTIME_ALARM: {
@@ -2005,6 +2020,7 @@ static int source_dispatch(sd_event_source *s) {
break;
case SOURCE_TIME_REALTIME:
+ case SOURCE_TIME_BOOTTIME:
case SOURCE_TIME_MONOTONIC:
case SOURCE_TIME_REALTIME_ALARM:
case SOURCE_TIME_BOOTTIME_ALARM:
@@ -2205,6 +2221,10 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
if (r < 0)
goto finish;
+ r = event_arm_timer(e, &e->boottime);
+ if (r < 0)
+ goto finish;
+
r = event_arm_timer(e, &e->monotonic);
if (r < 0)
goto finish;
@@ -2239,6 +2259,8 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
if (ev_queue[i].data.ptr == INT_TO_PTR(SOURCE_TIME_REALTIME))
r = flush_timer(e, e->realtime.fd, ev_queue[i].events, &e->realtime.next);
+ else if (ev_queue[i].data.ptr == INT_TO_PTR(SOURCE_TIME_BOOTTIME))
+ r = flush_timer(e, e->boottime.fd, ev_queue[i].events, &e->boottime.next);
else if (ev_queue[i].data.ptr == INT_TO_PTR(SOURCE_TIME_MONOTONIC))
r = flush_timer(e, e->monotonic.fd, ev_queue[i].events, &e->monotonic.next);
else if (ev_queue[i].data.ptr == INT_TO_PTR(SOURCE_TIME_REALTIME_ALARM))
@@ -2264,6 +2286,10 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) {
if (r < 0)
goto finish;
+ r = process_timer(e, e->timestamp_boottime, &e->boottime);
+ if (r < 0)
+ goto finish;
+
r = process_timer(e, e->timestamp.monotonic, &e->monotonic);
if (r < 0)
goto finish;
@@ -2369,6 +2395,7 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
*usec = e->timestamp.monotonic;
break;
+ case CLOCK_BOOTTIME:
case CLOCK_BOOTTIME_ALARM:
*usec = e->timestamp_boottime;
break;
More information about the systemd-commits
mailing list