Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Voice
asterisk
Commits
45b8a2be
Commit
45b8a2be
authored
9 years ago
by
Matt Jordan
Committed by
Gerrit Code Review
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge "dns: Fix crash when invoking cancel in DNS recurring unit test."
parents
a889cfa0
f1843664
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main/dns_recurring.c
+16
-8
16 additions, 8 deletions
main/dns_recurring.c
with
16 additions
and
8 deletions
main/dns_recurring.c
+
16
−
8
View file @
45b8a2be
...
...
@@ -73,10 +73,21 @@ static int dns_query_recurring_scheduled_callback(const void *data)
static
void
dns_query_recurring_resolution_callback
(
const
struct
ast_dns_query
*
query
)
{
struct
ast_dns_query_recurring
*
recurring
=
ast_dns_query_get_data
(
query
);
/* Replace the user data so the actual callback sees what it provided */
((
struct
ast_dns_query
*
)
query
)
->
user_data
=
ao2_bump
(
recurring
->
user_data
);
recurring
->
callback
(
query
);
struct
ast_dns_query
*
callback_query
;
/* Create a separate query to invoke the user specific callback on as the
* recurring query user data may get used externally (by the unit test)
* and thus changing it is problematic
*/
callback_query
=
dns_query_alloc
(
query
->
name
,
query
->
rr_type
,
query
->
rr_class
,
recurring
->
callback
,
recurring
->
user_data
);
if
(
callback_query
)
{
/* The result is immutable at this point and can be safely provided */
callback_query
->
result
=
query
->
result
;
callback_query
->
callback
(
callback_query
);
callback_query
->
result
=
NULL
;
ao2_ref
(
callback_query
,
-
1
);
}
ao2_lock
(
recurring
);
/* So.. if something has not externally cancelled this we can reschedule based on the TTL */
...
...
@@ -87,7 +98,7 @@ static void dns_query_recurring_resolution_callback(const struct ast_dns_query *
if
(
ttl
)
{
recurring
->
timer
=
ast_sched_add
(
ast_dns_get_sched
(),
ttl
*
1000
,
dns_query_recurring_scheduled_callback
,
ao2_bump
(
recurring
));
if
(
recurring
->
timer
<
0
)
{
/* It is impossible for this to be the last reference as th
is callback function hold
s a reference
itself
*/
/* It is impossible for this to be the last reference as th
e query ha
s a reference
to it
*/
ao2_ref
(
recurring
,
-
1
);
}
}
...
...
@@ -95,9 +106,6 @@ static void dns_query_recurring_resolution_callback(const struct ast_dns_query *
ao2_replace
(
recurring
->
active
,
NULL
);
ao2_unlock
(
recurring
);
/* Since we stole the reference from the query we need to drop it ourselves */
ao2_ref
(
recurring
,
-
1
);
}
struct
ast_dns_query_recurring
*
ast_dns_resolve_recurring
(
const
char
*
name
,
int
rr_type
,
int
rr_class
,
ast_dns_resolve_callback
callback
,
void
*
data
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment