mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix parse_file function did not handle err (#2928)
* Fix parse file function did not handle err * Fix parse_file function did not handle err * Fix error message * Updated error information
This commit is contained in:
parent
9385f2b80b
commit
8dc5853f8c
1 changed files with 16 additions and 12 deletions
|
@ -984,10 +984,10 @@ srs_error_t SrsConfDirective::parse_conf(SrsConfigBuffer* buffer, SrsDirectiveCo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == SrsDirectiveStateBlockEnd) {
|
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) {
|
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()) {
|
if (args.empty()) {
|
||||||
return srs_error_new(ERROR_SYSTEM_CONFIG_INVALID, "line %d: empty directive", conf_line);
|
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.
|
// Parse the matched config file.
|
||||||
err = parse_file(config_file.c_str());
|
err = parse_file(config_file.c_str());
|
||||||
|
|
||||||
if (test_conf) {
|
if (test_conf) {
|
||||||
// the parse_file never check the config,
|
// the parse_file never check the config,
|
||||||
// we check it when user requires check config file.
|
// 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 = srs_config_transform_vhost(root)) == srs_success) {
|
||||||
if (err == srs_success && (err = check_config()) == srs_success) {
|
if ((err = check_config()) == srs_success) {
|
||||||
srs_trace("config file is ok");
|
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);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error("invalid config, %s", srs_error_desc(err).c_str());
|
srs_trace("invalid config%s in %s", srs_error_summary(err).c_str(), config_file.c_str());
|
||||||
int ret = srs_error_code(err);
|
srs_trace("config file %s test is failed", config_file.c_str());
|
||||||
srs_freep(err);
|
exit(srs_error_code(err));
|
||||||
exit(ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (err != srs_success) {
|
||||||
|
return srs_error_wrap(err, "invalid config");
|
||||||
|
}
|
||||||
|
|
||||||
// transform config to compatible with previous style of config.
|
// transform config to compatible with previous style of config.
|
||||||
if ((err = srs_config_transform_vhost(root)) != srs_success) {
|
if ((err = srs_config_transform_vhost(root)) != srs_success) {
|
||||||
return srs_error_wrap(err, "transform");
|
return srs_error_wrap(err, "transform");
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// check log name and level
|
// check log name and level
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue