mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 17:51:22 +03:00
network: move sd_event initialization to manager_new()
This commit is contained in:
parent
57916ea352
commit
3534a04300
@ -1370,7 +1370,7 @@ static const struct hash_ops dhcp6_prefixes_hash_ops = {
|
||||
.compare = dhcp6_prefixes_compare_func,
|
||||
};
|
||||
|
||||
int manager_new(Manager **ret, sd_event *event) {
|
||||
int manager_new(Manager **ret) {
|
||||
_cleanup_(manager_freep) Manager *m = NULL;
|
||||
int r;
|
||||
|
||||
@ -1382,7 +1382,13 @@ int manager_new(Manager **ret, sd_event *event) {
|
||||
if (!m->state_file)
|
||||
return -ENOMEM;
|
||||
|
||||
m->event = sd_event_ref(event);
|
||||
r = sd_event_default(&m->event);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
sd_event_set_watchdog(m->event, true);
|
||||
sd_event_add_signal(m->event, NULL, SIGTERM, NULL, NULL);
|
||||
sd_event_add_signal(m->event, NULL, SIGINT, NULL, NULL);
|
||||
|
||||
r = sd_event_add_post(m->event, NULL, manager_dirty_handler, m);
|
||||
if (r < 0)
|
||||
|
@ -65,7 +65,7 @@ static inline const DUID* link_duid(const Link *link) {
|
||||
|
||||
extern const sd_bus_vtable manager_vtable[];
|
||||
|
||||
int manager_new(Manager **ret, sd_event *event);
|
||||
int manager_new(Manager **ret);
|
||||
void manager_free(Manager *m);
|
||||
|
||||
int manager_connect_bus(Manager *m);
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "user-util.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
sd_event *event = NULL;
|
||||
_cleanup_(manager_freep) Manager *m = NULL;
|
||||
const char *user = "systemd-network";
|
||||
uid_t uid;
|
||||
@ -71,15 +70,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGTERM, SIGINT, -1) >= 0);
|
||||
|
||||
r = sd_event_default(&event);
|
||||
if (r < 0)
|
||||
goto out;
|
||||
|
||||
sd_event_set_watchdog(event, true);
|
||||
sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
|
||||
sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
|
||||
|
||||
r = manager_new(&m, event);
|
||||
r = manager_new(&m);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Could not create manager: %m");
|
||||
goto out;
|
||||
@ -137,7 +128,7 @@ int main(int argc, char *argv[]) {
|
||||
"READY=1\n"
|
||||
"STATUS=Processing requests...");
|
||||
|
||||
r = sd_event_loop(event);
|
||||
r = sd_event_loop(m->event);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Event loop failed: %m");
|
||||
goto out;
|
||||
@ -147,7 +138,5 @@ out:
|
||||
"STOPPING=1\n"
|
||||
"STATUS=Shutting down...");
|
||||
|
||||
sd_event_unref(event);
|
||||
|
||||
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
|
@ -219,7 +219,6 @@ static void test_dhcp_hostname_shorten_overlong(void) {
|
||||
|
||||
int main(void) {
|
||||
_cleanup_(manager_freep) Manager *manager = NULL;
|
||||
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *loopback = NULL;
|
||||
int r;
|
||||
@ -229,9 +228,7 @@ int main(void) {
|
||||
test_address_equality();
|
||||
test_dhcp_hostname_shorten_overlong();
|
||||
|
||||
assert_se(sd_event_default(&event) >= 0);
|
||||
|
||||
assert_se(manager_new(&manager, event) >= 0);
|
||||
assert_se(manager_new(&manager) >= 0);
|
||||
|
||||
r = test_load_config(manager);
|
||||
if (r == -EPERM)
|
||||
|
Loading…
Reference in New Issue
Block a user