1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-03 05:18:09 +03:00

networkd-wait-online: flush monitor events after processing

Otherwise the event will trigger immediately again.
This commit is contained in:
Tom Gundersen 2014-05-08 13:14:42 +02:00
parent d91d3c1580
commit 3a9c5a32be
2 changed files with 17 additions and 15 deletions

View File

@ -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);
if (r < 0) {
log_error("Could not create monitor: %s", strerror(-r));
goto out;
}
r = sd_event_new(&m->event);
if (r < 0) {
log_error("Could not create event: %s", strerror(-r));
goto out;
}
fd = sd_network_monitor_get_fd(monitor);
r = sd_rtnl_open(&m->rtnl, 0);
if (r < 0) {
log_error("Could not create rtnl: %s", strerror(-r));
goto out;
}
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;

View File

@ -29,6 +29,7 @@
typedef struct Manager {
sd_event *event;
sd_rtnl *rtnl;
sd_network_monitor *monitor;
} Manager;
void manager_free(Manager *m);