Skip to content

Commit 0243672

Browse files
yuwatamrc0mmand
authored andcommitted
resolve: exit from loop for transactions when transactions has been regenerated
Fixes #37458. (cherry picked from commit 5814acca9aa4354d121de4bf174851f092a6b643) Related: RHEL-93425
1 parent eec31ef commit 0243672

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/resolve/resolved-dns-query.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ static int dns_query_candidate_go(DnsQueryCandidate *c) {
152152

153153
c->query->block_ready++;
154154

155+
uint64_t generation = c->generation;
156+
155157
/* Start the transactions that are not started yet */
156158
SET_FOREACH(t, c->transactions, i) {
157159
if (t->state != DNS_TRANSACTION_NULL)
@@ -166,6 +168,13 @@ static int dns_query_candidate_go(DnsQueryCandidate *c) {
166168
/* A transaction is complete. */
167169
notify = true;
168170

171+
if (c->generation != generation)
172+
/* The transaction has been completed, and dns_transaction_complete() ->
173+
* dns_query_candidate_notify() has been already called. Moreover, the query
174+
* candidate has been regenerated, and the query should be already restarted.
175+
* Let's exit from the loop now. */
176+
return 0;
177+
169178
n++;
170179
}
171180

@@ -257,6 +266,8 @@ static int dns_query_candidate_setup_transactions(DnsQueryCandidate *c) {
257266

258267
dns_query_candidate_stop(c);
259268

269+
c->generation++;
270+
260271
question = dns_query_question_for_protocol(c->query, c->scope->protocol);
261272

262273
/* Create one transaction per question key */

src/resolve/resolved-dns-query.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct DnsQueryCandidate {
2020
DnsSearchDomain *search_domain;
2121

2222
int error_code;
23+
uint64_t generation;
2324
Set *transactions;
2425

2526
LIST_FIELDS(DnsQueryCandidate, candidates_by_query);

0 commit comments

Comments
 (0)