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
b1305170
Commit
b1305170
authored
6 years ago
by
Joshua C. Colp
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "res_pjsip_registrar: mitigate blocked threads on reliable transport shutdown" into 13
parents
b9b095bb
2e1cbcde
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_pjsip_registrar.c
+30
-0
30 additions, 0 deletions
res/res_pjsip_registrar.c
with
30 additions
and
0 deletions
res/res_pjsip_registrar.c
+
30
−
0
View file @
b1305170
...
...
@@ -318,6 +318,8 @@ struct contact_transport_monitor {
* \note Stored after aor_name in space reserved when struct allocated.
*/
char
*
contact_name
;
/*! Indicates that the monitor is in the process of removing a contact */
int
removing
;
/*! AOR name the contact is associated */
char
aor_name
[
0
];
};
...
...
@@ -344,6 +346,20 @@ static int register_contact_transport_remove_cb(void *data)
}
ao2_lock
(
lock
);
/*
* We're now locked so check again to make sure some other thread is not
* currently removing the contact, or already has.
*/
if
(
monitor
->
removing
)
{
ao2_unlock
(
lock
);
ast_named_lock_put
(
lock
);
ao2_ref
(
monitor
,
-
1
);
return
0
;
}
monitor
->
removing
=
1
;
contact
=
ast_sip_location_retrieve_contact
(
monitor
->
contact_name
);
if
(
contact
)
{
ast_sip_location_delete_contact
(
contact
);
...
...
@@ -358,6 +374,7 @@ static int register_contact_transport_remove_cb(void *data)
contact
->
user_agent
);
ao2_ref
(
contact
,
-
1
);
}
ao2_unlock
(
lock
);
ast_named_lock_put
(
lock
);
...
...
@@ -379,6 +396,19 @@ static void register_contact_transport_shutdown_cb(void *data)
{
struct
contact_transport_monitor
*
monitor
=
data
;
/*
* It's possible for this shutdown handler to get called multiple times for the
* same monitor from different threads. Only one of the calls needs to do the
* actual removing of the contact, so if one is currently removing then any
* subsequent calls can skip.
*
* We'll call it non locked here, but check again once locked just in case the
* flag was updated (see register_contact_transport_remove_cb).
*/
if
(
monitor
->
removing
)
{
return
;
}
/*
* Push off to a default serializer. This is in case sorcery
* does database accesses for contacts. Database accesses may
...
...
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