summaryrefslogtreecommitdiff
path: root/res/res_calendar_icalendar.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_calendar_icalendar.c')
-rw-r--r--res/res_calendar_icalendar.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/res/res_calendar_icalendar.c b/res/res_calendar_icalendar.c
index 86024b27a..97c3253ab 100644
--- a/res/res_calendar_icalendar.c
+++ b/res/res_calendar_icalendar.c
@@ -324,11 +324,12 @@ static void icalendar_add_event(icalcomponent *comp, struct icaltime_span *span,
static void *ical_load_calendar(void *void_data)
{
struct icalendar_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_icalendar to load\n");
return NULL;
}
@@ -338,11 +339,13 @@ static void *ical_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), icalendar_destructor))) {
ast_log(LOG_ERROR, "Could not allocate icalendar_pvt structure for calendar: %s\n", cal->name);
+ ast_calendar_config_release();
return NULL;
}
@@ -352,6 +355,7 @@ static void *ical_load_calendar(void *void_data)
ast_log(LOG_ERROR, "Could not allocate space for fetching events for calendar: %s\n", cal->name);
pvt = unref_icalendar(pvt);
ao2_unlock(cal);
+ ast_calendar_config_release();
return NULL;
}
@@ -359,10 +363,11 @@ static void *ical_load_calendar(void *void_data)
ast_log(LOG_ERROR, "Couldn't allocate string field space for calendar: %s\n", cal->name);
pvt = unref_icalendar(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")) {
@@ -372,6 +377,8 @@ static void *ical_load_calendar(void *void_data)
}
}
+ ast_calendar_config_release();
+
if (ast_strlen_zero(pvt->url)) {
ast_log(LOG_WARNING, "No URL was specified for iCalendar '%s' - skipping.\n", cal->name);
pvt = unref_icalendar(pvt);