summaryrefslogtreecommitdiff
path: root/funcs/func_lock.c
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2012-05-10 18:35:14 +0000
committerJonathan Rose <jrose@digium.com>2012-05-10 18:35:14 +0000
commit8227f70cd70f497cb03c1f9aab63950bcd979d8b (patch)
tree4f4587c0997f7a2d7ad8c6ecc89c3ad2971d5027 /funcs/func_lock.c
parent3430da58e9f168e608e46133225e0fc81589f6ef (diff)
Coverity Report: Fix issues for error type CHECKED_RETURN for core
(issue ASTERISK-19658) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/1905/ ........ Merged revisions 366094 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 366106 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366126 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs/func_lock.c')
-rw-r--r--funcs/func_lock.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/funcs/func_lock.c b/funcs/func_lock.c
index 38c3aea35..060fcb809 100644
--- a/funcs/func_lock.c
+++ b/funcs/func_lock.c
@@ -486,9 +486,11 @@ static int unload_module(void)
ast_custom_function_unregister(&trylock_function);
ast_custom_function_unregister(&unlock_function);
- pthread_cancel(broker_tid);
- pthread_kill(broker_tid, SIGURG);
- pthread_join(broker_tid, NULL);
+ if (broker_tid != AST_PTHREADT_NULL) {
+ pthread_cancel(broker_tid);
+ pthread_kill(broker_tid, SIGURG);
+ pthread_join(broker_tid, NULL);
+ }
AST_LIST_UNLOCK(&locklist);
@@ -500,7 +502,14 @@ static int load_module(void)
int res = ast_custom_function_register(&lock_function);
res |= ast_custom_function_register(&trylock_function);
res |= ast_custom_function_register(&unlock_function);
- ast_pthread_create_background(&broker_tid, NULL, lock_broker, NULL);
+
+ if (ast_pthread_create_background(&broker_tid, NULL, lock_broker, NULL)) {
+ ast_log(LOG_ERROR, "Failed to start lock broker thread. Unloading func_lock module.\n");
+ broker_tid = AST_PTHREADT_NULL;
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
return res;
}