Skip to content

Commit cbe4216

Browse files
committed
resolved: remember explicitly whether we already tried a stream connection
On LLMNR we never want to retry stream connections (since local TCP connections should work, and we don't want to unnecessarily delay operation), explicitly remember whether we already tried one, instead of deriving this from a still stored stream object. This way, we can free the stream early, without forgetting that we tried it.
1 parent 598f44b commit cbe4216

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/resolve/resolved-dns-transaction.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ static int dns_transaction_open_tcp(DnsTransaction *t) {
421421
if (t->scope->link)
422422
t->stream->ifindex = t->scope->link->ifindex;
423423

424+
t->tried_stream = true;
425+
424426
return 0;
425427
}
426428

@@ -826,21 +828,18 @@ static usec_t transaction_get_resend_timeout(DnsTransaction *t) {
826828
}
827829

828830
static int dns_transaction_prepare(DnsTransaction *t, usec_t ts) {
829-
bool had_stream;
830831
int r;
831832

832833
assert(t);
833834

834-
had_stream = !!t->stream;
835-
836835
dns_transaction_stop(t);
837836

838837
if (t->n_attempts >= TRANSACTION_ATTEMPTS_MAX(t->scope->protocol)) {
839838
dns_transaction_complete(t, DNS_TRANSACTION_ATTEMPTS_MAX_REACHED);
840839
return 0;
841840
}
842841

843-
if (t->scope->protocol == DNS_PROTOCOL_LLMNR && had_stream) {
842+
if (t->scope->protocol == DNS_PROTOCOL_LLMNR && t->tried_stream) {
844843
/* If we already tried via a stream, then we don't
845844
* retry on LLMNR. See RFC 4795, Section 2.7. */
846845
dns_transaction_complete(t, DNS_TRANSACTION_ATTEMPTS_MAX_REACHED);

src/resolve/resolved-dns-transaction.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ struct DnsTransaction {
6969

7070
uint16_t id;
7171

72+
bool tried_stream:1;
73+
7274
bool initial_jitter_scheduled:1;
7375
bool initial_jitter_elapsed:1;
7476

0 commit comments

Comments
 (0)