diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-08-12 19:29:38 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-08-12 19:30:18 +0200 |
commit | 96c76ac49c28ba397fc8db3a40505b875c65ef16 (patch) | |
tree | 53c723e61349da92cc50b0c58bfe3f08d5087386 | |
parent | 85529c815b47c22839e0f148af67fd37e977cbfa (diff) |
sd-resolve: scale number of threads by queries currently being processed, rather than number of queries currently referenced
This way a query that blocks for a longer time, and whose reference has
been dropped won't block subsequent lookups from finishing.
-rw-r--r-- | src/libsystemd/sd-resolve/sd-resolve.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c index 15f1938639..fea695fcf9 100644 --- a/src/libsystemd/sd-resolve/sd-resolve.c +++ b/src/libsystemd/sd-resolve/sd-resolve.c @@ -87,7 +87,7 @@ struct sd_resolve { unsigned current_id; sd_resolve_query* query_array[QUERIES_MAX]; - unsigned n_queries, n_done; + unsigned n_queries, n_done, n_outstanding; sd_event_source *event_source; sd_event *event; @@ -526,7 +526,7 @@ static int start_threads(sd_resolve *resolve, unsigned extra) { unsigned n; int r; - n = resolve->n_queries + extra - resolve->n_done; + n = resolve->n_outstanding + extra; n = CLAMP(n, WORKERS_MIN, WORKERS_MAX); while (resolve->n_valid_workers < n) { @@ -854,6 +854,9 @@ static int handle_response(sd_resolve *resolve, const Packet *packet, size_t len return 0; } + assert(resolve->n_outstanding > 0); + resolve->n_outstanding--; + q = lookup_query(resolve, resp->id); if (!q) return 0; @@ -1099,6 +1102,8 @@ _public_ int sd_resolve_getaddrinfo( return -errno; } + resolve->n_outstanding++; + if (_q) *_q = q; @@ -1167,6 +1172,8 @@ _public_ int sd_resolve_getnameinfo( return -errno; } + resolve->n_outstanding++; + if (_q) *_q = q; @@ -1231,6 +1238,8 @@ static int resolve_res( return -errno; } + resolve->n_outstanding++; + if (_q) *_q = q; |