summaryrefslogtreecommitdiff
path: root/src/network/networkd-wait-online-manager.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-02-01 21:04:35 +0100
committerTom Gundersen <teg@jklm.no>2015-02-02 11:57:52 +0100
commite56cdb7ae2657d62c9a8b6d3427382b209dff8e7 (patch)
treec7631551cffc36f5892c47aafee10299c192f129 /src/network/networkd-wait-online-manager.c
parentc4f1aff2306e4fb10efeda75f7015e5d043d4e8d (diff)
networkd-wait-online: add timeout
Default to timing out after 120 seconds without a network connection. Setting a timeout of 0 disables the timeout.
Diffstat (limited to 'src/network/networkd-wait-online-manager.c')
-rw-r--r--src/network/networkd-wait-online-manager.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/network/networkd-wait-online-manager.c b/src/network/networkd-wait-online-manager.c
index d1273725f0..cafe110e50 100644
--- a/src/network/networkd-wait-online-manager.c
+++ b/src/network/networkd-wait-online-manager.c
@@ -31,6 +31,7 @@
#include "networkd-wait-online.h"
#include "util.h"
+#include "time-util.h"
bool manager_ignore_link(Manager *m, Link *link) {
char **ignore;
@@ -262,7 +263,7 @@ static int manager_network_monitor_listen(Manager *m) {
return 0;
}
-int manager_new(Manager **ret, char **interfaces, char **ignore) {
+int manager_new(Manager **ret, char **interfaces, char **ignore, usec_t timeout) {
_cleanup_(manager_freep) Manager *m = NULL;
int r;
@@ -282,6 +283,16 @@ int manager_new(Manager **ret, char **interfaces, char **ignore) {
sd_event_add_signal(m->event, NULL, SIGTERM, NULL, NULL);
sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
+ if (timeout > 0) {
+ usec_t usec;
+
+ usec = now(clock_boottime_or_monotonic()) + timeout;
+
+ r = sd_event_add_time(m->event, NULL, clock_boottime_or_monotonic(), usec, 0, NULL, INT_TO_PTR(-ETIMEDOUT));
+ if (r < 0)
+ return r;
+ }
+
sd_event_set_watchdog(m->event, true);
r = manager_network_monitor_listen(m);