mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-27 01:55:32 +03:00
resolved: fix crash when shutting down
Reported by Cristian Rodríguez http://lists.freedesktop.org/archives/systemd-devel/2015-May/031626.html
This commit is contained in:
parent
6b7d2e9ea4
commit
cab5b05903
@ -91,11 +91,8 @@ void dns_cache_flush(DnsCache *c) {
|
||||
assert(hashmap_size(c->by_key) == 0);
|
||||
assert(prioq_size(c->by_expiry) == 0);
|
||||
|
||||
hashmap_free(c->by_key);
|
||||
c->by_key = NULL;
|
||||
|
||||
prioq_free(c->by_expiry);
|
||||
c->by_expiry = NULL;
|
||||
c->by_key = hashmap_free(c->by_key);
|
||||
c->by_expiry = prioq_free(c->by_expiry);
|
||||
}
|
||||
|
||||
static void dns_cache_remove(DnsCache *c, DnsResourceKey *key) {
|
||||
|
@ -78,23 +78,24 @@ DnsServer* dns_server_free(DnsServer *s) {
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
if (s->manager) {
|
||||
if (s->link) {
|
||||
if (s->type == DNS_SERVER_LINK)
|
||||
LIST_REMOVE(servers, s->link->dns_servers, s);
|
||||
else if (s->type == DNS_SERVER_SYSTEM)
|
||||
|
||||
if (s->link->current_dns_server == s)
|
||||
link_set_dns_server(s->link, NULL);
|
||||
}
|
||||
|
||||
if (s->manager) {
|
||||
if (s->type == DNS_SERVER_SYSTEM)
|
||||
LIST_REMOVE(servers, s->manager->dns_servers, s);
|
||||
else if (s->type == DNS_SERVER_FALLBACK)
|
||||
LIST_REMOVE(servers, s->manager->fallback_dns_servers, s);
|
||||
else
|
||||
assert_not_reached("Unknown server type");
|
||||
|
||||
if (s->manager->current_dns_server == s)
|
||||
manager_set_dns_server(s->manager, NULL);
|
||||
}
|
||||
|
||||
if (s->link && s->link->current_dns_server == s)
|
||||
link_set_dns_server(s->link, NULL);
|
||||
|
||||
free(s);
|
||||
|
||||
return NULL;
|
||||
|
@ -68,13 +68,13 @@ Link *link_free(Link *l) {
|
||||
if (l->manager)
|
||||
hashmap_remove(l->manager->links, INT_TO_PTR(l->ifindex));
|
||||
|
||||
while (l->dns_servers)
|
||||
dns_server_free(l->dns_servers);
|
||||
|
||||
dns_scope_free(l->unicast_scope);
|
||||
dns_scope_free(l->llmnr_ipv4_scope);
|
||||
dns_scope_free(l->llmnr_ipv6_scope);
|
||||
|
||||
while (l->dns_servers)
|
||||
dns_server_free(l->dns_servers);
|
||||
|
||||
free(l);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -534,11 +534,11 @@ Manager *manager_free(Manager *m) {
|
||||
while (m->dns_queries)
|
||||
dns_query_free(m->dns_queries);
|
||||
|
||||
dns_scope_free(m->unicast_scope);
|
||||
|
||||
manager_flush_dns_servers(m, DNS_SERVER_SYSTEM);
|
||||
manager_flush_dns_servers(m, DNS_SERVER_FALLBACK);
|
||||
|
||||
dns_scope_free(m->unicast_scope);
|
||||
|
||||
hashmap_free(m->links);
|
||||
hashmap_free(m->dns_transactions);
|
||||
|
||||
|
@ -45,12 +45,14 @@ Prioq *prioq_new(compare_func_t compare_func) {
|
||||
return q;
|
||||
}
|
||||
|
||||
void prioq_free(Prioq *q) {
|
||||
Prioq* prioq_free(Prioq *q) {
|
||||
if (!q)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
free(q->items);
|
||||
free(q);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func) {
|
||||
|
@ -28,7 +28,7 @@ typedef struct Prioq Prioq;
|
||||
#define PRIOQ_IDX_NULL ((unsigned) -1)
|
||||
|
||||
Prioq *prioq_new(compare_func_t compare);
|
||||
void prioq_free(Prioq *q);
|
||||
Prioq *prioq_free(Prioq *q);
|
||||
int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func);
|
||||
|
||||
int prioq_put(Prioq *q, void *data, unsigned *idx);
|
||||
|
Loading…
Reference in New Issue
Block a user