|
|
17b0f1 |
From c724e008771aaaed70f909cb28fdcab1c9244d22 Mon Sep 17 00:00:00 2001
|
|
|
17b0f1 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
17b0f1 |
Date: Mon, 18 May 2015 23:23:17 +0200
|
|
|
17b0f1 |
Subject: [PATCH] resolved: fix crash when shutting down
|
|
|
17b0f1 |
MIME-Version: 1.0
|
|
|
17b0f1 |
Content-Type: text/plain; charset=UTF-8
|
|
|
17b0f1 |
Content-Transfer-Encoding: 8bit
|
|
|
17b0f1 |
|
|
|
17b0f1 |
Reported by Cristian RodrÃguez
|
|
|
17b0f1 |
|
|
|
17b0f1 |
http://lists.freedesktop.org/archives/systemd-devel/2015-May/031626.html
|
|
|
17b0f1 |
(cherry picked from commit cab5b05903096e1c9cf5575ccc73f89d15c8db69)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
Cherry-picked from: cab5b05
|
|
|
17b0f1 |
Resolves: #1222517
|
|
|
17b0f1 |
---
|
|
|
17b0f1 |
src/resolve/resolved-dns-cache.c | 4 +---
|
|
|
17b0f1 |
src/resolve/resolved-dns-server.c | 15 ++++++++-------
|
|
|
17b0f1 |
src/resolve/resolved-link.c | 6 +++---
|
|
|
17b0f1 |
src/resolve/resolved-manager.c | 4 ++--
|
|
|
17b0f1 |
src/shared/prioq.c | 6 ++++--
|
|
|
17b0f1 |
src/shared/prioq.h | 2 +-
|
|
|
17b0f1 |
6 files changed, 19 insertions(+), 18 deletions(-)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
|
|
|
17b0f1 |
index 33ca4d1a45..874207cfb8 100644
|
|
|
17b0f1 |
--- a/src/resolve/resolved-dns-cache.c
|
|
|
17b0f1 |
+++ b/src/resolve/resolved-dns-cache.c
|
|
|
17b0f1 |
@@ -93,9 +93,7 @@ void dns_cache_flush(DnsCache *c) {
|
|
|
17b0f1 |
|
|
|
17b0f1 |
hashmap_free(c->by_key);
|
|
|
17b0f1 |
c->by_key = NULL;
|
|
|
17b0f1 |
-
|
|
|
17b0f1 |
- prioq_free(c->by_expiry);
|
|
|
17b0f1 |
- c->by_expiry = NULL;
|
|
|
17b0f1 |
+ c->by_expiry = prioq_free(c->by_expiry);
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
static void dns_cache_remove(DnsCache *c, DnsResourceKey *key) {
|
|
|
17b0f1 |
diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c
|
|
|
17b0f1 |
index caf06fe450..9a62a63258 100644
|
|
|
17b0f1 |
--- a/src/resolve/resolved-dns-server.c
|
|
|
17b0f1 |
+++ b/src/resolve/resolved-dns-server.c
|
|
|
17b0f1 |
@@ -78,23 +78,24 @@ DnsServer* dns_server_free(DnsServer *s) {
|
|
|
17b0f1 |
if (!s)
|
|
|
17b0f1 |
return NULL;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- if (s->manager) {
|
|
|
17b0f1 |
+ if (s->link) {
|
|
|
17b0f1 |
if (s->type == DNS_SERVER_LINK)
|
|
|
17b0f1 |
LIST_REMOVE(servers, s->link->dns_servers, s);
|
|
|
17b0f1 |
- else if (s->type == DNS_SERVER_SYSTEM)
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
+ if (s->link->current_dns_server == s)
|
|
|
17b0f1 |
+ link_set_dns_server(s->link, NULL);
|
|
|
17b0f1 |
+ }
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
+ if (s->manager) {
|
|
|
17b0f1 |
+ if (s->type == DNS_SERVER_SYSTEM)
|
|
|
17b0f1 |
LIST_REMOVE(servers, s->manager->dns_servers, s);
|
|
|
17b0f1 |
else if (s->type == DNS_SERVER_FALLBACK)
|
|
|
17b0f1 |
LIST_REMOVE(servers, s->manager->fallback_dns_servers, s);
|
|
|
17b0f1 |
- else
|
|
|
17b0f1 |
- assert_not_reached("Unknown server type");
|
|
|
17b0f1 |
|
|
|
17b0f1 |
if (s->manager->current_dns_server == s)
|
|
|
17b0f1 |
manager_set_dns_server(s->manager, NULL);
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- if (s->link && s->link->current_dns_server == s)
|
|
|
17b0f1 |
- link_set_dns_server(s->link, NULL);
|
|
|
17b0f1 |
-
|
|
|
17b0f1 |
free(s);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
return NULL;
|
|
|
17b0f1 |
diff --git a/src/resolve/resolved-link.c b/src/resolve/resolved-link.c
|
|
|
17b0f1 |
index f94e4bb6f0..27d9129e00 100644
|
|
|
17b0f1 |
--- a/src/resolve/resolved-link.c
|
|
|
17b0f1 |
+++ b/src/resolve/resolved-link.c
|
|
|
17b0f1 |
@@ -68,13 +68,13 @@ Link *link_free(Link *l) {
|
|
|
17b0f1 |
if (l->manager)
|
|
|
17b0f1 |
hashmap_remove(l->manager->links, INT_TO_PTR(l->ifindex));
|
|
|
17b0f1 |
|
|
|
17b0f1 |
+ while (l->dns_servers)
|
|
|
17b0f1 |
+ dns_server_free(l->dns_servers);
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
dns_scope_free(l->unicast_scope);
|
|
|
17b0f1 |
dns_scope_free(l->llmnr_ipv4_scope);
|
|
|
17b0f1 |
dns_scope_free(l->llmnr_ipv6_scope);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- while (l->dns_servers)
|
|
|
17b0f1 |
- dns_server_free(l->dns_servers);
|
|
|
17b0f1 |
-
|
|
|
17b0f1 |
free(l);
|
|
|
17b0f1 |
return NULL;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
|
|
|
17b0f1 |
index b5ad701611..7c253aa13f 100644
|
|
|
17b0f1 |
--- a/src/resolve/resolved-manager.c
|
|
|
17b0f1 |
+++ b/src/resolve/resolved-manager.c
|
|
|
17b0f1 |
@@ -536,11 +536,11 @@ Manager *manager_free(Manager *m) {
|
|
|
17b0f1 |
while (m->dns_queries)
|
|
|
17b0f1 |
dns_query_free(m->dns_queries);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
- dns_scope_free(m->unicast_scope);
|
|
|
17b0f1 |
-
|
|
|
17b0f1 |
manager_flush_dns_servers(m, DNS_SERVER_SYSTEM);
|
|
|
17b0f1 |
manager_flush_dns_servers(m, DNS_SERVER_FALLBACK);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
+ dns_scope_free(m->unicast_scope);
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
hashmap_free(m->links);
|
|
|
17b0f1 |
hashmap_free(m->dns_transactions);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
diff --git a/src/shared/prioq.c b/src/shared/prioq.c
|
|
|
17b0f1 |
index 8af4c51c2f..b89888be0e 100644
|
|
|
17b0f1 |
--- a/src/shared/prioq.c
|
|
|
17b0f1 |
+++ b/src/shared/prioq.c
|
|
|
17b0f1 |
@@ -45,12 +45,14 @@ Prioq *prioq_new(compare_func_t compare_func) {
|
|
|
17b0f1 |
return q;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
-void prioq_free(Prioq *q) {
|
|
|
17b0f1 |
+Prioq* prioq_free(Prioq *q) {
|
|
|
17b0f1 |
if (!q)
|
|
|
17b0f1 |
- return;
|
|
|
17b0f1 |
+ return NULL;
|
|
|
17b0f1 |
|
|
|
17b0f1 |
free(q->items);
|
|
|
17b0f1 |
free(q);
|
|
|
17b0f1 |
+
|
|
|
17b0f1 |
+ return NULL;
|
|
|
17b0f1 |
}
|
|
|
17b0f1 |
|
|
|
17b0f1 |
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func) {
|
|
|
17b0f1 |
diff --git a/src/shared/prioq.h b/src/shared/prioq.h
|
|
|
17b0f1 |
index d836b36cd9..1c044b135c 100644
|
|
|
17b0f1 |
--- a/src/shared/prioq.h
|
|
|
17b0f1 |
+++ b/src/shared/prioq.h
|
|
|
17b0f1 |
@@ -28,7 +28,7 @@ typedef struct Prioq Prioq;
|
|
|
17b0f1 |
#define PRIOQ_IDX_NULL ((unsigned) -1)
|
|
|
17b0f1 |
|
|
|
17b0f1 |
Prioq *prioq_new(compare_func_t compare);
|
|
|
17b0f1 |
-void prioq_free(Prioq *q);
|
|
|
17b0f1 |
+Prioq *prioq_free(Prioq *q);
|
|
|
17b0f1 |
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func);
|
|
|
17b0f1 |
|
|
|
17b0f1 |
int prioq_put(Prioq *q, void *data, unsigned *idx);
|