summaryrefslogtreecommitdiff
path: root/src/network/networkd-wait-online.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/networkd-wait-online.c')
-rw-r--r--src/network/networkd-wait-online.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/network/networkd-wait-online.c b/src/network/networkd-wait-online.c
index a42fef26b9..3ea7a8384e 100644
--- a/src/network/networkd-wait-online.c
+++ b/src/network/networkd-wait-online.c
@@ -202,6 +202,8 @@ static int monitor_event_handler(sd_event_source *s, int fd, uint32_t revents,
if (all_configured(m))
sd_event_exit(m->event, 0);
+ sd_network_monitor_flush(m->monitor);
+
return 1;
}
@@ -218,7 +220,6 @@ void manager_free(Manager *m) {
int main(int argc, char *argv[]) {
_cleanup_manager_free_ Manager *m = NULL;
_cleanup_event_source_unref_ sd_event_source *event_source = NULL;
- _cleanup_network_monitor_unref_ sd_network_monitor *monitor = NULL;
int r, fd, events;
umask(0022);
@@ -237,25 +238,31 @@ int main(int argc, char *argv[]) {
if (!m)
return log_oom();
- r = sd_network_monitor_new(NULL, &monitor);
+ r = sd_event_new(&m->event);
if (r < 0) {
- log_error("Could not create monitor: %s", strerror(-r));
+ log_error("Could not create event: %s", strerror(-r));
goto out;
}
- r = sd_event_new(&m->event);
+ r = sd_rtnl_open(&m->rtnl, 0);
if (r < 0) {
- log_error("Could not create event: %s", strerror(-r));
+ log_error("Could not create rtnl: %s", strerror(-r));
goto out;
}
- fd = sd_network_monitor_get_fd(monitor);
+ r = sd_network_monitor_new(NULL, &m->monitor);
+ if (r < 0) {
+ log_error("Could not create monitor: %s", strerror(-r));
+ goto out;
+ }
+
+ fd = sd_network_monitor_get_fd(m->monitor);
if (fd < 0) {
log_error("Could not get monitor fd: %s", strerror(-r));
goto out;
}
- events = sd_network_monitor_get_events(monitor);
+ events = sd_network_monitor_get_events(m->monitor);
if (events < 0) {
log_error("Could not get monitor events: %s", strerror(-r));
goto out;
@@ -268,12 +275,6 @@ int main(int argc, char *argv[]) {
goto out;
}
- r = sd_rtnl_open(&m->rtnl, 0);
- if (r < 0) {
- log_error("Could not create rtnl: %s", strerror(-r));
- goto out;
- }
-
if (all_configured(m)) {
r = 0;
goto out;