[Asterisk-code-review] res pjsip registrar expire: Fix race condition at shutdown. (asterisk[master])
Anonymous Coward
asteriskteam at digium.com
Thu Apr 7 15:10:44 CDT 2016
Anonymous Coward #1000019 has submitted this change and it was merged.
Change subject: res_pjsip_registrar_expire: Fix race condition at shutdown.
......................................................................
res_pjsip_registrar_expire: Fix race condition at shutdown.
When shutting down, the PJSIP sorcery is destroyed. The registrar
expiration module queries the PJSIP sorcery to determine what
to expire. As there was no synchronization between termination
of the expiration thread and the unloading of the module it was
possible for the thread to try to access the PJSIP sorcery after
it had been destroyed.
This change ensures that the thread is shut down before allowing
the module to be considered unloaded.
Change-Id: I69fd239edbaaf160c2d37ae00d3ac06e5596fe8b
---
M res/res_pjsip_registrar_expire.c
1 file changed, 4 insertions(+), 0 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Anonymous Coward #1000019: Verified
Joshua Colp: Looks good to me, approved
George Joseph: Looks good to me, but someone else must approve
diff --git a/res/res_pjsip_registrar_expire.c b/res/res_pjsip_registrar_expire.c
index 87edf53..e52363e 100644
--- a/res/res_pjsip_registrar_expire.c
+++ b/res/res_pjsip_registrar_expire.c
@@ -91,6 +91,7 @@
} else {
if (check_thread != AST_PTHREADT_NULL) {
pthread_kill(check_thread, SIGURG);
+ pthread_join(check_thread, NULL);
check_thread = AST_PTHREADT_NULL;
ast_debug(3, "Interval = 0, shutting thread down\n");
}
@@ -105,7 +106,10 @@
static int unload_module(void)
{
if (check_thread != AST_PTHREADT_NULL) {
+ check_interval = 0;
pthread_kill(check_thread, SIGURG);
+ pthread_join(check_thread, NULL);
+
check_thread = AST_PTHREADT_NULL;
}
--
To view, visit https://gerrit.asterisk.org/2544
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I69fd239edbaaf160c2d37ae00d3ac06e5596fe8b
Gerrit-PatchSet: 3
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list