From: Terry Wilson Date: Mon, 25 Jan 2010 18:01:08 +0000 (+0000) Subject: Fix INTERNAL_OBJ error on stop when calendars.conf missing X-Git-Tag: 11.0.0-beta1~3536 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb65a6860ae03f48e233f0a50f1184343b41aad6;p=thirdparty%2Fasterisk.git 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: https://origsvn.digium.com/svn/asterisk/trunk@242812 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/res/res_calendar.c b/res/res_calendar.c index 7d5721b10c..a8c5ee7849 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,