summaryrefslogtreecommitdiff
path: root/main/optional_api.c
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-08-30 20:58:59 +0000
committerDavid M. Lee <dlee@digium.com>2013-08-30 20:58:59 +0000
commit2d1d5a98d587f30311e254c7de623434dff07dd1 (patch)
treecc4f15e91dc7ccd3df726f7f6af98355c76347a5 /main/optional_api.c
parentbe219c9ec9bcb1e54b8eed5ffaf7bced2f34abc4 (diff)
Fix graceful shutdown crash.
The cleanup code for optional_api needs to happen after all of the optional API users and providers have unused/unprovided. Unfortunately, regsitering the atexit() handler at the beginning of main() isn't soon enough, since module destructors run after that. ........ Merged revisions 398149 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398150 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/optional_api.c')
-rw-r--r--main/optional_api.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/main/optional_api.c b/main/optional_api.c
index f48fe11a1..9c96fa646 100644
--- a/main/optional_api.c
+++ b/main/optional_api.c
@@ -158,18 +158,8 @@ struct {
size_t len;
} apis;
-void optional_api_cleanup(void)
-{
- while (apis.len--) {
- optional_api_destroy(apis.list[apis.len]);
- }
- free(apis.list);
- apis.list = NULL;
- apis.maxlen = 0;
-}
-
/*!
- * \brief Gets (or creates) the \ref optional_api for the give function.
+ * \brief Gets (or creates) the \ref optional_api for the given function.
*
* \param sysname Name of the function to look up.
* \return Corresponding \ref optional_api.
@@ -181,9 +171,11 @@ static struct optional_api *get_api(const char *symname)
size_t i;
/* Find one, if we already have it */
- for (i = 0; i < apis.len; ++i) {
- if (strcmp(symname, apis.list[i]->symname) == 0) {
- return apis.list[i];
+ if (apis.list) {
+ for (i = 0; i < apis.len; ++i) {
+ if (strcmp(symname, apis.list[i]->symname) == 0) {
+ return apis.list[i];
+ }
}
}