summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-24 02:49:09 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-24 02:58:41 +0100
commit6a0f1f6d5af7c7300d3db7a0ba2b068f8abd222b (patch)
tree37083cf4a7292fc4657372d034475e026693f969 /src/libsystemd-network
parentf66eeb6bb636f8061bf45e6e8e24761e87510800 (diff)
sd-event: rework API to support CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM, too
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c62
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c17
-rw-r--r--src/libsystemd-network/test-dhcp-client.c7
3 files changed, 47 insertions, 39 deletions
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 0728a15550..0be6212a4f 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -300,7 +300,7 @@ static int client_send_discover(sd_dhcp_client *client) {
assert(client);
- r = sd_event_get_now_monotonic(client->event, &time_now);
+ r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
if (r < 0)
return r;
assert(time_now >= client->start_time);
@@ -427,7 +427,7 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
assert(client);
assert(client->event);
- r = sd_event_get_now_monotonic(client->event, &time_now);
+ r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
if (r < 0)
goto error;
@@ -476,11 +476,11 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec,
client->timeout_resend = sd_event_source_unref(client->timeout_resend);
- r = sd_event_add_monotonic(client->event,
- &client->timeout_resend,
- next_timeout,
- 10 * USEC_PER_MSEC,
- client_timeout_resend, client);
+ r = sd_event_add_time(client->event,
+ &client->timeout_resend,
+ CLOCK_MONOTONIC,
+ next_timeout, 10 * USEC_PER_MSEC,
+ client_timeout_resend, client);
if (r < 0)
goto error;
@@ -560,9 +560,11 @@ static int client_initialize_events(sd_dhcp_client *client,
client->timeout_resend = sd_event_source_unref(client->timeout_resend);
- r = sd_event_add_monotonic(client->event,
- &client->timeout_resend, 0, 0,
- client_timeout_resend, client);
+ r = sd_event_add_time(client->event,
+ &client->timeout_resend,
+ CLOCK_MONOTONIC,
+ 0, 0,
+ client_timeout_resend, client);
if (r < 0)
goto error;
@@ -806,7 +808,7 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
if (client->lease->lifetime == 0xffffffff)
return 0;
- r = sd_event_get_now_monotonic(client->event, &time_now);
+ r = sd_event_now(client->event, CLOCK_MONOTONIC, &time_now);
if (r < 0)
return r;
assert(client->request_sent <= time_now);
@@ -856,10 +858,10 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
}
/* arm lifetime timeout */
- r = sd_event_add_monotonic(client->event,
- &client->timeout_expire, lifetime_timeout,
- 10 * USEC_PER_MSEC,
- client_timeout_expire, client);
+ r = sd_event_add_time(client->event, &client->timeout_expire,
+ CLOCK_MONOTONIC,
+ lifetime_timeout, 10 * USEC_PER_MSEC,
+ client_timeout_expire, client);
if (r < 0)
return r;
@@ -877,11 +879,12 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
return 0;
/* arm T2 timeout */
- r = sd_event_add_monotonic(client->event,
- &client->timeout_t2,
- t2_timeout,
- 10 * USEC_PER_MSEC,
- client_timeout_t2, client);
+ r = sd_event_add_time(client->event,
+ &client->timeout_t2,
+ CLOCK_MONOTONIC,
+ t2_timeout,
+ 10 * USEC_PER_MSEC,
+ client_timeout_t2, client);
if (r < 0)
return r;
@@ -899,11 +902,11 @@ static int client_set_lease_timeouts(sd_dhcp_client *client) {
return 0;
/* arm T1 timeout */
- r = sd_event_add_monotonic(client->event,
- &client->timeout_t1,
- t1_timeout,
- 10 * USEC_PER_MSEC,
- client_timeout_t1, client);
+ r = sd_event_add_time(client->event,
+ &client->timeout_t1,
+ CLOCK_MONOTONIC,
+ t1_timeout, 10 * USEC_PER_MSEC,
+ client_timeout_t1, client);
if (r < 0)
return r;
@@ -964,10 +967,11 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message,
client->state = DHCP_STATE_REQUESTING;
client->attempt = 1;
- r = sd_event_add_monotonic(client->event,
- &client->timeout_resend, 0,
- 0, client_timeout_resend,
- client);
+ r = sd_event_add_time(client->event,
+ &client->timeout_resend,
+ CLOCK_MONOTONIC,
+ 0, 0,
+ client_timeout_resend, client);
if (r < 0)
goto error;
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index 7431af729e..a201139b08 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -165,7 +165,7 @@ static int ipv4ll_timer(sd_event_source *s, uint64_t usec, void *userdata) {
return 0;
}
-static void ipv4ll_set_next_wakeup (sd_ipv4ll *ll, int sec, int random_sec) {
+static void ipv4ll_set_next_wakeup(sd_ipv4ll *ll, int sec, int random_sec) {
usec_t next_timeout = 0;
usec_t time_now = 0;
@@ -178,7 +178,7 @@ 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_get_now_monotonic(ll->event, &time_now) < 0)
+ if (sd_event_now(ll->event, CLOCK_MONOTONIC, &time_now) < 0)
time_now = now(CLOCK_MONOTONIC);
ll->next_wakeup = time_now + next_timeout;
@@ -278,7 +278,7 @@ static void ipv4ll_run_state_machine(sd_ipv4ll *ll, IPv4LLTrigger trigger, void
if (ipv4ll_arp_conflict(ll, in_packet)) {
- r = sd_event_get_now_monotonic(ll->event, &time_now);
+ r = sd_event_now(ll->event, CLOCK_MONOTONIC, &time_now);
if (r < 0)
goto out;
@@ -330,8 +330,8 @@ 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_monotonic(ll->event, &ll->timer,
- ll->next_wakeup, 0, ipv4ll_timer, ll);
+ r = sd_event_add_time(ll->event, &ll->timer, CLOCK_MONOTONIC,
+ ll->next_wakeup, 0, ipv4ll_timer, ll);
if (r < 0)
goto out;
@@ -530,8 +530,11 @@ int sd_ipv4ll_start (sd_ipv4ll *ll) {
if (r < 0)
goto out;
- r = sd_event_add_monotonic(ll->event, &ll->timer, now(CLOCK_MONOTONIC), 0,
- ipv4ll_timer, ll);
+ r = sd_event_add_time(ll->event,
+ &ll->timer,
+ CLOCK_MONOTONIC,
+ now(CLOCK_MONOTONIC), 0,
+ ipv4ll_timer, ll);
if (r < 0)
goto out;
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index 0f7adac562..2d4d59096a 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -466,9 +466,10 @@ static void test_addr_acq(sd_event *e)
callback_recv = test_addr_acq_recv_discover;
- assert_se(sd_event_add_monotonic(e, &test_hangcheck,
- time_now + 2 * USEC_PER_SEC, 0,
- test_dhcp_hangcheck, NULL) >= 0);
+ assert_se(sd_event_add_time(e, &test_hangcheck,
+ CLOCK_MONOTONIC,
+ time_now + 2 * USEC_PER_SEC, 0,
+ test_dhcp_hangcheck, NULL) >= 0);
res = sd_dhcp_client_start(client);
assert_se(res == 0 || res == -EINPROGRESS);