aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_calendar_caldav.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_calendar_caldav.c')
-rw-r--r--res/res_calendar_caldav.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/res/res_calendar_caldav.c b/res/res_calendar_caldav.c
index 64f8f2aa1..2b3f5a334 100644
--- a/res/res_calendar_caldav.c
+++ b/res/res_calendar_caldav.c
@@ -536,11 +536,12 @@ static int verify_cert(void *userdata, int failures, const ne_ssl_certificate *c
static void *caldav_load_calendar(void *void_data)
{
struct caldav_pvt *pvt;
+ const struct ast_config *cfg;
struct ast_variable *v;
struct ast_calendar *cal = void_data;
ast_mutex_t refreshlock;
- if (!(cal && ast_calendar_config)) {
+ if (!(cal && (cfg = ast_calendar_config_acquire()))) {
ast_log(LOG_ERROR, "You must enable calendar support for res_caldav to load\n");
return NULL;
}
@@ -551,11 +552,13 @@ static void *caldav_load_calendar(void *void_data)
} else {
ast_log(LOG_WARNING, "Could not lock calendar, aborting!\n");
}
+ ast_calendar_config_release();
return NULL;
}
if (!(pvt = ao2_alloc(sizeof(*pvt), caldav_destructor))) {
ast_log(LOG_ERROR, "Could not allocate caldav_pvt structure for calendar: %s\n", cal->name);
+ ast_calendar_config_release();
return NULL;
}
@@ -565,6 +568,7 @@ static void *caldav_load_calendar(void *void_data)
ast_log(LOG_ERROR, "Could not allocate space for fetching events for calendar: %s\n", cal->name);
pvt = unref_caldav(pvt);
ao2_unlock(cal);
+ ast_calendar_config_release();
return NULL;
}
@@ -572,10 +576,11 @@ static void *caldav_load_calendar(void *void_data)
ast_log(LOG_ERROR, "Couldn't allocate string field space for calendar: %s\n", cal->name);
pvt = unref_caldav(pvt);
ao2_unlock(cal);
+ ast_calendar_config_release();
return NULL;
}
- for (v = ast_variable_browse(ast_calendar_config, cal->name); v; v = v->next) {
+ for (v = ast_variable_browse(cfg, cal->name); v; v = v->next) {
if (!strcasecmp(v->name, "url")) {
ast_string_field_set(pvt, url, v->value);
} else if (!strcasecmp(v->name, "user")) {
@@ -585,6 +590,8 @@ static void *caldav_load_calendar(void *void_data)
}
}
+ ast_calendar_config_release();
+
if (ast_strlen_zero(pvt->url)) {
ast_log(LOG_WARNING, "No URL was specified for CalDAV calendar '%s' - skipping.\n", cal->name);
pvt = unref_caldav(pvt);