1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-13 23:21:08 +03:00

resolved: transaction - close socket when changing server

Close the socket when changing the server in a transaction, in
order for it to be reopened with the right server when we send
the next packet.

This fixes a regression where we could get stuck with a failing
server.
This commit is contained in:
Tom Gundersen 2015-07-25 04:45:26 +02:00
parent 86ad4cd709
commit 647f6aa8fc

View File

@ -308,6 +308,16 @@ static int dns_transaction_open_tcp(DnsTransaction *t) {
return 0; return 0;
} }
static void dns_transaction_next_dns_server(DnsTransaction *t) {
assert(t);
t->server = dns_server_unref(t->server);
t->dns_event_source = sd_event_source_unref(t->dns_event_source);
t->dns_fd = safe_close(t->dns_fd);
dns_scope_next_dns_server(t->scope);
}
void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) { void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
int r; int r;
@ -394,7 +404,7 @@ void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p) {
} }
/* On DNS, couldn't send? Try immediately again, with a new server */ /* On DNS, couldn't send? Try immediately again, with a new server */
dns_scope_next_dns_server(t->scope); dns_transaction_next_dns_server(t);
r = dns_transaction_go(t); r = dns_transaction_go(t);
if (r < 0) { if (r < 0) {
@ -437,7 +447,7 @@ static int on_transaction_timeout(sd_event_source *s, usec_t usec, void *userdat
assert(t); assert(t);
/* Timeout reached? Try again, with a new server */ /* Timeout reached? Try again, with a new server */
dns_scope_next_dns_server(t->scope); dns_transaction_next_dns_server(t);
r = dns_transaction_go(t); r = dns_transaction_go(t);
if (r < 0) if (r < 0)
@ -614,7 +624,7 @@ int dns_transaction_go(DnsTransaction *t) {
} }
/* Couldn't send? Try immediately again, with a new server */ /* Couldn't send? Try immediately again, with a new server */
dns_scope_next_dns_server(t->scope); dns_transaction_next_dns_server(t);
return dns_transaction_go(t); return dns_transaction_go(t);
} }