summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-resolve
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-12 19:29:27 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-12 19:29:27 +0200
commit85529c815b47c22839e0f148af67fd37e977cbfa (patch)
tree359ee5db0e258f3cef1cc0e9bea82d4e72ff0c79 /src/libsystemd/sd-resolve
parent502fe44ea44fdbe2282fbe0625bb2e01777425c0 (diff)
sd-resolve: fix allocation if query ids, never reuse them
Diffstat (limited to 'src/libsystemd/sd-resolve')
-rw-r--r--src/libsystemd/sd-resolve/sd-resolve.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
index df63f1de9e..15f1938639 100644
--- a/src/libsystemd/sd-resolve/sd-resolve.c
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
@@ -85,7 +85,7 @@ struct sd_resolve {
pthread_t workers[WORKERS_MAX];
unsigned n_valid_workers;
- unsigned current_id, current_index;
+ unsigned current_id;
sd_resolve_query* query_array[QUERIES_MAX];
unsigned n_queries, n_done;
@@ -1024,21 +1024,17 @@ static int alloc_query(sd_resolve *resolve, bool floating, sd_resolve_query **_q
if (r < 0)
return r;
- while (resolve->query_array[resolve->current_index]) {
- resolve->current_index++;
+ while (resolve->query_array[resolve->current_id % QUERIES_MAX])
resolve->current_id++;
- resolve->current_index %= QUERIES_MAX;
- }
-
- q = resolve->query_array[resolve->current_index] = new0(sd_resolve_query, 1);
+ q = resolve->query_array[resolve->current_id % QUERIES_MAX] = new0(sd_resolve_query, 1);
if (!q)
return -ENOMEM;
q->n_ref = 1;
q->resolve = resolve;
q->floating = floating;
- q->id = resolve->current_id;
+ q->id = resolve->current_id++;
if (!floating)
sd_resolve_ref(resolve);