[systemd-commits] 2 commits - src/libsystemd src/systemd

Tom Gundersen tomegun at kemper.freedesktop.org
Tue Jan 14 04:33:42 PST 2014


 src/libsystemd/resolv-util.h |   12 -
 src/libsystemd/sd-resolv.c   |  314 +++++++++++++++++++++----------------------
 src/libsystemd/test-resolv.c |   40 ++---
 src/systemd/sd-resolv.h      |   94 ++++++------
 4 files changed, 230 insertions(+), 230 deletions(-)

New commits:
commit 12f404c4d1dc31a54013646473249b4644fc23e7
Author: Daniel Buch <boogiewasthere at gmail.com>
Date:   Tue Jan 14 11:46:49 2014 +0100

    sd-resolv: rename old asyncns variables

diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c
index a4e7cde..aa97ef7 100644
--- a/src/libsystemd/sd-resolv.c
+++ b/src/libsystemd/sd-resolv.c
@@ -84,7 +84,7 @@ struct sd_resolv {
 };
 
 struct sd_resolv_query {
-        sd_resolv_t *asyncns;
+        sd_resolv_t *resolv;
         int done;
         unsigned id;
         query_type_t type;
@@ -383,18 +383,18 @@ static int handle_request(int out_fd, const packet_t *packet, size_t length) {
 }
 
 static void* thread_worker(void *p) {
-        sd_resolv_t *asyncns = p;
+        sd_resolv_t *resolv = p;
         sigset_t fullset;
 
         /* No signals in this thread please */
         sigfillset(&fullset);
         pthread_sigmask(SIG_BLOCK, &fullset, NULL);
 
-        while (!asyncns->dead) {
+        while (!resolv->dead) {
                 packet_t buf[BUFSIZE/sizeof(packet_t) + 1];
                 ssize_t length;
 
-                length = recv(asyncns->fds[REQUEST_RECV_FD], buf, sizeof(buf), 0);
+                length = recv(resolv->fds[REQUEST_RECV_FD], buf, sizeof(buf), 0);
 
                 if (length <= 0) {
                         if (length < 0 && (errno == EAGAIN || errno == EINTR))
@@ -402,50 +402,50 @@ static void* thread_worker(void *p) {
                         break;
                 }
 
-                if (asyncns->dead)
+                if (resolv->dead)
                         break;
 
-                if (handle_request(asyncns->fds[RESPONSE_SEND_FD], buf, (size_t) length) < 0)
+                if (handle_request(resolv->fds[RESPONSE_SEND_FD], buf, (size_t) length) < 0)
                         break;
         }
 
-        send_died(asyncns->fds[RESPONSE_SEND_FD]);
+        send_died(resolv->fds[RESPONSE_SEND_FD]);
 
         return NULL;
 }
 
 sd_resolv_t* sd_resolv_new(unsigned n_proc) {
         int i;
-        sd_resolv_t *asyncns = NULL;
+        sd_resolv_t *resolv = NULL;
 
         assert(n_proc >= 1);
 
         if (n_proc > MAX_WORKERS)
                 n_proc = MAX_WORKERS;
 
-        asyncns = malloc(sizeof(sd_resolv_t));
-        if (!asyncns) {
+        resolv = malloc(sizeof(sd_resolv_t));
+        if (!resolv) {
                 errno = ENOMEM;
                 goto fail;
         }
 
-        asyncns->dead = 0;
-        asyncns->valid_workers = 0;
+        resolv->dead = 0;
+        resolv->valid_workers = 0;
 
         for (i = 0; i < MESSAGE_FD_MAX; i++)
-                asyncns->fds[i] = -1;
+                resolv->fds[i] = -1;
 
-        memset(asyncns->queries, 0, sizeof(asyncns->queries));
+        memset(resolv->queries, 0, sizeof(resolv->queries));
 
 #ifdef SOCK_CLOEXEC
-        if (socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, asyncns->fds) < 0 ||
-                        socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, asyncns->fds+2) < 0) {
+        if (socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, resolv->fds) < 0 ||
+                        socketpair(PF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, resolv->fds+2) < 0) {
 
                 /* Try again, without SOCK_CLOEXEC */
                 if (errno == EINVAL) {
 #endif
-                        if (socketpair(PF_UNIX, SOCK_DGRAM, 0, asyncns->fds) < 0 ||
-                                        socketpair(PF_UNIX, SOCK_DGRAM, 0, asyncns->fds+2) < 0)
+                        if (socketpair(PF_UNIX, SOCK_DGRAM, 0, resolv->fds) < 0 ||
+                                        socketpair(PF_UNIX, SOCK_DGRAM, 0, resolv->fds+2) < 0)
                                 goto fail;
 #ifdef SOCK_CLOEXEC
                 } else
@@ -454,42 +454,42 @@ sd_resolv_t* sd_resolv_new(unsigned n_proc) {
 #endif
 
         for (i = 0; i < MESSAGE_FD_MAX; i++)
-                fd_cloexec(asyncns->fds[i], true);
+                fd_cloexec(resolv->fds[i], true);
 
-        for (asyncns->valid_workers = 0; asyncns->valid_workers < n_proc; asyncns->valid_workers++) {
+        for (resolv->valid_workers = 0; resolv->valid_workers < n_proc; resolv->valid_workers++) {
                 int r;
-                r = pthread_create(&asyncns->workers[asyncns->valid_workers], NULL, thread_worker, asyncns);
+                r = pthread_create(&resolv->workers[resolv->valid_workers], NULL, thread_worker, resolv);
                 if (r) {
                         errno = r;
                         goto fail;
                 }
         }
 
-        asyncns->current_index = asyncns->current_id = 0;
-        asyncns->done_head = asyncns->done_tail = NULL;
-        asyncns->n_queries = 0;
+        resolv->current_index = resolv->current_id = 0;
+        resolv->done_head = resolv->done_tail = NULL;
+        resolv->n_queries = 0;
 
-        fd_nonblock(asyncns->fds[RESPONSE_RECV_FD], true);
+        fd_nonblock(resolv->fds[RESPONSE_RECV_FD], true);
 
-        return asyncns;
+        return resolv;
 
 fail:
-        if (asyncns)
-                sd_resolv_free(asyncns);
+        if (resolv)
+                sd_resolv_free(resolv);
 
         return NULL;
 }
 
-void sd_resolv_free(sd_resolv_t *asyncns) {
+void sd_resolv_free(sd_resolv_t *resolv) {
         int i;
         int saved_errno = errno;
         unsigned p;
 
-        assert(asyncns);
+        assert(resolv);
 
-        asyncns->dead = 1;
+        resolv->dead = 1;
 
-        if (asyncns->fds[REQUEST_SEND_FD] >= 0) {
+        if (resolv->fds[REQUEST_SEND_FD] >= 0) {
                 rheader_t req = {};
 
                 req.type = REQUEST_TERMINATE;
@@ -497,43 +497,43 @@ void sd_resolv_free(sd_resolv_t *asyncns) {
                 req.id = 0;
 
                 /* Send one termination packet for each worker */
-                for (p = 0; p < asyncns->valid_workers; p++)
-                        send(asyncns->fds[REQUEST_SEND_FD], &req, req.length, MSG_NOSIGNAL);
+                for (p = 0; p < resolv->valid_workers; p++)
+                        send(resolv->fds[REQUEST_SEND_FD], &req, req.length, MSG_NOSIGNAL);
         }
 
         /* Now terminate them and wait until they are gone. */
-        for (p = 0; p < asyncns->valid_workers; p++) {
+        for (p = 0; p < resolv->valid_workers; p++) {
                 for (;;) {
-                        if (pthread_join(asyncns->workers[p], NULL) != EINTR)
+                        if (pthread_join(resolv->workers[p], NULL) != EINTR)
                                 break;
                 }
         }
 
         /* Close all communication channels */
         for (i = 0; i < MESSAGE_FD_MAX; i++)
-                if (asyncns->fds[i] >= 0)
-                        close(asyncns->fds[i]);
+                if (resolv->fds[i] >= 0)
+                        close(resolv->fds[i]);
 
         for (p = 0; p < MAX_QUERIES; p++)
-                if (asyncns->queries[p])
-                        sd_resolv_cancel(asyncns, asyncns->queries[p]);
+                if (resolv->queries[p])
+                        sd_resolv_cancel(resolv, resolv->queries[p]);
 
-        free(asyncns);
+        free(resolv);
 
         errno = saved_errno;
 }
 
-int sd_resolv_fd(sd_resolv_t *asyncns) {
-        assert(asyncns);
+int sd_resolv_fd(sd_resolv_t *resolv) {
+        assert(resolv);
 
-        return asyncns->fds[RESPONSE_RECV_FD];
+        return resolv->fds[RESPONSE_RECV_FD];
 }
 
-static sd_resolv_query_t *lookup_query(sd_resolv_t *asyncns, unsigned id) {
+static sd_resolv_query_t *lookup_query(sd_resolv_t *resolv, unsigned id) {
         sd_resolv_query_t *q;
-        assert(asyncns);
+        assert(resolv);
 
-        q = asyncns->queries[id % MAX_QUERIES];
+        q = resolv->queries[id % MAX_QUERIES];
         if (q)
                 if (q->id == id)
                         return q;
@@ -541,19 +541,19 @@ static sd_resolv_query_t *lookup_query(sd_resolv_t *asyncns, unsigned id) {
         return NULL;
 }
 
-static void complete_query(sd_resolv_t *asyncns, sd_resolv_query_t *q) {
-        assert(asyncns);
+static void complete_query(sd_resolv_t *resolv, sd_resolv_query_t *q) {
+        assert(resolv);
         assert(q);
         assert(!q->done);
 
         q->done = 1;
 
-        if ((q->done_prev = asyncns->done_tail))
-                asyncns->done_tail->done_next = q;
+        if ((q->done_prev = resolv->done_tail))
+                resolv->done_tail->done_next = q;
         else
-                asyncns->done_head = q;
+                resolv->done_head = q;
 
-        asyncns->done_tail = q;
+        resolv->done_tail = q;
         q->done_next = NULL;
 }
 
@@ -613,11 +613,11 @@ fail:
         return NULL;
 }
 
-static int handle_response(sd_resolv_t *asyncns, const packet_t *packet, size_t length) {
+static int handle_response(sd_resolv_t *resolv, const packet_t *packet, size_t length) {
         const rheader_t *resp;
         sd_resolv_query_t *q;
 
-        assert(asyncns);
+        assert(resolv);
 
         resp = &packet->rheader;
         assert(resp);
@@ -625,11 +625,11 @@ static int handle_response(sd_resolv_t *asyncns, const packet_t *packet, size_t
         assert(length == resp->length);
 
         if (resp->type == RESPONSE_DIED) {
-                asyncns->dead = 1;
+                resolv->dead = 1;
                 return 0;
         }
 
-        q = lookup_query(asyncns, resp->id);
+        q = lookup_query(resolv, resp->id);
         if (!q)
                 return 0;
 
@@ -666,7 +666,7 @@ static int handle_response(sd_resolv_t *asyncns, const packet_t *packet, size_t
                         prev = ai;
                 }
 
-                complete_query(asyncns, q);
+                complete_query(resolv, q);
                 break;
         }
 
@@ -688,7 +688,7 @@ static int handle_response(sd_resolv_t *asyncns, const packet_t *packet, size_t
                         if (!(q->serv = strndup((const char*) ni_resp + sizeof(nameinfo_response_t) + ni_resp->hostlen, ni_resp->servlen-1)))
                                 q->ret = EAI_MEMORY;
 
-                complete_query(asyncns, q);
+                complete_query(resolv, q);
                 break;
         }
 
@@ -710,7 +710,7 @@ static int handle_response(sd_resolv_t *asyncns, const packet_t *packet, size_t
                                 memcpy(q->serv, (const char *)resp + sizeof(res_response_t), res_resp->ret);
                 }
 
-                complete_query(asyncns, q);
+                complete_query(resolv, q);
                 break;
         }
 
@@ -721,20 +721,20 @@ static int handle_response(sd_resolv_t *asyncns, const packet_t *packet, size_t
         return 0;
 }
 
-int sd_resolv_wait(sd_resolv_t *asyncns, int block) {
+int sd_resolv_wait(sd_resolv_t *resolv, int block) {
         int handled = 0;
-        assert(asyncns);
+        assert(resolv);
 
         for (;;) {
                 packet_t buf[BUFSIZE/sizeof(packet_t) + 1];
                 ssize_t l;
 
-                if (asyncns->dead) {
+                if (resolv->dead) {
                         errno = ECHILD;
                         return -1;
                 }
 
-                l = recv(asyncns->fds[RESPONSE_RECV_FD], buf, sizeof(buf), 0);
+                l = recv(resolv->fds[RESPONSE_RECV_FD], buf, sizeof(buf), 0);
                 if (l < 0) {
                         fd_set fds;
 
@@ -745,49 +745,49 @@ int sd_resolv_wait(sd_resolv_t *asyncns, int block) {
                                 return 0;
 
                         FD_ZERO(&fds);
-                        FD_SET(asyncns->fds[RESPONSE_RECV_FD], &fds);
+                        FD_SET(resolv->fds[RESPONSE_RECV_FD], &fds);
 
-                        if (select(asyncns->fds[RESPONSE_RECV_FD]+1, &fds, NULL, NULL, NULL) < 0)
+                        if (select(resolv->fds[RESPONSE_RECV_FD]+1, &fds, NULL, NULL, NULL) < 0)
                                 return -1;
 
                         continue;
                 }
 
-                if (handle_response(asyncns, buf, (size_t) l) < 0)
+                if (handle_response(resolv, buf, (size_t) l) < 0)
                         return -1;
 
                 handled = 1;
         }
 }
 
-static sd_resolv_query_t *alloc_query(sd_resolv_t *asyncns) {
+static sd_resolv_query_t *alloc_query(sd_resolv_t *resolv) {
         sd_resolv_query_t *q;
-        assert(asyncns);
+        assert(resolv);
 
-        if (asyncns->n_queries >= MAX_QUERIES) {
+        if (resolv->n_queries >= MAX_QUERIES) {
                 errno = ENOMEM;
                 return NULL;
         }
 
-        while (asyncns->queries[asyncns->current_index]) {
-                asyncns->current_index++;
-                asyncns->current_id++;
+        while (resolv->queries[resolv->current_index]) {
+                resolv->current_index++;
+                resolv->current_id++;
 
-                while (asyncns->current_index >= MAX_QUERIES)
-                        asyncns->current_index -= MAX_QUERIES;
+                while (resolv->current_index >= MAX_QUERIES)
+                        resolv->current_index -= MAX_QUERIES;
         }
 
-        q = asyncns->queries[asyncns->current_index] = malloc(sizeof(sd_resolv_query_t));
+        q = resolv->queries[resolv->current_index] = malloc(sizeof(sd_resolv_query_t));
         if (!q) {
                 errno = ENOMEM;
                 return NULL;
         }
 
-        asyncns->n_queries++;
+        resolv->n_queries++;
 
-        q->asyncns = asyncns;
+        q->resolv = resolv;
         q->done = 0;
-        q->id = asyncns->current_id;
+        q->id = resolv->current_id;
         q->done_next = q->done_prev = NULL;
         q->ret = 0;
         q->_errno = 0;
@@ -799,19 +799,19 @@ static sd_resolv_query_t *alloc_query(sd_resolv_t *asyncns) {
         return q;
 }
 
-sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *asyncns, const char *node, const char *service, const struct addrinfo *hints) {
+sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *resolv, const char *node, const char *service, const struct addrinfo *hints) {
         addrinfo_request_t data[BUFSIZE/sizeof(addrinfo_request_t) + 1] = {};
         addrinfo_request_t *req = data;
         sd_resolv_query_t *q;
-        assert(asyncns);
+        assert(resolv);
         assert(node || service);
 
-        if (asyncns->dead) {
+        if (resolv->dead) {
                 errno = ECHILD;
                 return NULL;
         }
 
-        q = alloc_query(asyncns);
+        q = alloc_query(resolv);
         if (!q)
                 return NULL;
 
@@ -840,26 +840,26 @@ sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *asyncns, const char *node,
         if (service)
                 strcpy((char*) req + sizeof(addrinfo_request_t) + req->node_len, service);
 
-        if (send(asyncns->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
+        if (send(resolv->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
                 goto fail;
 
         return q;
 
 fail:
         if (q)
-                sd_resolv_cancel(asyncns, q);
+                sd_resolv_cancel(resolv, q);
 
         return NULL;
 }
 
-int sd_resolv_getaddrinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, struct addrinfo **ret_res) {
+int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv, sd_resolv_query_t* q, struct addrinfo **ret_res) {
         int ret;
-        assert(asyncns);
+        assert(resolv);
         assert(q);
-        assert(q->asyncns == asyncns);
+        assert(q->resolv == resolv);
         assert(q->type == REQUEST_ADDRINFO);
 
-        if (asyncns->dead) {
+        if (resolv->dead) {
                 errno = ECHILD;
                 return EAI_SYSTEM;
         }
@@ -878,26 +878,26 @@ int sd_resolv_getaddrinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, struc
         if (ret != 0)
                 h_errno = q->_h_errno;
 
-        sd_resolv_cancel(asyncns, q);
+        sd_resolv_cancel(resolv, q);
 
         return ret;
 }
 
-sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
+sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *resolv, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
         nameinfo_request_t data[BUFSIZE/sizeof(nameinfo_request_t) + 1] = {};
         nameinfo_request_t *req = data;
         sd_resolv_query_t *q;
 
-        assert(asyncns);
+        assert(resolv);
         assert(sa);
         assert(salen > 0);
 
-        if (asyncns->dead) {
+        if (resolv->dead) {
                 errno = ECHILD;
                 return NULL;
         }
 
-        q = alloc_query(asyncns);
+        q = alloc_query(resolv);
         if (!q)
                 return NULL;
 
@@ -917,28 +917,28 @@ sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *asyncns, const struct sock
 
         memcpy((uint8_t*) req + sizeof(nameinfo_request_t), sa, salen);
 
-        if (send(asyncns->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
+        if (send(resolv->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
                 goto fail;
 
         return q;
 
 fail:
         if (q)
-                sd_resolv_cancel(asyncns, q);
+                sd_resolv_cancel(resolv, q);
 
         return NULL;
 }
 
-int sd_resolv_getnameinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
+int sd_resolv_getnameinfo_done(sd_resolv_t *resolv, sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
         int ret;
-        assert(asyncns);
+        assert(resolv);
         assert(q);
-        assert(q->asyncns == asyncns);
+        assert(q->resolv == resolv);
         assert(q->type == REQUEST_NAMEINFO);
         assert(!ret_host || hostlen);
         assert(!ret_serv || servlen);
 
-        if (asyncns->dead) {
+        if (resolv->dead) {
                 errno = ECHILD;
                 return EAI_SYSTEM;
         }
@@ -964,25 +964,25 @@ int sd_resolv_getnameinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, char
         if (ret != 0)
                 h_errno = q->_h_errno;
 
-        sd_resolv_cancel(asyncns, q);
+        sd_resolv_cancel(resolv, q);
 
         return ret;
 }
 
-static sd_resolv_query_t * asyncns_res(sd_resolv_t *asyncns, query_type_t qtype, const char *dname, int class, int type) {
+static sd_resolv_query_t * resolv_res(sd_resolv_t *resolv, query_type_t qtype, const char *dname, int class, int type) {
         res_request_t data[BUFSIZE/sizeof(res_request_t) + 1];
         res_request_t *req = data;
         sd_resolv_query_t *q;
 
-        assert(asyncns);
+        assert(resolv);
         assert(dname);
 
-        if (asyncns->dead) {
+        if (resolv->dead) {
                 errno = ECHILD;
                 return NULL;
         }
 
-        q = alloc_query(asyncns);
+        q = alloc_query(resolv);
         if (!q)
                 return NULL;
 
@@ -1002,35 +1002,35 @@ static sd_resolv_query_t * asyncns_res(sd_resolv_t *asyncns, query_type_t qtype,
 
         strcpy((char*) req + sizeof(res_request_t), dname);
 
-        if (send(asyncns->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
+        if (send(resolv->fds[REQUEST_SEND_FD], req, req->header.length, MSG_NOSIGNAL) < 0)
                 goto fail;
 
         return q;
 
 fail:
         if (q)
-                sd_resolv_cancel(asyncns, q);
+                sd_resolv_cancel(resolv, q);
 
         return NULL;
 }
 
-sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *asyncns, const char *dname, int class, int type) {
-        return asyncns_res(asyncns, REQUEST_RES_QUERY, dname, class, type);
+sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *resolv, const char *dname, int class, int type) {
+        return resolv_res(resolv, REQUEST_RES_QUERY, dname, class, type);
 }
 
-sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *asyncns, const char *dname, int class, int type) {
-        return asyncns_res(asyncns, REQUEST_RES_SEARCH, dname, class, type);
+sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *resolv, const char *dname, int class, int type) {
+        return resolv_res(resolv, REQUEST_RES_SEARCH, dname, class, type);
 }
 
-int sd_resolv_res_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, unsigned char **answer) {
+int sd_resolv_res_done(sd_resolv_t *resolv, sd_resolv_query_t* q, unsigned char **answer) {
         int ret;
-        assert(asyncns);
+        assert(resolv);
         assert(q);
-        assert(q->asyncns == asyncns);
+        assert(q->resolv == resolv);
         assert(q->type == REQUEST_RES_QUERY || q->type == REQUEST_RES_SEARCH);
         assert(answer);
 
-        if (asyncns->dead) {
+        if (resolv->dead) {
                 errno = ECHILD;
                 return -ECHILD;
         }
@@ -1050,52 +1050,52 @@ int sd_resolv_res_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, unsigned char
                 h_errno = q->_h_errno;
         }
 
-        sd_resolv_cancel(asyncns, q);
+        sd_resolv_cancel(resolv, q);
 
         return ret < 0 ? -errno : ret;
 }
 
-sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *asyncns) {
-        assert(asyncns);
-        return asyncns->done_head;
+sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *resolv) {
+        assert(resolv);
+        return resolv->done_head;
 }
 
-int sd_resolv_getnqueries(sd_resolv_t *asyncns) {
-        assert(asyncns);
-        return asyncns->n_queries;
+int sd_resolv_getnqueries(sd_resolv_t *resolv) {
+        assert(resolv);
+        return resolv->n_queries;
 }
 
-void sd_resolv_cancel(sd_resolv_t *asyncns, sd_resolv_query_t* q) {
+void sd_resolv_cancel(sd_resolv_t *resolv, sd_resolv_query_t* q) {
         int i;
         int saved_errno = errno;
 
-        assert(asyncns);
+        assert(resolv);
         assert(q);
-        assert(q->asyncns == asyncns);
-        assert(asyncns->n_queries > 0);
+        assert(q->resolv == resolv);
+        assert(resolv->n_queries > 0);
 
         if (q->done) {
 
                 if (q->done_prev)
                         q->done_prev->done_next = q->done_next;
                 else
-                        asyncns->done_head = q->done_next;
+                        resolv->done_head = q->done_next;
 
                 if (q->done_next)
                         q->done_next->done_prev = q->done_prev;
                 else
-                        asyncns->done_tail = q->done_prev;
+                        resolv->done_tail = q->done_prev;
         }
 
         i = q->id % MAX_QUERIES;
-        assert(asyncns->queries[i] == q);
-        asyncns->queries[i] = NULL;
+        assert(resolv->queries[i] == q);
+        resolv->queries[i] = NULL;
 
         sd_resolv_freeaddrinfo(q->addrinfo);
         free(q->host);
         free(q->serv);
 
-        asyncns->n_queries--;
+        resolv->n_queries--;
         free(q);
 
         errno = saved_errno;
@@ -1123,7 +1123,7 @@ void sd_resolv_freeanswer(unsigned char *answer) {
         if (!answer)
                 return;
 
-        /* Please note that this function is new in libasyncns 0.4. In
+        /* Please note that this function is new in libresolv 0.4. In
          * older versions you were supposed to free the answer directly
          * with free(). Hence, if this function is changed to do more than
          * just a simple free() this must be considered ABI/API breakage! */
@@ -1133,26 +1133,26 @@ void sd_resolv_freeanswer(unsigned char *answer) {
         errno = saved_errno;
 }
 
-int sd_resolv_isdone(sd_resolv_t *asyncns, sd_resolv_query_t*q) {
-        assert(asyncns);
+int sd_resolv_isdone(sd_resolv_t *resolv, sd_resolv_query_t*q) {
+        assert(resolv);
         assert(q);
-        assert(q->asyncns == asyncns);
+        assert(q->resolv == resolv);
 
         return q->done;
 }
 
-void sd_resolv_setuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q, void *userdata) {
+void sd_resolv_setuserdata(sd_resolv_t *resolv, sd_resolv_query_t *q, void *userdata) {
         assert(q);
-        assert(asyncns);
-        assert(q->asyncns = asyncns);
+        assert(resolv);
+        assert(q->resolv = resolv);
 
         q->userdata = userdata;
 }
 
-void* sd_resolv_getuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q) {
+void* sd_resolv_getuserdata(sd_resolv_t *resolv, sd_resolv_query_t *q) {
         assert(q);
-        assert(asyncns);
-        assert(q->asyncns = asyncns);
+        assert(resolv);
+        assert(q->resolv = resolv);
 
         return q->userdata;
 }
diff --git a/src/libsystemd/test-resolv.c b/src/libsystemd/test-resolv.c
index aa26931..5baef96 100644
--- a/src/libsystemd/test-resolv.c
+++ b/src/libsystemd/test-resolv.c
@@ -37,7 +37,7 @@
 
 int main(int argc, char *argv[]) {
         int r = 1, ret;
-        _cleanup_resolv_free_ sd_resolv_t *asyncns = NULL;
+        _cleanup_resolv_free_ sd_resolv_t *resolv = NULL;
         _cleanup_resolv_addrinfo_free_ struct addrinfo *ai = NULL;
         _cleanup_resolv_answer_free_ unsigned char *srv = NULL;
         sd_resolv_query_t *q1, *q2, *q3;
@@ -47,15 +47,15 @@ int main(int argc, char *argv[]) {
 
         signal(SIGCHLD, SIG_IGN);
 
-        asyncns = sd_resolv_new(2);
-        if (!asyncns)
+        resolv = sd_resolv_new(2);
+        if (!resolv)
                 log_oom();
 
         /* Make a name -> address query */
         hints.ai_family = PF_UNSPEC;
         hints.ai_socktype = SOCK_STREAM;
 
-        q1 = sd_resolv_getaddrinfo(asyncns, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints);
+        q1 = sd_resolv_getaddrinfo(resolv, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints);
         if (!q1)
                 fprintf(stderr, "sd_resolv_getaddrinfo(): %s\n", strerror(errno));
 
@@ -64,25 +64,25 @@ int main(int argc, char *argv[]) {
         sa.sin_addr.s_addr = inet_addr(argc >= 3 ? argv[2] : "193.99.144.71");
         sa.sin_port = htons(80);
 
-        q2 = sd_resolv_getnameinfo(asyncns, (struct sockaddr*) &sa, sizeof(sa), 0, 1, 1);
+        q2 = sd_resolv_getnameinfo(resolv, (struct sockaddr*) &sa, sizeof(sa), 0, 1, 1);
         if (!q2)
                 fprintf(stderr, "sd_resolv_getnameinfo(): %s\n", strerror(errno));
 
         /* Make a res_query() call */
-        q3 = sd_resolv_res_query(asyncns, "_xmpp-client._tcp.gmail.com", C_IN, T_SRV);
+        q3 = sd_resolv_res_query(resolv, "_xmpp-client._tcp.gmail.com", C_IN, T_SRV);
         if (!q3)
                 fprintf(stderr, "sd_resolv_res_query(): %s\n", strerror(errno));
 
         /* Wait until the three queries are completed */
-        while (!sd_resolv_isdone(asyncns, q1) ||
-               !sd_resolv_isdone(asyncns, q2) ||
-               !sd_resolv_isdone(asyncns, q3)) {
-                if (sd_resolv_wait(asyncns, 1) < 0)
+        while (!sd_resolv_isdone(resolv, q1) ||
+               !sd_resolv_isdone(resolv, q2) ||
+               !sd_resolv_isdone(resolv, q3)) {
+                if (sd_resolv_wait(resolv, 1) < 0)
                         fprintf(stderr, "sd_resolv_wait(): %s\n", strerror(errno));
         }
 
         /* Interpret the result of the name -> addr query */
-        ret = sd_resolv_getaddrinfo_done(asyncns, q1, &ai);
+        ret = sd_resolv_getaddrinfo_done(resolv, q1, &ai);
         if (ret)
                 fprintf(stderr, "error: %s %i\n", gai_strerror(ret), ret);
         else {
@@ -102,14 +102,14 @@ int main(int argc, char *argv[]) {
         }
 
         /* Interpret the result of the addr -> name query */
-        ret = sd_resolv_getnameinfo_done(asyncns, q2, host, sizeof(host), serv, sizeof(serv));
+        ret = sd_resolv_getnameinfo_done(resolv, q2, host, sizeof(host), serv, sizeof(serv));
         if (ret)
                 fprintf(stderr, "error: %s %i\n", gai_strerror(ret), ret);
         else
                 printf("%s -- %s\n", host, serv);
 
         /* Interpret the result of the SRV lookup */
-        ret = sd_resolv_res_done(asyncns, q3, &srv);
+        ret = sd_resolv_res_done(resolv, q3, &srv);
         if (ret < 0) {
                 fprintf(stderr, "error: %s %i\n", strerror(errno), ret);
         } else if (ret == 0) {
diff --git a/src/systemd/sd-resolv.h b/src/systemd/sd-resolv.h
index c9f1d1d..21e2413 100644
--- a/src/systemd/sd-resolv.h
+++ b/src/systemd/sd-resolv.h
@@ -33,48 +33,48 @@ _SD_BEGIN_DECLARATIONS;
  *
  * \section moo Method of operation
  *
- * To use libasyncns allocate an sd_resolv_t object with
+ * To use libresolv allocate an sd_resolv_t object with
  * sd_resolv_new(). This will spawn a number of worker threads (or processes, depending on what is available) which
  * are subsequently used to process the queries the controlling
  * program issues via sd_resolv_getaddrinfo() and
  * sd_resolv_getnameinfo(). Use sd_resolv_free() to shut down the worker
  * threads/processes.
  *
- * Since libasyncns may fork off new processes you have to make sure that
+ * Since libresolv may fork off new processes you have to make sure that
  * your program is not irritated by spurious SIGCHLD signals.
  */
 
-/** An opaque libasyncns session structure */
+/** An opaque libresolv session structure */
 typedef struct sd_resolv sd_resolv_t;
 
-/** An opaque libasyncns query structure */
+/** An opaque libresolv query structure */
 typedef struct sd_resolv_query sd_resolv_query_t;
 
-/** Allocate a new libasyncns session with n_proc worker processes/threads */
+/** Allocate a new libresolv session with n_proc worker processes/threads */
 sd_resolv_t* sd_resolv_new(unsigned n_proc);
 
-/** Free a libasyncns session. This destroys all attached
+/** Free a libresolv session. This destroys all attached
  * sd_resolv_query_t objects automatically */
-void sd_resolv_free(sd_resolv_t *asyncns);
+void sd_resolv_free(sd_resolv_t *resolv);
 
 /** Return the UNIX file descriptor to select() for readability
- * on. Use this function to integrate libasyncns with your custom main
+ * on. Use this function to integrate libresolv with your custom main
  * loop. */
-int sd_resolv_fd(sd_resolv_t *asyncns);
+int sd_resolv_fd(sd_resolv_t *resolv);
 
 /** Process pending responses. After this function is called you can
  * get the next completed query object(s) using sd_resolv_getnext(). If
  * block is non-zero wait until at least one response has been
  * processed. If block is zero, process all pending responses and
  * return. */
-int sd_resolv_wait(sd_resolv_t *asyncns, int block);
+int sd_resolv_wait(sd_resolv_t *resolv, int block);
 
 /** Issue a name to address query on the specified session. The
  * arguments are compatible with the ones of libc's
  * getaddrinfo(3). The function returns a new query object. When the
  * query is completed you may retrieve the results using
  * sd_resolv_getaddrinfo_done().*/
-sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
+sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *resolv, const char *node, const char *service, const struct addrinfo *hints);
 
 /** Retrieve the results of a preceding sd_resolv_getaddrinfo()
  * call. Returns a addrinfo structure and a return value compatible
@@ -83,7 +83,7 @@ sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *asyncns, const char *node,
  * returned addrinfo structure with sd_resolv_freeaddrinfo() and not
  * libc's freeaddrinfo(3)! If the query is not completed yet EAI_AGAIN
  * is returned.*/
-int sd_resolv_getaddrinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, struct addrinfo **ret_res);
+int sd_resolv_getaddrinfo_done(sd_resolv_t *resolv, sd_resolv_query_t* q, struct addrinfo **ret_res);
 
 /** Issue an address to name query on the specified session. The
  * arguments are compatible with the ones of libc's
@@ -91,48 +91,48 @@ int sd_resolv_getaddrinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, struc
  * query is completed you may retrieve the results using
  * sd_resolv_getnameinfo_done(). Set gethost (resp. getserv) to non-zero
  * if you want to query the hostname (resp. the service name). */
-sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
+sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *resolv, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
 
 /** Retrieve the results of a preceding sd_resolv_getnameinfo()
  * call. Returns the hostname and the service name in ret_host and
  * ret_serv. The query object q is destroyed by this call and may not
  * be used any further. If the query is not completed yet EAI_AGAIN is
  * returned. */
-int sd_resolv_getnameinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
+int sd_resolv_getnameinfo_done(sd_resolv_t *resolv, sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
 
 /** Issue a resolver query on the specified session. The arguments are
  * compatible with the ones of libc's res_query(3). The function returns a new
  * query object. When the query is completed you may retrieve the results using
  * sd_resolv_res_done().  */
-sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *asyncns, const char *dname, int class, int type);
+sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *resolv, const char *dname, int class, int type);
 
 /** Issue an resolver query on the specified session. The arguments are
  * compatible with the ones of libc's res_search(3). The function returns a new
  * query object. When the query is completed you may retrieve the results using
  * sd_resolv_res_done().  */
-sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *asyncns, const char *dname, int class, int type);
+sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *resolv, const char *dname, int class, int type);
 
 /** Retrieve the results of a preceding sd_resolv_res_query() or
- * asyncns_res_search call.  The query object q is destroyed by this
+ * resolv_res_search call.  The query object q is destroyed by this
  * call and may not be used any further. Returns a pointer to the
  * answer of the res_query call. If the query is not completed yet
  * -EAGAIN is returned, on failure -errno is returned, otherwise the
  * length of answer is returned. Make sure to free the answer is a
  * call to sd_resolv_freeanswer(). */
-int sd_resolv_res_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, unsigned char **answer);
+int sd_resolv_res_done(sd_resolv_t *resolv, sd_resolv_query_t* q, unsigned char **answer);
 
 /** Return the next completed query object. If no query has been
  * completed yet, return NULL. Please note that you need to run
  * sd_resolv_wait() before this function will return sensible data.  */
-sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *asyncns);
+sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *resolv);
 
 /** Return the number of query objects (completed or not) attached to
  * this session */
-int sd_resolv_getnqueries(sd_resolv_t *asyncns);
+int sd_resolv_getnqueries(sd_resolv_t *resolv);
 
 /** Cancel a currently running query. q is is destroyed by this call
  * and may not be used any futher. */
-void sd_resolv_cancel(sd_resolv_t *asyncns, sd_resolv_query_t* q);
+void sd_resolv_cancel(sd_resolv_t *resolv, sd_resolv_query_t* q);
 
 /** Free the addrinfo structure as returned by
  * sd_resolv_getaddrinfo_done(). Make sure to use this functions instead
@@ -143,15 +143,15 @@ void sd_resolv_freeaddrinfo(struct addrinfo *ai);
 void sd_resolv_freeanswer(unsigned char *answer);
 
 /** Returns non-zero when the query operation specified by q has been completed */
-int sd_resolv_isdone(sd_resolv_t *asyncns, sd_resolv_query_t*q);
+int sd_resolv_isdone(sd_resolv_t *resolv, sd_resolv_query_t*q);
 
 /** Assign some opaque userdata with a query object */
-void sd_resolv_setuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q, void *userdata);
+void sd_resolv_setuserdata(sd_resolv_t *resolv, sd_resolv_query_t *q, void *userdata);
 
 /** Return userdata assigned to a query object. Use
  * sd_resolv_setuserdata() to set this data. If no data has been set
  * prior to this call it returns NULL. */
-void* sd_resolv_getuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q);
+void* sd_resolv_getuserdata(sd_resolv_t *resolv, sd_resolv_query_t *q);
 
 _SD_END_DECLARATIONS;
 

commit 2a4be8ad9896ebd02d0d92be1a116aabd2bf402b
Author: Daniel Buch <boogiewasthere at gmail.com>
Date:   Tue Jan 14 11:46:48 2014 +0100

    sd_resolv: Rename structs- and function names to sd_resolv

diff --git a/src/libsystemd/resolv-util.h b/src/libsystemd/resolv-util.h
index e0284c8..7b6ec70 100644
--- a/src/libsystemd/resolv-util.h
+++ b/src/libsystemd/resolv-util.h
@@ -23,9 +23,9 @@
 
 #include "util.h"
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(asyncns_t*, asyncns_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, asyncns_freeanswer);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, asyncns_freeaddrinfo);
-#define _cleanup_asyncns_free_ _cleanup_(asyncns_freep)
-#define _cleanup_asyncns_answer_free_ _cleanup_(asyncns_freeanswerp)
-#define _cleanup_asyncns_addrinfo_free_ _cleanup_(asyncns_freeaddrinfop)
+DEFINE_TRIVIAL_CLEANUP_FUNC(sd_resolv_t*, sd_resolv_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC(unsigned char *, sd_resolv_freeanswer);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct addrinfo*, sd_resolv_freeaddrinfo);
+#define _cleanup_resolv_free_ _cleanup_(sd_resolv_freep)
+#define _cleanup_resolv_answer_free_ _cleanup_(sd_resolv_freeanswerp)
+#define _cleanup_resolv_addrinfo_free_ _cleanup_(sd_resolv_freeaddrinfop)
diff --git a/src/libsystemd/sd-resolv.c b/src/libsystemd/sd-resolv.c
index 2db66eb..a4e7cde 100644
--- a/src/libsystemd/sd-resolv.c
+++ b/src/libsystemd/sd-resolv.c
@@ -68,27 +68,27 @@ enum {
         MESSAGE_FD_MAX = 4
 };
 
-struct asyncns {
+struct sd_resolv {
         int fds[MESSAGE_FD_MAX];
 
         pthread_t workers[MAX_WORKERS];
         unsigned valid_workers;
 
         unsigned current_id, current_index;
-        asyncns_query_t* queries[MAX_QUERIES];
+        sd_resolv_query_t* queries[MAX_QUERIES];
 
-        asyncns_query_t *done_head, *done_tail;
+        sd_resolv_query_t *done_head, *done_tail;
 
         int n_queries;
         int dead;
 };
 
-struct asyncns_query {
-        asyncns_t *asyncns;
+struct sd_resolv_query {
+        sd_resolv_t *asyncns;
         int done;
         unsigned id;
         query_type_t type;
-        asyncns_query_t *done_next, *done_prev;
+        sd_resolv_query_t *done_next, *done_prev;
         int ret;
         int _errno;
         int _h_errno;
@@ -383,7 +383,7 @@ static int handle_request(int out_fd, const packet_t *packet, size_t length) {
 }
 
 static void* thread_worker(void *p) {
-        asyncns_t *asyncns = p;
+        sd_resolv_t *asyncns = p;
         sigset_t fullset;
 
         /* No signals in this thread please */
@@ -414,16 +414,16 @@ static void* thread_worker(void *p) {
         return NULL;
 }
 
-asyncns_t* asyncns_new(unsigned n_proc) {
+sd_resolv_t* sd_resolv_new(unsigned n_proc) {
         int i;
-        asyncns_t *asyncns = NULL;
+        sd_resolv_t *asyncns = NULL;
 
         assert(n_proc >= 1);
 
         if (n_proc > MAX_WORKERS)
                 n_proc = MAX_WORKERS;
 
-        asyncns = malloc(sizeof(asyncns_t));
+        asyncns = malloc(sizeof(sd_resolv_t));
         if (!asyncns) {
                 errno = ENOMEM;
                 goto fail;
@@ -475,12 +475,12 @@ asyncns_t* asyncns_new(unsigned n_proc) {
 
 fail:
         if (asyncns)
-                asyncns_free(asyncns);
+                sd_resolv_free(asyncns);
 
         return NULL;
 }
 
-void asyncns_free(asyncns_t *asyncns) {
+void sd_resolv_free(sd_resolv_t *asyncns) {
         int i;
         int saved_errno = errno;
         unsigned p;
@@ -516,21 +516,21 @@ void asyncns_free(asyncns_t *asyncns) {
 
         for (p = 0; p < MAX_QUERIES; p++)
                 if (asyncns->queries[p])
-                        asyncns_cancel(asyncns, asyncns->queries[p]);
+                        sd_resolv_cancel(asyncns, asyncns->queries[p]);
 
         free(asyncns);
 
         errno = saved_errno;
 }
 
-int asyncns_fd(asyncns_t *asyncns) {
+int sd_resolv_fd(sd_resolv_t *asyncns) {
         assert(asyncns);
 
         return asyncns->fds[RESPONSE_RECV_FD];
 }
 
-static asyncns_query_t *lookup_query(asyncns_t *asyncns, unsigned id) {
-        asyncns_query_t *q;
+static sd_resolv_query_t *lookup_query(sd_resolv_t *asyncns, unsigned id) {
+        sd_resolv_query_t *q;
         assert(asyncns);
 
         q = asyncns->queries[id % MAX_QUERIES];
@@ -541,7 +541,7 @@ static asyncns_query_t *lookup_query(asyncns_t *asyncns, unsigned id) {
         return NULL;
 }
 
-static void complete_query(asyncns_t *asyncns, asyncns_query_t *q) {
+static void complete_query(sd_resolv_t *asyncns, sd_resolv_query_t *q) {
         assert(asyncns);
         assert(q);
         assert(!q->done);
@@ -608,14 +608,14 @@ static const void *unserialize_addrinfo(const void *p, struct addrinfo **ret_ai,
 
 fail:
         if (ai)
-                asyncns_freeaddrinfo(ai);
+                sd_resolv_freeaddrinfo(ai);
 
         return NULL;
 }
 
-static int handle_response(asyncns_t *asyncns, const packet_t *packet, size_t length) {
+static int handle_response(sd_resolv_t *asyncns, const packet_t *packet, size_t length) {
         const rheader_t *resp;
-        asyncns_query_t *q;
+        sd_resolv_query_t *q;
 
         assert(asyncns);
 
@@ -721,7 +721,7 @@ static int handle_response(asyncns_t *asyncns, const packet_t *packet, size_t le
         return 0;
 }
 
-int asyncns_wait(asyncns_t *asyncns, int block) {
+int sd_resolv_wait(sd_resolv_t *asyncns, int block) {
         int handled = 0;
         assert(asyncns);
 
@@ -760,8 +760,8 @@ int asyncns_wait(asyncns_t *asyncns, int block) {
         }
 }
 
-static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
-        asyncns_query_t *q;
+static sd_resolv_query_t *alloc_query(sd_resolv_t *asyncns) {
+        sd_resolv_query_t *q;
         assert(asyncns);
 
         if (asyncns->n_queries >= MAX_QUERIES) {
@@ -777,7 +777,7 @@ static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
                         asyncns->current_index -= MAX_QUERIES;
         }
 
-        q = asyncns->queries[asyncns->current_index] = malloc(sizeof(asyncns_query_t));
+        q = asyncns->queries[asyncns->current_index] = malloc(sizeof(sd_resolv_query_t));
         if (!q) {
                 errno = ENOMEM;
                 return NULL;
@@ -799,10 +799,10 @@ static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
         return q;
 }
 
-asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints) {
+sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *asyncns, const char *node, const char *service, const struct addrinfo *hints) {
         addrinfo_request_t data[BUFSIZE/sizeof(addrinfo_request_t) + 1] = {};
         addrinfo_request_t *req = data;
-        asyncns_query_t *q;
+        sd_resolv_query_t *q;
         assert(asyncns);
         assert(node || service);
 
@@ -847,12 +847,12 @@ asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const
 
 fail:
         if (q)
-                asyncns_cancel(asyncns, q);
+                sd_resolv_cancel(asyncns, q);
 
         return NULL;
 }
 
-int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res) {
+int sd_resolv_getaddrinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, struct addrinfo **ret_res) {
         int ret;
         assert(asyncns);
         assert(q);
@@ -878,15 +878,15 @@ int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addr
         if (ret != 0)
                 h_errno = q->_h_errno;
 
-        asyncns_cancel(asyncns, q);
+        sd_resolv_cancel(asyncns, q);
 
         return ret;
 }
 
-asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
+sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv) {
         nameinfo_request_t data[BUFSIZE/sizeof(nameinfo_request_t) + 1] = {};
         nameinfo_request_t *req = data;
-        asyncns_query_t *q;
+        sd_resolv_query_t *q;
 
         assert(asyncns);
         assert(sa);
@@ -924,12 +924,12 @@ asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *
 
 fail:
         if (q)
-                asyncns_cancel(asyncns, q);
+                sd_resolv_cancel(asyncns, q);
 
         return NULL;
 }
 
-int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
+int sd_resolv_getnameinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen) {
         int ret;
         assert(asyncns);
         assert(q);
@@ -964,15 +964,15 @@ int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_h
         if (ret != 0)
                 h_errno = q->_h_errno;
 
-        asyncns_cancel(asyncns, q);
+        sd_resolv_cancel(asyncns, q);
 
         return ret;
 }
 
-static asyncns_query_t * asyncns_res(asyncns_t *asyncns, query_type_t qtype, const char *dname, int class, int type) {
+static sd_resolv_query_t * asyncns_res(sd_resolv_t *asyncns, query_type_t qtype, const char *dname, int class, int type) {
         res_request_t data[BUFSIZE/sizeof(res_request_t) + 1];
         res_request_t *req = data;
-        asyncns_query_t *q;
+        sd_resolv_query_t *q;
 
         assert(asyncns);
         assert(dname);
@@ -1009,20 +1009,20 @@ static asyncns_query_t * asyncns_res(asyncns_t *asyncns, query_type_t qtype, con
 
 fail:
         if (q)
-                asyncns_cancel(asyncns, q);
+                sd_resolv_cancel(asyncns, q);
 
         return NULL;
 }
 
-asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type) {
+sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *asyncns, const char *dname, int class, int type) {
         return asyncns_res(asyncns, REQUEST_RES_QUERY, dname, class, type);
 }
 
-asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type) {
+sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *asyncns, const char *dname, int class, int type) {
         return asyncns_res(asyncns, REQUEST_RES_SEARCH, dname, class, type);
 }
 
-int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer) {
+int sd_resolv_res_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, unsigned char **answer) {
         int ret;
         assert(asyncns);
         assert(q);
@@ -1050,22 +1050,22 @@ int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **ans
                 h_errno = q->_h_errno;
         }
 
-        asyncns_cancel(asyncns, q);
+        sd_resolv_cancel(asyncns, q);
 
         return ret < 0 ? -errno : ret;
 }
 
-asyncns_query_t* asyncns_getnext(asyncns_t *asyncns) {
+sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *asyncns) {
         assert(asyncns);
         return asyncns->done_head;
 }
 
-int asyncns_getnqueries(asyncns_t *asyncns) {
+int sd_resolv_getnqueries(sd_resolv_t *asyncns) {
         assert(asyncns);
         return asyncns->n_queries;
 }
 
-void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q) {
+void sd_resolv_cancel(sd_resolv_t *asyncns, sd_resolv_query_t* q) {
         int i;
         int saved_errno = errno;
 
@@ -1091,7 +1091,7 @@ void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q) {
         assert(asyncns->queries[i] == q);
         asyncns->queries[i] = NULL;
 
-        asyncns_freeaddrinfo(q->addrinfo);
+        sd_resolv_freeaddrinfo(q->addrinfo);
         free(q->host);
         free(q->serv);
 
@@ -1101,7 +1101,7 @@ void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q) {
         errno = saved_errno;
 }
 
-void asyncns_freeaddrinfo(struct addrinfo *ai) {
+void sd_resolv_freeaddrinfo(struct addrinfo *ai) {
         int saved_errno = errno;
 
         while (ai) {
@@ -1117,7 +1117,7 @@ void asyncns_freeaddrinfo(struct addrinfo *ai) {
         errno = saved_errno;
 }
 
-void asyncns_freeanswer(unsigned char *answer) {
+void sd_resolv_freeanswer(unsigned char *answer) {
         int saved_errno = errno;
 
         if (!answer)
@@ -1133,7 +1133,7 @@ void asyncns_freeanswer(unsigned char *answer) {
         errno = saved_errno;
 }
 
-int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q) {
+int sd_resolv_isdone(sd_resolv_t *asyncns, sd_resolv_query_t*q) {
         assert(asyncns);
         assert(q);
         assert(q->asyncns == asyncns);
@@ -1141,7 +1141,7 @@ int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q) {
         return q->done;
 }
 
-void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata) {
+void sd_resolv_setuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q, void *userdata) {
         assert(q);
         assert(asyncns);
         assert(q->asyncns = asyncns);
@@ -1149,7 +1149,7 @@ void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata)
         q->userdata = userdata;
 }
 
-void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q) {
+void* sd_resolv_getuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q) {
         assert(q);
         assert(asyncns);
         assert(q->asyncns = asyncns);
diff --git a/src/libsystemd/test-resolv.c b/src/libsystemd/test-resolv.c
index 9365dd8..aa26931 100644
--- a/src/libsystemd/test-resolv.c
+++ b/src/libsystemd/test-resolv.c
@@ -37,17 +37,17 @@
 
 int main(int argc, char *argv[]) {
         int r = 1, ret;
-        _cleanup_asyncns_free_ asyncns_t *asyncns = NULL;
-        _cleanup_asyncns_addrinfo_free_ struct addrinfo *ai = NULL;
-        _cleanup_asyncns_answer_free_ unsigned char *srv = NULL;
-        asyncns_query_t *q1, *q2, *q3;
+        _cleanup_resolv_free_ sd_resolv_t *asyncns = NULL;
+        _cleanup_resolv_addrinfo_free_ struct addrinfo *ai = NULL;
+        _cleanup_resolv_answer_free_ unsigned char *srv = NULL;
+        sd_resolv_query_t *q1, *q2, *q3;
         struct addrinfo hints = {};
         struct sockaddr_in sa = {};
         char host[NI_MAXHOST] = "", serv[NI_MAXSERV] = "";
 
         signal(SIGCHLD, SIG_IGN);
 
-        asyncns = asyncns_new(2);
+        asyncns = sd_resolv_new(2);
         if (!asyncns)
                 log_oom();
 
@@ -55,34 +55,34 @@ int main(int argc, char *argv[]) {
         hints.ai_family = PF_UNSPEC;
         hints.ai_socktype = SOCK_STREAM;
 
-        q1 = asyncns_getaddrinfo(asyncns, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints);
+        q1 = sd_resolv_getaddrinfo(asyncns, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints);
         if (!q1)
-                fprintf(stderr, "asyncns_getaddrinfo(): %s\n", strerror(errno));
+                fprintf(stderr, "sd_resolv_getaddrinfo(): %s\n", strerror(errno));
 
         /* Make an address -> name query */
         sa.sin_family = AF_INET;
         sa.sin_addr.s_addr = inet_addr(argc >= 3 ? argv[2] : "193.99.144.71");
         sa.sin_port = htons(80);
 
-        q2 = asyncns_getnameinfo(asyncns, (struct sockaddr*) &sa, sizeof(sa), 0, 1, 1);
+        q2 = sd_resolv_getnameinfo(asyncns, (struct sockaddr*) &sa, sizeof(sa), 0, 1, 1);
         if (!q2)
-                fprintf(stderr, "asyncns_getnameinfo(): %s\n", strerror(errno));
+                fprintf(stderr, "sd_resolv_getnameinfo(): %s\n", strerror(errno));
 
         /* Make a res_query() call */
-        q3 = asyncns_res_query(asyncns, "_xmpp-client._tcp.gmail.com", C_IN, T_SRV);
+        q3 = sd_resolv_res_query(asyncns, "_xmpp-client._tcp.gmail.com", C_IN, T_SRV);
         if (!q3)
-                fprintf(stderr, "asyncns_res_query(): %s\n", strerror(errno));
+                fprintf(stderr, "sd_resolv_res_query(): %s\n", strerror(errno));
 
         /* Wait until the three queries are completed */
-        while (!asyncns_isdone(asyncns, q1) ||
-               !asyncns_isdone(asyncns, q2) ||
-               !asyncns_isdone(asyncns, q3)) {
-                if (asyncns_wait(asyncns, 1) < 0)
-                        fprintf(stderr, "asyncns_wait(): %s\n", strerror(errno));
+        while (!sd_resolv_isdone(asyncns, q1) ||
+               !sd_resolv_isdone(asyncns, q2) ||
+               !sd_resolv_isdone(asyncns, q3)) {
+                if (sd_resolv_wait(asyncns, 1) < 0)
+                        fprintf(stderr, "sd_resolv_wait(): %s\n", strerror(errno));
         }
 
         /* Interpret the result of the name -> addr query */
-        ret = asyncns_getaddrinfo_done(asyncns, q1, &ai);
+        ret = sd_resolv_getaddrinfo_done(asyncns, q1, &ai);
         if (ret)
                 fprintf(stderr, "error: %s %i\n", gai_strerror(ret), ret);
         else {
@@ -102,14 +102,14 @@ int main(int argc, char *argv[]) {
         }
 
         /* Interpret the result of the addr -> name query */
-        ret = asyncns_getnameinfo_done(asyncns, q2, host, sizeof(host), serv, sizeof(serv));
+        ret = sd_resolv_getnameinfo_done(asyncns, q2, host, sizeof(host), serv, sizeof(serv));
         if (ret)
                 fprintf(stderr, "error: %s %i\n", gai_strerror(ret), ret);
         else
                 printf("%s -- %s\n", host, serv);
 
         /* Interpret the result of the SRV lookup */
-        ret = asyncns_res_done(asyncns, q3, &srv);
+        ret = sd_resolv_res_done(asyncns, q3, &srv);
         if (ret < 0) {
                 fprintf(stderr, "error: %s %i\n", strerror(errno), ret);
         } else if (ret == 0) {
diff --git a/src/systemd/sd-resolv.h b/src/systemd/sd-resolv.h
index 47608ce..c9f1d1d 100644
--- a/src/systemd/sd-resolv.h
+++ b/src/systemd/sd-resolv.h
@@ -33,11 +33,11 @@ _SD_BEGIN_DECLARATIONS;
  *
  * \section moo Method of operation
  *
- * To use libasyncns allocate an asyncns_t object with
- * asyncns_new(). This will spawn a number of worker threads (or processes, depending on what is available) which
+ * To use libasyncns allocate an sd_resolv_t object with
+ * sd_resolv_new(). This will spawn a number of worker threads (or processes, depending on what is available) which
  * are subsequently used to process the queries the controlling
- * program issues via asyncns_getaddrinfo() and
- * asyncns_getnameinfo(). Use asyncns_free() to shut down the worker
+ * program issues via sd_resolv_getaddrinfo() and
+ * sd_resolv_getnameinfo(). Use sd_resolv_free() to shut down the worker
  * threads/processes.
  *
  * Since libasyncns may fork off new processes you have to make sure that
@@ -45,113 +45,113 @@ _SD_BEGIN_DECLARATIONS;
  */
 
 /** An opaque libasyncns session structure */
-typedef struct asyncns asyncns_t;
+typedef struct sd_resolv sd_resolv_t;
 
 /** An opaque libasyncns query structure */
-typedef struct asyncns_query asyncns_query_t;
+typedef struct sd_resolv_query sd_resolv_query_t;
 
 /** Allocate a new libasyncns session with n_proc worker processes/threads */
-asyncns_t* asyncns_new(unsigned n_proc);
+sd_resolv_t* sd_resolv_new(unsigned n_proc);
 
 /** Free a libasyncns session. This destroys all attached
- * asyncns_query_t objects automatically */
-void asyncns_free(asyncns_t *asyncns);
+ * sd_resolv_query_t objects automatically */
+void sd_resolv_free(sd_resolv_t *asyncns);
 
 /** Return the UNIX file descriptor to select() for readability
  * on. Use this function to integrate libasyncns with your custom main
  * loop. */
-int asyncns_fd(asyncns_t *asyncns);
+int sd_resolv_fd(sd_resolv_t *asyncns);
 
 /** Process pending responses. After this function is called you can
- * get the next completed query object(s) using asyncns_getnext(). If
+ * get the next completed query object(s) using sd_resolv_getnext(). If
  * block is non-zero wait until at least one response has been
  * processed. If block is zero, process all pending responses and
  * return. */
-int asyncns_wait(asyncns_t *asyncns, int block);
+int sd_resolv_wait(sd_resolv_t *asyncns, int block);
 
 /** Issue a name to address query on the specified session. The
  * arguments are compatible with the ones of libc's
  * getaddrinfo(3). The function returns a new query object. When the
  * query is completed you may retrieve the results using
- * asyncns_getaddrinfo_done().*/
-asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
+ * sd_resolv_getaddrinfo_done().*/
+sd_resolv_query_t* sd_resolv_getaddrinfo(sd_resolv_t *asyncns, const char *node, const char *service, const struct addrinfo *hints);
 
-/** Retrieve the results of a preceding asyncns_getaddrinfo()
+/** Retrieve the results of a preceding sd_resolv_getaddrinfo()
  * call. Returns a addrinfo structure and a return value compatible
  * with libc's getaddrinfo(3). The query object q is destroyed by this
  * call and may not be used any further. Make sure to free the
- * returned addrinfo structure with asyncns_freeaddrinfo() and not
+ * returned addrinfo structure with sd_resolv_freeaddrinfo() and not
  * libc's freeaddrinfo(3)! If the query is not completed yet EAI_AGAIN
  * is returned.*/
-int asyncns_getaddrinfo_done(asyncns_t *asyncns, asyncns_query_t* q, struct addrinfo **ret_res);
+int sd_resolv_getaddrinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, struct addrinfo **ret_res);
 
 /** Issue an address to name query on the specified session. The
  * arguments are compatible with the ones of libc's
  * getnameinfo(3). The function returns a new query object. When the
  * query is completed you may retrieve the results using
- * asyncns_getnameinfo_done(). Set gethost (resp. getserv) to non-zero
+ * sd_resolv_getnameinfo_done(). Set gethost (resp. getserv) to non-zero
  * if you want to query the hostname (resp. the service name). */
-asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
+sd_resolv_query_t* sd_resolv_getnameinfo(sd_resolv_t *asyncns, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv);
 
-/** Retrieve the results of a preceding asyncns_getnameinfo()
+/** Retrieve the results of a preceding sd_resolv_getnameinfo()
  * call. Returns the hostname and the service name in ret_host and
  * ret_serv. The query object q is destroyed by this call and may not
  * be used any further. If the query is not completed yet EAI_AGAIN is
  * returned. */
-int asyncns_getnameinfo_done(asyncns_t *asyncns, asyncns_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
+int sd_resolv_getnameinfo_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, char *ret_host, size_t hostlen, char *ret_serv, size_t servlen);
 
 /** Issue a resolver query on the specified session. The arguments are
  * compatible with the ones of libc's res_query(3). The function returns a new
  * query object. When the query is completed you may retrieve the results using
- * asyncns_res_done().  */
-asyncns_query_t* asyncns_res_query(asyncns_t *asyncns, const char *dname, int class, int type);
+ * sd_resolv_res_done().  */
+sd_resolv_query_t* sd_resolv_res_query(sd_resolv_t *asyncns, const char *dname, int class, int type);
 
 /** Issue an resolver query on the specified session. The arguments are
  * compatible with the ones of libc's res_search(3). The function returns a new
  * query object. When the query is completed you may retrieve the results using
- * asyncns_res_done().  */
-asyncns_query_t* asyncns_res_search(asyncns_t *asyncns, const char *dname, int class, int type);
+ * sd_resolv_res_done().  */
+sd_resolv_query_t* sd_resolv_res_search(sd_resolv_t *asyncns, const char *dname, int class, int type);
 
-/** Retrieve the results of a preceding asyncns_res_query() or
+/** Retrieve the results of a preceding sd_resolv_res_query() or
  * asyncns_res_search call.  The query object q is destroyed by this
  * call and may not be used any further. Returns a pointer to the
  * answer of the res_query call. If the query is not completed yet
  * -EAGAIN is returned, on failure -errno is returned, otherwise the
  * length of answer is returned. Make sure to free the answer is a
- * call to asyncns_freeanswer(). */
-int asyncns_res_done(asyncns_t *asyncns, asyncns_query_t* q, unsigned char **answer);
+ * call to sd_resolv_freeanswer(). */
+int sd_resolv_res_done(sd_resolv_t *asyncns, sd_resolv_query_t* q, unsigned char **answer);
 
 /** Return the next completed query object. If no query has been
  * completed yet, return NULL. Please note that you need to run
- * asyncns_wait() before this function will return sensible data.  */
-asyncns_query_t* asyncns_getnext(asyncns_t *asyncns);
+ * sd_resolv_wait() before this function will return sensible data.  */
+sd_resolv_query_t* sd_resolv_getnext(sd_resolv_t *asyncns);
 
 /** Return the number of query objects (completed or not) attached to
  * this session */
-int asyncns_getnqueries(asyncns_t *asyncns);
+int sd_resolv_getnqueries(sd_resolv_t *asyncns);
 
 /** Cancel a currently running query. q is is destroyed by this call
  * and may not be used any futher. */
-void asyncns_cancel(asyncns_t *asyncns, asyncns_query_t* q);
+void sd_resolv_cancel(sd_resolv_t *asyncns, sd_resolv_query_t* q);
 
 /** Free the addrinfo structure as returned by
- * asyncns_getaddrinfo_done(). Make sure to use this functions instead
+ * sd_resolv_getaddrinfo_done(). Make sure to use this functions instead
  * of the libc's freeaddrinfo()! */
-void asyncns_freeaddrinfo(struct addrinfo *ai);
+void sd_resolv_freeaddrinfo(struct addrinfo *ai);
 
-/** Free the answer data as returned by asyncns_res_done().*/
-void asyncns_freeanswer(unsigned char *answer);
+/** Free the answer data as returned by sd_resolv_res_done().*/
+void sd_resolv_freeanswer(unsigned char *answer);
 
 /** Returns non-zero when the query operation specified by q has been completed */
-int asyncns_isdone(asyncns_t *asyncns, asyncns_query_t*q);
+int sd_resolv_isdone(sd_resolv_t *asyncns, sd_resolv_query_t*q);
 
 /** Assign some opaque userdata with a query object */
-void asyncns_setuserdata(asyncns_t *asyncns, asyncns_query_t *q, void *userdata);
+void sd_resolv_setuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q, void *userdata);
 
 /** Return userdata assigned to a query object. Use
- * asyncns_setuserdata() to set this data. If no data has been set
+ * sd_resolv_setuserdata() to set this data. If no data has been set
  * prior to this call it returns NULL. */
-void* asyncns_getuserdata(asyncns_t *asyncns, asyncns_query_t *q);
+void* sd_resolv_getuserdata(sd_resolv_t *asyncns, sd_resolv_query_t *q);
 
 _SD_END_DECLARATIONS;
 



More information about the systemd-commits mailing list