From 97d5d9055f0cdfdfee901452848a519b49896382 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 4 Dec 2018 20:19:16 +0100 Subject: [PATCH] resolved: don't read packet from DnsStream on on_stream_complete() of DnsTransaction We register an on_packet() handler anyway, which is called first. There's hence no need to check in on_stream_complete() again, as it is already taken by that time. --- src/resolve/resolved-dns-transaction.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index b23ca54ade..e26241754d 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -504,8 +504,6 @@ static int dns_transaction_on_stream_packet(DnsTransaction *t, DnsPacket *p) { static int on_stream_complete(DnsStream *s, int error) { _cleanup_(dns_stream_unrefp) DnsStream *p = NULL; - DnsTransaction *t, *n; - int r = 0; /* Do not let new transactions use this stream */ if (s->server && s->server->stream == s) @@ -515,19 +513,21 @@ static int on_stream_complete(DnsStream *s, int error) { log_debug_errno(error, "Connection failure for DNS TCP stream: %m"); if (s->transactions) { + DnsTransaction *t; + t = s->transactions; dns_server_packet_lost(t->server, IPPROTO_TCP, t->current_feature_level); } } - LIST_FOREACH_SAFE(transactions_by_stream, t, n, s->transactions) - if (error != 0) - on_transaction_stream_error(t, error); - else if (DNS_PACKET_ID(s->read_packet) == t->id) - /* As each transaction have a unique id the return code is only set once */ - r = dns_transaction_on_stream_packet(t, s->read_packet); + if (error != 0) { + DnsTransaction *t, *n; - return r; + LIST_FOREACH_SAFE(transactions_by_stream, t, n, s->transactions) + on_transaction_stream_error(t, error); + } + + return 0; } static int dns_stream_on_packet(DnsStream *s) {