[asterisk-commits] file: branch group/dns r432482 - in /team/group/dns: include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 5 08:58:46 CST 2015


Author: file
Date: Thu Mar  5 08:58:44 2015
New Revision: 432482

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=432482
Log:
Begin adding recurring support.

Modified:
    team/group/dns/include/asterisk/dns_internal.h
    team/group/dns/main/dns_core.c

Modified: team/group/dns/include/asterisk/dns_internal.h
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/include/asterisk/dns_internal.h?view=diff&rev=432482&r1=432481&r2=432482
==============================================================================
--- team/group/dns/include/asterisk/dns_internal.h (original)
+++ team/group/dns/include/asterisk/dns_internal.h Thu Mar  5 08:58:44 2015
@@ -99,6 +99,8 @@
 	void *resolver_data;
 	/*! \brief Result of the DNS query */
 	struct ast_dns_result *result;
+	/*! \brief If the query is recurring or not */
+	unsigned int recurring;
 	/*! \brief Timer for recurring resolution */
 	int timer;
 	/*! \brief Resource record type */

Modified: team/group/dns/main/dns_core.c
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/main/dns_core.c?view=diff&rev=432482&r1=432481&r2=432482
==============================================================================
--- team/group/dns/main/dns_core.c (original)
+++ team/group/dns/main/dns_core.c Thu Mar  5 08:58:44 2015
@@ -141,7 +141,7 @@
 	ast_dns_result_free(query->result);
 }
 
-struct ast_dns_query *ast_dns_resolve_async(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data)
+static struct ast_dns_query *dns_resolve_async(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data, unsigned int recurring)
 {
 	struct ast_dns_query *query;
 
@@ -149,12 +149,19 @@
 		return NULL;
 	}
 
-	query = ao2_alloc_options(sizeof(*query) + strlen(name) + 1, dns_query_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
+	if (!recurring) {
+		query = ao2_alloc_options(sizeof(*query) + strlen(name) + 1, dns_query_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
+	} else {
+		query = ao2_alloc(sizeof(*query) + strlen(name) + 1, dns_query_destroy);
+	}
+
 	if (!query) {
 		return NULL;
 	}
 
 	query->callback = callback;
+	query->user_data = ao2_bump(data);
+	query->recurring = recurring;
 	query->rr_type = rr_type;
 	query->rr_class = rr_class;
 	strcpy(query->name, name); /* SAFE */
@@ -180,9 +187,14 @@
 	return query;
 }
 
+struct ast_dns_query *ast_dns_resolve_async(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data)
+{
+	return dns_resolve_async(name, rr_type, rr_class, callback, data, 0);
+}
+
 struct ast_dns_query *ast_dns_resolve_async_recurring(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data)
 {
-	return NULL;
+	return dns_resolve_async(name, rr_type, rr_class, callback, data, 1);
 }
 
 int ast_dns_resolve_cancel(struct ast_dns_query *query)




More information about the asterisk-commits mailing list