Review Board 1.7.16


Add a new option "require" to modules.conf to make Asterisk fail if a module does not load

Review Request #426 - Created Nov. 12, 2009 and submitted

Olle E Johansson
trunk
Reviewers
asterisk-dev
Asterisk
If a module for some reason fail to load - compiled with the wrong build system, failure to load required library or something else, then Asterisk currently proceeds, regardless of configuration in modules.conf.

This patch adds "require=<module>" and "preload-require=<module>" but not "noload-require <module>" :-)

If the module doesn't load, Asterisk will print a message to stderr and then exit with the status of 2, so that scripts like safe_asterisk and similar can catch this situation. I don't want my Asterisk to run without chan_sip - AT ALL, which is a reason for this patch.
Tested with preload-require and require on my own development system and some old modules that gives strange load errors and fail to load.

Noticed that logging to ERROR doesn't always get logged, since Asterisk exits, so I added the fprintf(stderr,"....");
/trunk/configs/modules.conf.sample
Revision 229637 New Change
[20] 18 lines
[+20]
19
;preload => res_config_odbc.so
19
;preload => res_config_odbc.so
20
;
20
;
21
; Uncomment the following if you wish to use the Speech Recognition API
21
; Uncomment the following if you wish to use the Speech Recognition API
22
;preload => res_speech.so
22
;preload => res_speech.so
23
;
23
;

    
   
24
; If you want Asterisk to fail if a module does not load, then use

    
   
25
; the "require" keyword. Asterisk will exit with a status code of 2

    
   
26
; if a required module does not load.

    
   
27
;

    
   
28
; require = chan_sip.so

    
   
29
; If you want you can combine with preload

    
   
30
; preload-require = res_odbc.so

    
   
31
;
24
; If you want, load the GTK console right away.
32
; If you want, load the GTK console right away.
25
;
33
;
26
noload => pbx_gtkconsole.so
34
noload => pbx_gtkconsole.so
27
;load => pbx_gtkconsole.so
35
;load => pbx_gtkconsole.so
28
;
36
;
[+20] [20] 9 lines
/trunk/main/asterisk.c
Revision 229637 New Change
 
/trunk/main/loader.c
Revision 229637 New Change
 
  1. /trunk/configs/modules.conf.sample: Loading...
  2. /trunk/main/asterisk.c: Loading...
  3. /trunk/main/loader.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.