[Asterisk-code-review] First draft to force calendars to do new fetch after module ... (asterisk[master])
Ludovic Gasc (Eyepea)
asteriskteam at digium.com
Thu Sep 29 12:48:55 CDT 2016
Ludovic Gasc (Eyepea) has uploaded a new change for review.
https://gerrit.asterisk.org/3998
Change subject: First draft to force calendars to do new fetch after module reload
......................................................................
First draft to force calendars to do new fetch after module reload
Change-Id: I384b02ebfa42b142bbbd5b7221458c7f4dee7077
---
M configs/samples/calendar.conf.sample
M include/asterisk/calendar.h
M res/res_calendar.c
3 files changed, 7 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/98/3998/1
diff --git a/configs/samples/calendar.conf.sample b/configs/samples/calendar.conf.sample
index 82b8702..d87b3b2 100644
--- a/configs/samples/calendar.conf.sample
+++ b/configs/samples/calendar.conf.sample
@@ -6,6 +6,8 @@
;refresh = 15 ; refresh calendar every n minutes
;timeframe = 60 ; number of minutes of calendar data to pull for each refresh period
; ; should always be >= refresh
+;fetch_again_at_reload = no ; to reload the calendar content when the module is reloaded
+;
;
; You can set up res_calendar to execute a call upon an upcoming busy status
; The following fields are available from the ${CALENDAR_EVENT(<field>)} dialplan function:
diff --git a/include/asterisk/calendar.h b/include/asterisk/calendar.h
index da4af01..e9dcd88 100644
--- a/include/asterisk/calendar.h
+++ b/include/asterisk/calendar.h
@@ -129,6 +129,7 @@
int autoreminder; /*!< If set, override any calendar_tech specific notification times and use this time (in mins) */
int notify_waittime; /*!< Maxiumum time to allow for a notification attempt */
int refresh; /*!< When to refresh the calendar events */
+ int fetch_again_at_reload; /*!< To reload the calendar content when the module is reloaded */
int timeframe; /*!< Span (in mins) of calendar data to pull with each request */
pthread_t thread; /*!< The thread that the calendar is loaded/updated in */
ast_cond_t unload;
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 6f6f711..029eceb 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -436,6 +436,7 @@
cal->refresh = 3600;
cal->timeframe = 60;
cal->notify_waittime = 30000;
+ cal->fetch_again_at_reload = 0;
for (v = ast_variable_browse(cfg, cat); v; v = v->next) {
if (!strcasecmp(v->name, "autoreminder")) {
@@ -457,6 +458,8 @@
ast_string_field_set(cal, notify_appdata, v->value);
} else if (!strcasecmp(v->name, "refresh")) {
cal->refresh = atoi(v->value);
+ } else if (!strcasecmp(v->name, "fetch_again_at_reload")) {
+ cal->fetch_again_at_reload = ast_true(v->value);
} else if (!strcasecmp(v->name, "timeframe")) {
cal->timeframe = atoi(v->value);
} else if (!strcasecmp(v->name, "setvar")) {
@@ -482,7 +485,7 @@
}
}
- if (new_calendar) {
+ if (new_calendar || cal->fetch_again_at_reload) {
cal->thread = AST_PTHREADT_NULL;
ast_cond_init(&cal->unload, NULL);
ao2_link(calendars, cal);
--
To view, visit https://gerrit.asterisk.org/3998
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I384b02ebfa42b142bbbd5b7221458c7f4dee7077
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Ludovic Gasc (Eyepea) <gmludo at gmail.com>
More information about the asterisk-code-review
mailing list