From 7172e4ee1ea27c33f8d125132a7498f1182ea784 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 4 Dec 2018 22:17:49 +0100 Subject: [PATCH] resolved: implicitly disconnect a stream from its server when a stream is closed 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 | 2 ++ src/resolve/resolved-dns-transaction.c | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index 8bca32d253..aee339a4c8 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -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 */ diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c index f29a68e444..cc748ac95e 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c @@ -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");