Merged revisions 334013 via svnmerge from
authorRichard Mudgett <rmudgett@digium.com>
Wed, 31 Aug 2011 16:02:11 +0000 (16:02 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 31 Aug 2011 16:02:11 +0000 (16:02 +0000)
https://origsvn.digium.com/svn/asterisk/branches/10

................
  r334013 | rmudgett | 2011-08-31 11:00:49 -0500 (Wed, 31 Aug 2011) | 30 lines

  Merged revisions 334012 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.8

  ........
    r334012 | rmudgett | 2011-08-31 10:57:12 -0500 (Wed, 31 Aug 2011) | 23 lines

    No DAHDI channel available for conference, user introduction disabled.

    The following error will consistently occur when trying to dial into a
    MeetMe conference when the server does not have DAHDI hardware installed:

    app_meetme.c: No DAHDI channel available for conference, user introduction
    disabled (is chan_dahdi loaded?)

    While chan_dahdi is loaded correctly during compilation and install of
    Asterisk/Dahdi, including associated modules, etc., a chan_dahdi.conf
    configuration file in /etc/asterisk is not created by FreePBX if hardware
    does not exist, causing MeetMe to be unable to open a DAHDI pseudo
    channel.

    * Allow chan_dahdi to create a pseudo channel when there is no
    chan_dahdi.conf file to load.

    (closes issue ASTERISK-17398)
    Reported by: Preston Edwards
    Patches:
          jira_asterisk_17398_v1.8.patch (license #5621) patch uploaded by rmudgett
    Tested by: rmudgett
  ........
................

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@334014 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c

index 450f9de..4d5e821 100644 (file)
@@ -18216,23 +18216,56 @@ static int setup_dahdi_int(int reload, struct dahdi_chan_conf *default_conf, str
        int trunkgroup;
        int dchannels[SIG_PRI_NUM_DCHANS];
 #endif
+       int have_cfg_now;
+       static int had_cfg_before = 1;/* So initial load will complain if we don't have cfg. */
 
        cfg = ast_config_load(config, config_flags);
-
-       /* Error if we have no config file */
+       have_cfg_now = !!cfg;
        if (!cfg) {
-               ast_log(LOG_ERROR, "Unable to load config %s\n", config);
-               return 0;
+               /* Error if we have no config file */
+               if (had_cfg_before) {
+                       ast_log(LOG_ERROR, "Unable to load config %s\n", config);
+                       ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
+               }
+               cfg = ast_config_new();/* Dummy config */
+               if (!cfg) {
+                       return 0;
+               }
+               ucfg = ast_config_load("users.conf", config_flags);
+               if (ucfg == CONFIG_STATUS_FILEUNCHANGED) {
+                       ast_config_destroy(cfg);
+                       return 0;
+               }
+               if (ucfg == CONFIG_STATUS_FILEINVALID) {
+                       ast_log(LOG_ERROR, "File users.conf cannot be parsed.  Aborting.\n");
+                       ast_config_destroy(cfg);
+                       return 0;
+               }
        } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) {
                ucfg = ast_config_load("users.conf", config_flags);
                if (ucfg == CONFIG_STATUS_FILEUNCHANGED) {
                        return 0;
-               } else if (ucfg == CONFIG_STATUS_FILEINVALID) {
+               }
+               if (ucfg == CONFIG_STATUS_FILEINVALID) {
                        ast_log(LOG_ERROR, "File users.conf cannot be parsed.  Aborting.\n");
                        return 0;
                }
                ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
-               if ((cfg = ast_config_load(config, config_flags)) == CONFIG_STATUS_FILEINVALID) {
+               cfg = ast_config_load(config, config_flags);
+               have_cfg_now = !!cfg;
+               if (!cfg) {
+                       if (had_cfg_before) {
+                               /* We should have been able to load the config. */
+                               ast_log(LOG_ERROR, "Bad. Unable to load config %s\n", config);
+                               ast_config_destroy(ucfg);
+                               return 0;
+                       }
+                       cfg = ast_config_new();/* Dummy config */
+                       if (!cfg) {
+                               ast_config_destroy(ucfg);
+                               return 0;
+                       }
+               } else if (cfg == CONFIG_STATUS_FILEINVALID) {
                        ast_log(LOG_ERROR, "File %s cannot be parsed.  Aborting.\n", config);
                        ast_config_destroy(ucfg);
                        return 0;
@@ -18242,12 +18275,14 @@ static int setup_dahdi_int(int reload, struct dahdi_chan_conf *default_conf, str
                return 0;
        } else {
                ast_clear_flag(&config_flags, CONFIG_FLAG_FILEUNCHANGED);
-               if ((ucfg = ast_config_load("users.conf", config_flags)) == CONFIG_STATUS_FILEINVALID) {
+               ucfg = ast_config_load("users.conf", config_flags);
+               if (ucfg == CONFIG_STATUS_FILEINVALID) {
                        ast_log(LOG_ERROR, "File users.conf cannot be parsed.  Aborting.\n");
                        ast_config_destroy(cfg);
                        return 0;
                }
        }
+       had_cfg_before = have_cfg_now;
 
        /* It's a little silly to lock it, but we might as well just to be sure */
        ast_mutex_lock(&iflock);