diff options
author | twilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-25 18:01:08 +0000 |
---|---|---|
committer | twilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-01-25 18:01:08 +0000 |
commit | 403a249ddb3a4046a0c0d26d3b1e7826306e4736 (patch) | |
tree | 4e65b7713797a0b9e7efb4f1bc1cb3819e2c8977 /res/res_calendar.c | |
parent | dbf9257276656ab5737eedf014a9784d9d4f8742 (diff) |
Fix INTERNAL_OBJ error on stop when calendars.conf missing
Initialize the calendars container before calling load_config and return FAILURE
on allocation failure. Also, use the AST_MODULE_LOAD_* values for return values.
Thanks to rmudgett for pointing out the error and the need to use the defined
values for return
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@242812 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_calendar.c')
-rw-r--r-- | res/res_calendar.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/res/res_calendar.c b/res/res_calendar.c index 7d5721b10..a8c5ee784 100644 --- a/res/res_calendar.c +++ b/res/res_calendar.c @@ -1647,14 +1647,14 @@ static int unload_module(void) static int load_module(void) { - if (load_config(NULL)) { - /* We don't have calendar support enabled */ - return 0; - } - if (!(calendars = ao2_container_alloc(CALENDAR_BUCKETS, calendar_hash_fn, calendar_cmp_fn))) { ast_log(LOG_ERROR, "Unable to allocate calendars container!\n"); - return -1; + return AST_MODULE_LOAD_FAILURE; + } + + if (load_config(NULL)) { + /* We don't have calendar support enabled */ + return AST_MODULE_LOAD_DECLINE; } ast_mutex_init(&refreshlock); @@ -1663,7 +1663,7 @@ static int load_module(void) if (!(sched = sched_context_create())) { ast_log(LOG_ERROR, "Unable to create sched context\n"); - return -1; + return AST_MODULE_LOAD_FAILURE; } if (ast_pthread_create_background(&refresh_thread, NULL, do_refresh, NULL) < 0) { @@ -1682,7 +1682,7 @@ static int load_module(void) /* Since other modules depend on this, disable unloading */ ast_module_ref(ast_module_info->self); - return 0; + return AST_MODULE_LOAD_SUCCESS; } AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Asterisk Calendar integration", .load = load_module, |