1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine config, allow parse multiple times.

This commit is contained in:
winlin 2019-04-08 08:31:58 +08:00
parent 6239dfa489
commit 74c1944e15
4 changed files with 17 additions and 2 deletions

3
trunk/.gitignore vendored
View file

@ -37,4 +37,5 @@ srs
*.dSYM/
*.gcov
*.ts
*.h264
*.264

Binary file not shown.

View file

@ -3960,6 +3960,11 @@ srs_error_t SrsConfig::parse_buffer(SrsConfigBuffer* buffer)
{
srs_error_t err = srs_success;
// We use a new root to parse buffer, to allow parse multiple times.
srs_freep(root);
root = new SrsConfDirective();
// Parse root tree from buffer.
if ((err = root->parse(buffer)) != srs_success) {
return srs_error_wrap(err, "root parse");
}

View file

@ -1804,3 +1804,12 @@ VOID TEST(ConfigMainTest, CheckConf_vhost_ingest_id)
EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"vhost v{ingest{} ingest{}}"));
}
VOID TEST(ConfigUnitTest, CheckDefaultValues)
{
MockSrsConfig conf;
if (true) {
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF));
EXPECT_EQ(30 * SRS_UTIME_SECONDS, conf.get_bw_check_interval_ms(""));
}
}