mirror of
https://github.com/systemd/systemd.git
synced 2025-01-26 14:04:03 +03:00
resolved: enforce limit on concurrent outstanding queries
This commit is contained in:
parent
634af5665f
commit
39762fdf67
@ -26,6 +26,7 @@
|
|||||||
#define QUERY_TIMEOUT_USEC (30 * USEC_PER_SEC)
|
#define QUERY_TIMEOUT_USEC (30 * USEC_PER_SEC)
|
||||||
#define ATTEMPTS_MAX 8
|
#define ATTEMPTS_MAX 8
|
||||||
#define CNAME_MAX 8
|
#define CNAME_MAX 8
|
||||||
|
#define QUERIES_MAX 2048
|
||||||
|
|
||||||
static int dns_query_transaction_start(DnsQueryTransaction *t);
|
static int dns_query_transaction_start(DnsQueryTransaction *t);
|
||||||
|
|
||||||
@ -403,8 +404,10 @@ DnsQuery *dns_query_free(DnsQuery *q) {
|
|||||||
while (q->transactions)
|
while (q->transactions)
|
||||||
dns_query_transaction_free(q->transactions);
|
dns_query_transaction_free(q->transactions);
|
||||||
|
|
||||||
if (q->manager)
|
if (q->manager) {
|
||||||
LIST_REMOVE(queries, q->manager->dns_queries, q);
|
LIST_REMOVE(queries, q->manager->dns_queries, q);
|
||||||
|
q->manager->n_dns_queries--;
|
||||||
|
}
|
||||||
|
|
||||||
for (n = 0; n < q->n_keys; n++)
|
for (n = 0; n < q->n_keys; n++)
|
||||||
free(q->keys[n].name);
|
free(q->keys[n].name);
|
||||||
@ -423,6 +426,9 @@ int dns_query_new(Manager *m, DnsQuery **ret, DnsResourceKey *keys, unsigned n_k
|
|||||||
if (n_keys <= 0 || n_keys >= 65535)
|
if (n_keys <= 0 || n_keys >= 65535)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (m->n_dns_queries >= QUERIES_MAX)
|
||||||
|
return -EBUSY;
|
||||||
|
|
||||||
assert(keys);
|
assert(keys);
|
||||||
|
|
||||||
q = new0(DnsQuery, 1);
|
q = new0(DnsQuery, 1);
|
||||||
@ -447,6 +453,7 @@ int dns_query_new(Manager *m, DnsQuery **ret, DnsResourceKey *keys, unsigned n_k
|
|||||||
}
|
}
|
||||||
|
|
||||||
LIST_PREPEND(queries, m->dns_queries, q);
|
LIST_PREPEND(queries, m->dns_queries, q);
|
||||||
|
m->n_dns_queries++;
|
||||||
q->manager = m;
|
q->manager = m;
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -56,6 +56,7 @@ struct Manager {
|
|||||||
|
|
||||||
Hashmap *dns_query_transactions;
|
Hashmap *dns_query_transactions;
|
||||||
LIST_HEAD(DnsQuery, dns_queries);
|
LIST_HEAD(DnsQuery, dns_queries);
|
||||||
|
unsigned n_dns_queries;
|
||||||
|
|
||||||
LIST_HEAD(DnsServer, dns_servers);
|
LIST_HEAD(DnsServer, dns_servers);
|
||||||
DnsServer *current_dns_server;
|
DnsServer *current_dns_server;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user