]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: don't read packet from DnsStream on on_stream_complete() of DnsTransaction
authorLennart Poettering <lennart@poettering.net>
Tue, 4 Dec 2018 19:19:16 +0000 (20:19 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Dec 2018 16:16:29 +0000 (17:16 +0100)
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

index b23ca54ade635527143c3788917aaf250fe1f4c0..e26241754d87b6c0f37e93d33172b19a6a5e0e5e 100644 (file)
@@ -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)
+        if (error != 0) {
+                DnsTransaction *t, *n;
+
+                LIST_FOREACH_SAFE(transactions_by_stream, t, n, s->transactions)
                         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);
+        }
 
-        return r;
+        return 0;
 }
 
 static int dns_stream_on_packet(DnsStream *s) {