]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: reuse dns_transaction_stop() when destructing transaction objects
authorLennart Poettering <lennart@poettering.net>
Sat, 26 Dec 2015 17:48:37 +0000 (18:48 +0100)
committerLennart Poettering <lennart@poettering.net>
Sun, 27 Dec 2015 00:41:40 +0000 (01:41 +0100)
src/resolve/resolved-dns-transaction.c

index cf7dae0e692053049103f85a6d89c8d2937fe94c..e708559137d69d16f551197f21086b8bcf736c26 100644 (file)
@@ -48,6 +48,16 @@ static void dns_transaction_close_connection(DnsTransaction *t) {
         t->dns_udp_fd = safe_close(t->dns_udp_fd);
 }
 
+static void dns_transaction_stop(DnsTransaction *t) {
+        assert(t);
+
+        t->timeout_event_source = sd_event_source_unref(t->timeout_event_source);
+        t->stream = dns_stream_free(t->stream);
+
+        /* Note that we do not drop the UDP socket here, as we want to
+         * reuse it to repeat the interaction. */
+}
+
 DnsTransaction* dns_transaction_free(DnsTransaction *t) {
         DnsQueryCandidate *c;
         DnsZoneItem *i;
@@ -56,8 +66,8 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
         if (!t)
                 return NULL;
 
-        sd_event_source_unref(t->timeout_event_source);
         dns_transaction_close_connection(t);
+        dns_transaction_stop(t);
 
         dns_packet_unref(t->sent);
         dns_transaction_reset_answer(t);
@@ -72,8 +82,6 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
                         hashmap_remove(t->scope->manager->dns_transactions, UINT_TO_PTR(t->id));
         }
 
-        dns_resource_key_unref(t->key);
-
         while ((c = set_steal_first(t->notify_query_candidates)))
                 set_remove(c->transactions, t);
         set_free(t->notify_query_candidates);
@@ -93,8 +101,9 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
         set_free(t->dnssec_transactions);
 
         dns_answer_unref(t->validated_keys);
-
+        dns_resource_key_unref(t->key);
         free(t->key_string);
+
         free(t);
         return NULL;
 }
@@ -177,16 +186,6 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key)
         return 0;
 }
 
-static void dns_transaction_stop(DnsTransaction *t) {
-        assert(t);
-
-        t->timeout_event_source = sd_event_source_unref(t->timeout_event_source);
-        t->stream = dns_stream_free(t->stream);
-
-        /* Note that we do not drop the UDP socket here, as we want to
-         * reuse it to repeat the interaction. */
-}
-
 static void dns_transaction_tentative(DnsTransaction *t, DnsPacket *p) {
         _cleanup_free_ char *pretty = NULL;
         DnsZoneItem *z;