[Home]

Summary:ASTERISK-16744: Problems with loading of res_calendar and its sister modules
Reporter:Leif Madsen (lmadsen)Labels:
Date Opened:2010-09-28 07:31:16Date Closed:2012-01-31 18:23:28.000-0600
Priority:MinorRegression?
Status:Closed/CompleteComponents:Resources/res_calendar
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:
Description:Yesterday and today while trying to document the res_calendar modules, I've run into some problems with the loading of the modules after Asterisk has been started (which typically leads into a problem with having to reload all modules or restarting Asterisk).

More information in Steps To Reproduce.

****** STEPS TO REPRODUCE ******

First, start Asterisk with no calendar.conf file (or rename it to calendar.conf.bak)

Then from the *CLI> do:

*CLI> !mv calendar.conf.bak calendar.conf

At this point, I can't seem to figure out what order the modules expect to load. It seems res_calendar.so will always load, regardless as to whether we have a calendar.conf file or not, which is not what I would expect. The expectation would be a WARNING at load time that states calendar.conf is missing, and res_calendar.so cannot be loaded.

So if I try to reload the res_calendar.so module, that works fine, but my calendar does not load into memory.

I also cannot seem to reload the res_calendar sister modules, such as res_calendar_caldav.so as it does not support reloads. If I try to unload the module, it tells me the module is not loaded, but if I try to load it, it says the caldav functionality is already being provided by another module.

****** ADDITIONAL INFORMATION ******

The work around for this seems to be to unload res_calendar.so from the console, then do a "module reload" and then it seems to pick up the settings and loads from calendar.conf, which imports my calendar into memory.
Comments:By: Terry Wilson (twilson) 2012-01-04 18:03:26.570-0600

All reloads for the calendar modules are done through the main res_calendar module. There is no way to reload individual calendar modules. I've also looked at the code and tested and res_calendar.so when there is no calendar.conf file. It displays an ERROR:

[Jan  4 19:43:04] ERROR[18942]: res_calendar.c:970 load_config: Unable to load config calendar.conf

and load_module returns AST_MODULE_LOAD_DECLINE, which is documented in module.h as "Module is not configured". This is the exact same behavior that chan_sip shows when there is no sip.conf. After creating the config, you have to do a 'load module res_calendar.so' just like you would have to do a 'load module chan_sip.so'.

If loading manually, one would need to load res_calendar.so (with a valid config file), then, unfortunately, do a module reload res_calendar.so...this is ugly. There is only one config file for all calendar types, and all parsing is done through res_calendar--which is why reloads are done from there. Since you've done something silly (loaded the module w/o a config file), the tech module will have registered (w/o a config) and returned AST_MODULE_LOAD_DECLINE. Since there *is* no reload in the module, it is fine...it just needs to be reloaded from the main module...which means there is an ugly load && reload that has to be done on res_calendar.so.

The only return value from load_module that we can do to stop things would be AST_MODULE_LOAD_FAILURE...but that completely keeps Asterisk from starting, which we don't want. I don't really want to add reloads for the individual modules, either since they would all have to parse the whole config file anyway.

SO. I'm thinking the moral of this story is...don't try to use res_calendar without a calendar.conf file. Everything works fine w/o the file if you don't want to use calendars and works fine if you do have a calendar.conf and want to use calendars. If you want to manually mess with stuff, load the res_calendar.so then do module reload res_calendar.so to pick the calendars.

Can I close this? :-)