File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,8 @@ static int dns_query_candidate_go(DnsQueryCandidate *c) {
199199 /* Let's keep a reference to the query while we're operating */
200200 keep_c = dns_query_candidate_ref (c );
201201
202+ uint64_t generation = c -> generation ;
203+
202204 /* Start the transactions that are not started yet */
203205 SET_FOREACH (t , c -> transactions ) {
204206 if (t -> state != DNS_TRANSACTION_NULL )
@@ -208,6 +210,13 @@ static int dns_query_candidate_go(DnsQueryCandidate *c) {
208210 if (r < 0 )
209211 return r ;
210212
213+ if (c -> generation != generation )
214+ /* The transaction has been completed, and dns_transaction_complete() ->
215+ * dns_query_candidate_notify() has been already called. Moreover, the query
216+ * candidate has been regenerated, and the query should be already restarted.
217+ * Let's exit from the loop now. */
218+ return 0 ;
219+
211220 n ++ ;
212221 }
213222
@@ -271,6 +280,8 @@ static int dns_query_candidate_setup_transactions(DnsQueryCandidate *c) {
271280
272281 dns_query_candidate_stop (c );
273282
283+ c -> generation ++ ;
284+
274285 if (c -> query -> question_bypass ) {
275286 /* If this is a bypass query, then pass the original query packet along to the transaction */
276287
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ typedef struct DnsStubListenerExtra DnsStubListenerExtra;
1818struct DnsQueryCandidate {
1919 unsigned n_ref ;
2020 int error_code ;
21+ uint64_t generation ;
2122
2223 DnsQuery * query ;
2324 DnsScope * scope ;
You can’t perform that action at this time.
0 commit comments