]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: implicitly disconnect a stream from its server when a stream is closed
authorLennart Poettering <lennart@poettering.net>
Tue, 4 Dec 2018 21:17:49 +0000 (22:17 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 7 Dec 2018 16:22:59 +0000 (17:22 +0100)
Previously, the callback function did this, but let's do this in the
caller instead, to make this more robust, and use our new helper
function for it.

src/resolve/resolved-dns-stream.c
src/resolve/resolved-dns-transaction.c

index 8bca32d2532aa596e8158c0fd0e3ed52bc7bb803..aee339a4c8d5679349101eccbed4d01e684360ec 100644 (file)
@@ -64,6 +64,8 @@ static int dns_stream_complete(DnsStream *s, int error) {
 #endif
                 dns_stream_stop(s);
 
+        dns_stream_detach(s);
+
         if (s->complete)
                 s->complete(s, error);
         else /* the default action if no completion function is set is to close the stream */
index f29a68e444acac311cd55e1a85b4d0a71a577f3a..cc748ac95eac03118e0c5935e26727a8c1cb3e86 100644 (file)
@@ -503,11 +503,7 @@ 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;
-
-        /* Do not let new transactions use this stream */
-        if (s->server && s->server->stream == s)
-                p = TAKE_PTR(s->server->stream);
+        assert(s);
 
         if (ERRNO_IS_DISCONNECT(error) && s->protocol != DNS_PROTOCOL_LLMNR) {
                 log_debug_errno(error, "Connection failure for DNS TCP stream: %m");