@@ -48,6 +48,16 @@ static void dns_transaction_close_connection(DnsTransaction *t) {
4848 t -> dns_udp_fd = safe_close (t -> dns_udp_fd );
4949}
5050
51+ static void dns_transaction_stop (DnsTransaction * t ) {
52+ assert (t );
53+
54+ t -> timeout_event_source = sd_event_source_unref (t -> timeout_event_source );
55+ t -> stream = dns_stream_free (t -> stream );
56+
57+ /* Note that we do not drop the UDP socket here, as we want to
58+ * reuse it to repeat the interaction. */
59+ }
60+
5161DnsTransaction * dns_transaction_free (DnsTransaction * t ) {
5262 DnsQueryCandidate * c ;
5363 DnsZoneItem * i ;
@@ -56,8 +66,8 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
5666 if (!t )
5767 return NULL ;
5868
59- sd_event_source_unref (t -> timeout_event_source );
6069 dns_transaction_close_connection (t );
70+ dns_transaction_stop (t );
6171
6272 dns_packet_unref (t -> sent );
6373 dns_transaction_reset_answer (t );
@@ -72,8 +82,6 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
7282 hashmap_remove (t -> scope -> manager -> dns_transactions , UINT_TO_PTR (t -> id ));
7383 }
7484
75- dns_resource_key_unref (t -> key );
76-
7785 while ((c = set_steal_first (t -> notify_query_candidates )))
7886 set_remove (c -> transactions , t );
7987 set_free (t -> notify_query_candidates );
@@ -93,8 +101,9 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
93101 set_free (t -> dnssec_transactions );
94102
95103 dns_answer_unref (t -> validated_keys );
96-
104+ dns_resource_key_unref ( t -> key );
97105 free (t -> key_string );
106+
98107 free (t );
99108 return NULL ;
100109}
@@ -177,16 +186,6 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key)
177186 return 0 ;
178187}
179188
180- static void dns_transaction_stop (DnsTransaction * t ) {
181- assert (t );
182-
183- t -> timeout_event_source = sd_event_source_unref (t -> timeout_event_source );
184- t -> stream = dns_stream_free (t -> stream );
185-
186- /* Note that we do not drop the UDP socket here, as we want to
187- * reuse it to repeat the interaction. */
188- }
189-
190189static void dns_transaction_tentative (DnsTransaction * t , DnsPacket * p ) {
191190 _cleanup_free_ char * pretty = NULL ;
192191 DnsZoneItem * z ;
0 commit comments