diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index e782ceaa2..204ca2eee 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -984,10 +984,10 @@ srs_error_t SrsConfDirective::parse_conf(SrsConfigBuffer* buffer, SrsDirectiveCo } if (state == SrsDirectiveStateBlockEnd) { - return ctx == SrsDirectiveContextBlock ? srs_success : srs_error_wrap(err, "line %d: unexpected \"}\"", buffer->line); + return ctx == SrsDirectiveContextBlock ? srs_success : srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "line %d: unexpected \"}\"", buffer->line); } if (state == SrsDirectiveStateEOF) { - return ctx != SrsDirectiveContextBlock ? srs_success : srs_error_wrap(err, "line %d: unexpected end of file, expecting \"}\"", conf_line); + return ctx != SrsDirectiveContextBlock ? srs_success : srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "line %d: unexpected end of file, expecting \"}\"", conf_line); } if (args.empty()) { return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "line %d: empty directive", conf_line); @@ -2034,28 +2034,32 @@ srs_error_t SrsConfig::parse_options(int argc, char** argv) // Parse the matched config file. err = parse_file(config_file.c_str()); - + if (test_conf) { // the parse_file never check the config, // we check it when user requires check config file. if (err == srs_success && (err = srs_config_transform_vhost(root)) == srs_success) { - if (err == srs_success && (err = check_config()) == srs_success) { - srs_trace("config file is ok"); + if ((err = check_config()) == srs_success) { + srs_trace("the config file %s syntax is ok", config_file.c_str()); + srs_trace("config file %s test is successful", config_file.c_str()); exit(0); } } - - srs_error("invalid config, %s", srs_error_desc(err).c_str()); - int ret = srs_error_code(err); - srs_freep(err); - exit(ret); + + srs_trace("invalid config%s in %s", srs_error_summary(err).c_str(), config_file.c_str()); + srs_trace("config file %s test is failed", config_file.c_str()); + exit(srs_error_code(err)); } - + + if (err != srs_success) { + return srs_error_wrap(err, "invalid config"); + } + // transform config to compatible with previous style of config. if ((err = srs_config_transform_vhost(root)) != srs_success) { return srs_error_wrap(err, "transform"); } - + //////////////////////////////////////////////////////////////////////// // check log name and level ////////////////////////////////////////////////////////////////////////