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
cb45aa1f
Commit
cb45aa1f
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: lock transport monitor when setting 'removing' flag" into 13
parents
d496bf20
3974633c
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
res/res_pjsip_registrar.c
+12
-18
12 additions, 18 deletions
res/res_pjsip_registrar.c
with
12 additions
and
18 deletions
res/res_pjsip_registrar.c
+
12
−
18
View file @
cb45aa1f
...
...
@@ -341,25 +341,15 @@ static int register_contact_transport_remove_cb(void *data)
lock
=
ast_named_lock_get
(
AST_NAMED_LOCK_TYPE_MUTEX
,
"aor"
,
monitor
->
aor_name
);
if
(
!
lock
)
{
ao2_lock
(
monitor
);
monitor
->
removing
=
0
;
ao2_unlock
(
monitor
);
ao2_ref
(
monitor
,
-
1
);
return
0
;
}
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
);
...
...
@@ -401,14 +391,15 @@ static void register_contact_transport_shutdown_cb(void *data)
* 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).
*/
ao2_lock
(
monitor
);
if
(
monitor
->
removing
)
{
ao2_unlock
(
monitor
);
return
;
}
monitor
->
removing
=
1
;
/*
* Push off to a default serializer. This is in case sorcery
* does database accesses for contacts. Database accesses may
...
...
@@ -417,8 +408,11 @@ static void register_contact_transport_shutdown_cb(void *data)
*/
ao2_ref
(
monitor
,
+
1
);
if
(
ast_sip_push_task
(
NULL
,
register_contact_transport_remove_cb
,
monitor
))
{
monitor
->
removing
=
0
;
ao2_ref
(
monitor
,
-
1
);
}
ao2_unlock
(
monitor
);
}
AST_VECTOR
(
excess_contact_vector
,
struct
ast_sip_contact
*
);
...
...
@@ -729,8 +723,8 @@ static void register_aor_core(pjsip_rx_data *rdata,
* the contact won't be valid anymore if that happens.
*/
contact_name
=
ast_sorcery_object_get_id
(
contact
);
monitor
=
ao2_alloc
_options
(
sizeof
(
*
monitor
)
+
2
+
strlen
(
aor_name
)
+
strlen
(
contact_name
),
NULL
,
AO2_ALLOC_OPT_LOCK_NOLOCK
);
monitor
=
ao2_alloc
(
sizeof
(
*
monitor
)
+
2
+
strlen
(
aor_name
)
+
strlen
(
contact_name
),
NULL
);
if
(
monitor
)
{
strcpy
(
monitor
->
aor_name
,
aor_name
);
/* Safe */
monitor
->
contact_name
=
monitor
->
aor_name
+
strlen
(
aor_name
)
+
1
;
...
...
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