resolve: exit from loop for transactions when transactions has been regenerated

Fixes #37458.
This commit is contained in:
Yu Watanabe
2025-05-15 07:18:38 +09:00
committed by Luca Boccassi
parent d83ceacc7e
commit 5814acca9a
2 changed files with 12 additions and 0 deletions

View File

@@ -210,6 +210,8 @@ static int dns_query_candidate_go(DnsQueryCandidate *c) {
/* Let's keep a reference to the query while we're operating */
keep_c = dns_query_candidate_ref(c);
uint64_t generation = c->generation;
/* Start the transactions that are not started yet */
SET_FOREACH(t, c->transactions) {
if (t->state != DNS_TRANSACTION_NULL)
@@ -219,6 +221,13 @@ static int dns_query_candidate_go(DnsQueryCandidate *c) {
if (r < 0)
return r;
if (c->generation != generation)
/* The transaction has been completed, and dns_transaction_complete() ->
* dns_query_candidate_notify() has been already called. Moreover, the query
* candidate has been regenerated, and the query should be already restarted.
* Let's exit from the loop now. */
return 0;
n++;
}
@@ -280,6 +289,8 @@ static int dns_query_candidate_setup_transactions(DnsQueryCandidate *c) {
dns_query_candidate_stop(c);
c->generation++;
if (c->query->question_bypass) {
/* If this is a bypass query, then pass the original query packet along to the transaction */

View File

@@ -10,6 +10,7 @@
typedef struct DnsQueryCandidate {
unsigned n_ref;
int error_code;
uint64_t generation;
DnsQuery *query;
DnsScope *scope;