mirror of
https://github.com/systemd/systemd.git
synced 2025-01-05 13:18:06 +03:00
networkd-wait-online: flush monitor events after processing
Otherwise the event will trigger immediately again.
This commit is contained in:
parent
d91d3c1580
commit
3a9c5a32be
@ -202,6 +202,8 @@ static int monitor_event_handler(sd_event_source *s, int fd, uint32_t revents,
|
|||||||
if (all_configured(m))
|
if (all_configured(m))
|
||||||
sd_event_exit(m->event, 0);
|
sd_event_exit(m->event, 0);
|
||||||
|
|
||||||
|
sd_network_monitor_flush(m->monitor);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +220,6 @@ void manager_free(Manager *m) {
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
_cleanup_manager_free_ Manager *m = NULL;
|
_cleanup_manager_free_ Manager *m = NULL;
|
||||||
_cleanup_event_source_unref_ sd_event_source *event_source = NULL;
|
_cleanup_event_source_unref_ sd_event_source *event_source = NULL;
|
||||||
_cleanup_network_monitor_unref_ sd_network_monitor *monitor = NULL;
|
|
||||||
int r, fd, events;
|
int r, fd, events;
|
||||||
|
|
||||||
umask(0022);
|
umask(0022);
|
||||||
@ -237,25 +238,31 @@ int main(int argc, char *argv[]) {
|
|||||||
if (!m)
|
if (!m)
|
||||||
return log_oom();
|
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);
|
r = sd_event_new(&m->event);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_error("Could not create event: %s", strerror(-r));
|
log_error("Could not create event: %s", strerror(-r));
|
||||||
goto out;
|
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) {
|
if (fd < 0) {
|
||||||
log_error("Could not get monitor fd: %s", strerror(-r));
|
log_error("Could not get monitor fd: %s", strerror(-r));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
events = sd_network_monitor_get_events(monitor);
|
events = sd_network_monitor_get_events(m->monitor);
|
||||||
if (events < 0) {
|
if (events < 0) {
|
||||||
log_error("Could not get monitor events: %s", strerror(-r));
|
log_error("Could not get monitor events: %s", strerror(-r));
|
||||||
goto out;
|
goto out;
|
||||||
@ -268,12 +275,6 @@ int main(int argc, char *argv[]) {
|
|||||||
goto out;
|
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)) {
|
if (all_configured(m)) {
|
||||||
r = 0;
|
r = 0;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
typedef struct Manager {
|
typedef struct Manager {
|
||||||
sd_event *event;
|
sd_event *event;
|
||||||
sd_rtnl *rtnl;
|
sd_rtnl *rtnl;
|
||||||
|
sd_network_monitor *monitor;
|
||||||
} Manager;
|
} Manager;
|
||||||
|
|
||||||
void manager_free(Manager *m);
|
void manager_free(Manager *m);
|
||||||
|
Loading…
Reference in New Issue
Block a user