summaryrefslogtreecommitdiff
path: root/tests/test_dns_query_set.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-04-22 13:28:09 -0300
committerJoshua Colp <jcolp@digium.com>2015-04-22 13:28:09 -0300
commit7216e3c60875442df3467acd3561d4a0e2680673 (patch)
treee8cf61295cf7f0fff1aa8b93c52cf6fe304f645c /tests/test_dns_query_set.c
parent46950d6901ec69436483360796aae5e48e1094df (diff)
dns: Make query sets hold on to queries for their lifetime.
The query set documentation states that upon completion queries can be retrieved for the lifetime of the query set. This is a reasonable expectation but does not currently occur. This was originally done to resolve a circular reference between queries and query sets, but in practice the query can be kept. This change makes it so a query does not have a reference to the query set until it begins resolving. It also makes it so that the reference is given up upon the query being completed. This allows the queries to remain for the lifetime of the query set. As the query set on the query is only useful to the query set functionality and only for the lifetime that the query is resolving this is safe to do. ASTERISK-24994 #close Reported by: Joshua Colp Change-Id: I54e09c0cb45475896654e7835394524e816d1aa0
Diffstat (limited to 'tests/test_dns_query_set.c')
-rw-r--r--tests/test_dns_query_set.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/test_dns_query_set.c b/tests/test_dns_query_set.c
index 08829f59e..9acf1bf81 100644
--- a/tests/test_dns_query_set.c
+++ b/tests/test_dns_query_set.c
@@ -131,9 +131,14 @@ static int query_set_resolve(struct ast_dns_query *query)
static int query_set_cancel(struct ast_dns_query *query)
{
struct ast_dns_query_set *query_set = ast_dns_query_get_data(query);
- struct query_set_data *qsdata = query_set->user_data;
+ struct query_set_data *qsdata;
int res = -1;
+ if (!query_set) {
+ return -1;
+ }
+ qsdata = query_set->user_data;
+
if (qsdata->cancel++ < qsdata->cancel_allowed) {
res = 0;
}