/**
* initialize FS core from optional configuration dir
*/
-static void fst_init_core_and_modload(const char *confdir, const char *basedir, int minimal)
+static switch_status_t fst_init_core_and_modload(const char *confdir, const char *basedir, int minimal)
{
const char *err;
// Let FreeSWITCH core pick these
switch_core_set_globals();
if (!minimal) {
- switch_core_init_and_modload(0, SWITCH_TRUE, &err);
+ switch_status_t status = switch_core_init_and_modload(0, SWITCH_TRUE, &err);
switch_sleep(1 * 1000000);
switch_core_set_variable("sound_prefix", "." SWITCH_PATH_SEPARATOR);
- } else {
- switch_core_init(SCF_MINIMAL, SWITCH_TRUE, &err);
+ return status;
}
+ return switch_core_init(SCF_MINIMAL, SWITCH_TRUE, &err);
}
/**
#define FST_CORE_BEGIN(confdir) \
FCT_BGN() \
{ \
- int fst_core = 2; \
+ int fst_core = 0; \
switch_time_t fst_time_start = 0; \
switch_timer_t fst_timer = { 0 }; \
switch_memory_pool_t *fst_pool = NULL; \
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
- fst_init_core_and_modload(confdir, NULL, 0); \
+ if (fst_init_core_and_modload(confdir, NULL, 0) == SWITCH_STATUS_SUCCESS) { \
+ fst_core = 2; \
+ } else { \
+ fprintf(stderr, "Failed to load FS core\n"); \
+ exit(1); \
+ } \
{
#define FST_MINCORE_BEGIN() \
FCT_BGN() \
{ \
- int fst_core = 1; \
+ int fst_core = 0; \
switch_time_t fst_time_start = 0; \
switch_timer_t fst_timer = { 0 }; \
switch_memory_pool_t *fst_pool = NULL; \
fst_getenv_default("FST_SUPPRESS_UNUSED_STATIC_WARNING", NULL, SWITCH_FALSE); \
- fst_init_core_and_modload(".", NULL, 1); /* minimal load */ \
+ if (fst_init_core_and_modload(".", NULL, 1) == SWITCH_STATUS_SUCCESS) { /* minimal load */ \
+ fst_core = 1; \
+ } else { \
+ fprintf(stderr, "Failed to load FS core\n"); \
+ exit(1); \
+ } \
{
#define FST_MINCORE_END FST_CORE_END
switch_channel_global_init(runtime.memory_pool);
if (switch_xml_init(runtime.memory_pool, err) != SWITCH_STATUS_SUCCESS) {
- apr_terminate();
- return SWITCH_STATUS_MEMERR;
+ /* allow missing configuration if MINIMAL */
+ if (!(flags & SCF_MINIMAL)) {
+ apr_terminate();
+ return SWITCH_STATUS_MEMERR;
+ }
}
if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {