summaryrefslogtreecommitdiff
path: root/src/dnsproxy.c
diff options
context:
space:
mode:
authorPaulo Pizarro <paulo.pizarro@gmail.com>2012-05-30 17:24:24 -0300
committerPatrik Flykt <patrik.flykt@linux.intel.com>2012-05-31 10:55:52 +0300
commitd07c8edabf44721a3e7428993ada7df10f773f60 (patch)
treedb0141242e2acae0e5207b88aba2a1c0e9bfc0ac /src/dnsproxy.c
parent243ca16628fff07f8185c8e5083c6d46e7f34b38 (diff)
downloadconnman-d07c8edabf44721a3e7428993ada7df10f773f60.tar.gz
connman-d07c8edabf44721a3e7428993ada7df10f773f60.tar.bz2
connman-d07c8edabf44721a3e7428993ada7df10f773f60.zip
dnsproxy: If the answer is in the cache, the UDP request is released
Diffstat (limited to 'src/dnsproxy.c')
-rw-r--r--src/dnsproxy.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/dnsproxy.c b/src/dnsproxy.c
index 5c4099bd..efbc195f 100644
--- a/src/dnsproxy.c
+++ b/src/dnsproxy.c
@@ -2039,7 +2039,6 @@ static gboolean resolv(struct request_data *req,
gpointer request, gpointer name)
{
GSList *list;
- int status;
for (list = server_list; list; list = list->next) {
struct server_data *data = list->data;
@@ -2054,19 +2053,11 @@ static gboolean resolv(struct request_data *req,
G_IO_IN | G_IO_NVAL | G_IO_ERR | G_IO_HUP,
udp_server_event, data);
- status = ns_resolv(data, req, request, name);
- if (status < 0)
- continue;
-
- if (status > 0) {
- if (req->timeout > 0) {
- g_source_remove(req->timeout);
- req->timeout = 0;
- }
- }
+ if (ns_resolv(data, req, request, name) > 0)
+ return TRUE;
}
- return TRUE;
+ return FALSE;
}
static void append_domain(const char *interface, const char *domain)
@@ -2512,11 +2503,18 @@ static gboolean udp_listener_event(GIOChannel *channel, GIOCondition condition,
req->numserv = 0;
req->ifdata = (struct listener_data *) ifdata;
- req->timeout = g_timeout_add_seconds(5, request_timeout, req);
req->append_domain = FALSE;
+
+ if (resolv(req, buf, query) == TRUE) {
+ /* a cached result was sent, so the request can be released */
+ g_free(req);
+ return TRUE;
+ }
+
+ req->timeout = g_timeout_add_seconds(5, request_timeout, req);
request_list = g_slist_append(request_list, req);
- return resolv(req, buf, query);
+ return TRUE;
}
static int create_dns_listener(int protocol, struct listener_data *ifdata)