summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-query.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-17 01:58:14 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-17 01:58:14 +0200
commit39762fdf67fd338e442abd25246ea4f0248f9bff (patch)
treec1e267309af1538ad2820ec0ec2aaf00d7c8de65 /src/resolve/resolved-dns-query.c
parent634af5665fda8776d22624d947c8de830e30a874 (diff)
resolved: enforce limit on concurrent outstanding queries
Diffstat (limited to 'src/resolve/resolved-dns-query.c')
-rw-r--r--src/resolve/resolved-dns-query.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index 6e04324da5..fcde03d0ea 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -26,6 +26,7 @@
#define QUERY_TIMEOUT_USEC (30 * USEC_PER_SEC)
#define ATTEMPTS_MAX 8
#define CNAME_MAX 8
+#define QUERIES_MAX 2048
static int dns_query_transaction_start(DnsQueryTransaction *t);
@@ -403,8 +404,10 @@ DnsQuery *dns_query_free(DnsQuery *q) {
while (q->transactions)
dns_query_transaction_free(q->transactions);
- if (q->manager)
+ if (q->manager) {
LIST_REMOVE(queries, q->manager->dns_queries, q);
+ q->manager->n_dns_queries--;
+ }
for (n = 0; n < q->n_keys; n++)
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)
return -EINVAL;
+ if (m->n_dns_queries >= QUERIES_MAX)
+ return -EBUSY;
+
assert(keys);
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);
+ m->n_dns_queries++;
q->manager = m;
if (ret)