[systemd-commits] 4 commits - src/network src/resolve src/timesync
Lennart Poettering
lennart at kemper.freedesktop.org
Mon Jul 7 14:12:09 PDT 2014
src/network/networkd-manager.c | 39 +++------------------------------------
src/network/networkd.c | 2 ++
src/resolve/resolved-manager.c | 18 +++++-------------
src/resolve/resolved.c | 2 ++
src/resolve/resolved.h | 6 ++----
src/timesync/timesyncd.c | 2 ++
6 files changed, 16 insertions(+), 53 deletions(-)
New commits:
commit c92e531c82a9815ec349aa1bf31236b86b2d5311
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Jul 7 23:11:48 2014 +0200
resolved: make use of union in_addr_union in resolved, too
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 0e2b85b..9d073c7 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -114,6 +114,8 @@ int manager_new(Manager **ret) {
_cleanup_manager_free_ Manager *m = NULL;
int r;
+ assert(ret);
+
m = new0(Manager, 1);
if (!m)
return -ENOMEM;
diff --git a/src/resolve/resolved.h b/src/resolve/resolved.h
index 984edc7..48b361d 100644
--- a/src/resolve/resolved.h
+++ b/src/resolve/resolved.h
@@ -26,6 +26,7 @@
#include "util.h"
#include "list.h"
+#include "socket-util.h"
typedef struct Address Address;
typedef struct Manager Manager;
@@ -33,10 +34,7 @@ typedef struct Manager Manager;
struct Address {
unsigned char family;
- union {
- struct in_addr in;
- struct in6_addr in6;
- } in_addr;
+ union in_addr_union in_addr;
LIST_FIELDS(Address, addresses);
};
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index 27f6b2d..0c50902 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -1019,6 +1019,8 @@ static int manager_new(Manager **ret) {
_cleanup_manager_free_ Manager *m = NULL;
int r;
+ assert(ret);
+
m = new0(Manager, 1);
if (!m)
return -ENOMEM;
commit 186fe1db20902b6542cee58ba499ced914d687a8
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Jul 7 23:11:03 2014 +0200
networkd: simplify signal handling of SIGTERM/SIGINT
sd-event makes handling SIGTERM/SIGINT a lot easier than it used to,
let's make use of this
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index c1d5012..46b803f 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -43,38 +43,6 @@ const char* const network_dirs[] = {
#endif
NULL};
-static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
- Manager *m = userdata;
-
- assert(m);
-
- log_received_signal(LOG_INFO, si);
-
- sd_event_exit(m->event, 0);
- return 0;
-}
-
-static int setup_signals(Manager *m) {
- sigset_t mask;
- int r;
-
- assert(m);
-
- assert_se(sigemptyset(&mask) == 0);
- sigset_add_many(&mask, SIGINT, SIGTERM, -1);
- assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0);
-
- r = sd_event_add_signal(m->event, &m->sigterm_event_source, SIGTERM, dispatch_sigterm, m);
- if (r < 0)
- return r;
-
- r = sd_event_add_signal(m->event, &m->sigint_event_source, SIGINT, dispatch_sigterm, m);
- if (r < 0)
- return r;
-
- return 0;
-}
-
static int setup_default_address_pool(Manager *m) {
AddressPool *p;
int r;
@@ -120,6 +88,9 @@ int manager_new(Manager **ret) {
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_rtnl_open(&m->rtnl, 3, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR,
RTNLGRP_IPV6_IFADDR);
if (r < 0)
@@ -129,10 +100,6 @@ int manager_new(Manager **ret) {
if (r < 0 && r != -ENOENT) /* TODO: drop when we can rely on kdbus */
return r;
- r = setup_signals(m);
- if (r < 0)
- return r;
-
/* udev does not initialize devices inside containers,
* so we rely on them being already initialized before
* entering the container */
diff --git a/src/network/networkd.c b/src/network/networkd.c
index d607535..665f4c4 100644
--- a/src/network/networkd.c
+++ b/src/network/networkd.c
@@ -75,6 +75,8 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto out;
+ assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+
r = manager_new(&m);
if (r < 0) {
log_error("Could not create manager: %s", strerror(-r));
commit b9e7a9d870ac41d4db954edd52a1f5dd7d153389
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Jul 7 23:09:02 2014 +0200
resolved: make sure SIGTER/SIGINT actually can be caught and processed
diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c
index f61b70f..53f09db 100644
--- a/src/resolve/resolved.c
+++ b/src/resolve/resolved.c
@@ -64,6 +64,8 @@ int main(int argc, char *argv[]) {
if (r < 0)
goto out;
+ assert_se(sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1) == 0);
+
r = manager_new(&m);
if (r < 0) {
log_error("Could not create manager: %s", strerror(-r));
commit 987d561fe202568c0a2880cf047c7833fd365c7a
Author: Lennart Poettering <lennart at poettering.net>
Date: Mon Jul 7 23:03:17 2014 +0200
resolved: let config_parse() open the configuration file for us
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 3ed0603..0e2b85b 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -97,23 +97,13 @@ int config_parse_dnsv(
}
static int manager_parse_config_file(Manager *m) {
- static const char fn[] = "/etc/systemd/resolved.conf";
- _cleanup_fclose_ FILE *f = NULL;
int r;
assert(m);
- f = fopen(fn, "re");
- if (!f) {
- if (errno == ENOENT)
- return 0;
-
- log_warning("Failed to open configuration file %s: %m", fn);
- return -errno;
- }
-
- r = config_parse(NULL, fn, f, "Resolve\0", config_item_perf_lookup,
- (void*) resolved_gperf_lookup, false, false, m);
+ r = config_parse(NULL, "/etc/systemd/resolved.conf", NULL,
+ "Resolve\0", config_item_perf_lookup, (void*) resolved_gperf_lookup,
+ false, false, m);
if (r < 0)
log_warning("Failed to parse configuration file: %s", strerror(-r));
More information about the systemd-commits
mailing list