diff options
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_devstate.c | 1 | ||||
-rw-r--r-- | funcs/func_lock.c | 17 |
2 files changed, 14 insertions, 4 deletions
diff --git a/funcs/func_devstate.c b/funcs/func_devstate.c index 1b1318a5d..e1f34387a 100644 --- a/funcs/func_devstate.c +++ b/funcs/func_devstate.c @@ -187,6 +187,7 @@ static enum ast_device_state custom_devstate_callback(const char *data) { char buf[256] = ""; + /* Ignore check_return warning from Coverity fow ast_db_get below */ ast_db_get(astdb_family, data, buf, sizeof(buf)); return ast_devstate_val(buf); 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; } |