summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-transaction.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-07-15 19:22:29 +0200
committerTom Gundersen <teg@jklm.no>2015-07-27 20:13:11 +0200
commit0db643664cf37111be163c0c64ccd66b519daf34 (patch)
treef4d503859c188cb4b5df8837984038bd9ac2682a /src/resolve/resolved-dns-transaction.c
parent647f6aa8fcc50a5bb18f188e4d11d568ed307811 (diff)
resolved: transaction - move DNS UDP socket creation to the scope
With access to the server when creating the socket, we can connect() to the server and hence simplify message sending and receiving in follow-up patches.
Diffstat (limited to 'src/resolve/resolved-dns-transaction.c')
-rw-r--r--src/resolve/resolved-dns-transaction.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index 5540cd386e..5580e376c0 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -663,7 +663,8 @@ static int on_dns_packet(sd_event_source *s, int fd, uint32_t revents, void *use
return 0;
}
-int transaction_dns_fd(DnsTransaction *t) {
+int transaction_dns_fd(DnsTransaction *t, DnsServer **_server) {
+ DnsServer *server;
int r;
assert(t);
@@ -673,14 +674,17 @@ int transaction_dns_fd(DnsTransaction *t) {
if (t->dns_fd >= 0)
return t->dns_fd;
- t->dns_fd = socket(t->scope->family, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
+ t->dns_fd = dns_scope_udp_dns_socket(t->scope, &server);
if (t->dns_fd < 0)
- return -errno;
+ return t->dns_fd;
r = sd_event_add_io(t->scope->manager->event, &t->dns_event_source, t->dns_fd, EPOLLIN, on_dns_packet, t);
if (r < 0)
goto fail;
+ if (_server)
+ *_server = server;
+
return t->dns_fd;
fail: