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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 6 09:30:38 CST 2015


Author: file
Date: Fri Mar  6 09:30:35 2015
New Revision: 432517

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=432517
Log:
Change the resolver data to be an ao2 object.

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

Modified: team/group/dns/include/asterisk/dns_core.h
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/include/asterisk/dns_core.h?view=diff&rev=432517&r1=432516&r2=432517
==============================================================================
--- team/group/dns/include/asterisk/dns_core.h (original)
+++ team/group/dns/include/asterisk/dns_core.h Fri Mar  6 09:30:35 2015
@@ -208,6 +208,10 @@
  * \retval NULL failure
  *
  * \note The result passed to the callback does not need to be freed
+ *
+ * \note The user data MUST be an ao2 object
+ *
+ * \note This function increments the reference count of the user data, it does NOT steal
  */
 struct ast_dns_query *ast_dns_resolve_async(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data);
 

Modified: team/group/dns/include/asterisk/dns_resolver.h
URL: http://svnview.digium.com/svn/asterisk/team/group/dns/include/asterisk/dns_resolver.h?view=diff&rev=432517&r1=432516&r2=432517
==============================================================================
--- team/group/dns/include/asterisk/dns_resolver.h (original)
+++ team/group/dns/include/asterisk/dns_resolver.h Fri Mar  6 09:30:35 2015
@@ -48,9 +48,16 @@
  * \param query The DNS query
  * \param data The resolver specific data
  *
- * \note Unlike user specific data this does not have to be ao2 allocated
+ * \note The resolver data MUST be an ao2 object
+ *
+ * \note This function increments the reference count of the resolver data, it does NOT steal
+ *
+ * \note Once resolver specific data has been set it can not be changed
+ *
+ * \retval 0 success
+ * \retval -1 failure, resolver data is already set
  */
-void ast_dns_resolver_set_data(struct ast_dns_query *query, void *data);
+int ast_dns_resolver_set_data(struct ast_dns_query *query, void *data);
 
 /*!
  * \brief Retrieve resolver specific data

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=432517&r1=432516&r2=432517
==============================================================================
--- team/group/dns/main/dns_core.c (original)
+++ team/group/dns/main/dns_core.c Fri Mar  6 09:30:35 2015
@@ -141,7 +141,7 @@
 	struct ast_dns_query *query = data;
 
 	ao2_cleanup(query->user_data);
-	ast_assert(query->resolver_data == NULL);
+	ao2_cleanup(query->resolver_data);
 	ast_dns_result_free(query->result);
 }
 
@@ -326,9 +326,15 @@
 	return NULL;
 }
 
-void ast_dns_resolver_set_data(struct ast_dns_query *query, void *data)
-{
-	query->resolver_data = data;
+int ast_dns_resolver_set_data(struct ast_dns_query *query, void *data)
+{
+	if (query->resolver_data) {
+		return -1;
+	}
+
+	query->resolver_data = ao2_bump(data);
+
+	return 0;
 }
 
 void *ast_dns_resolver_get_data(const struct ast_dns_query *query)




More information about the asterisk-commits mailing list