mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix the empty config error
This commit is contained in:
parent
75bfe2af78
commit
0db2e6b8e9
3 changed files with 37 additions and 1 deletions
|
@ -1182,6 +1182,13 @@ int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer)
|
||||||
if ((ret = root->parse(buffer)) != ERROR_SUCCESS) {
|
if ((ret = root->parse(buffer)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check empty
|
||||||
|
if (root->directives.size() == 0) {
|
||||||
|
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||||
|
srs_error("conf is empty, ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// check root directives.
|
// check root directives.
|
||||||
for (int i = 0; i < (int)root->directives.size(); i++) {
|
for (int i = 0; i < (int)root->directives.size(); i++) {
|
||||||
|
@ -1200,7 +1207,7 @@ int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check rtmp port specified by directive listen.
|
// check rtmp port specified by directive listen.
|
||||||
if (_srs_config->get_listen().size() <= 0) {
|
if (get_listen().size() <= 0) {
|
||||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||||
srs_error("directive \"listen\" is empty, ret=%d", ret);
|
srs_error("directive \"listen\" is empty, ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -53,6 +53,20 @@ int MockSrsConfigBuffer::fullfill(const char* /*filename*/)
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MockSrsConfig::MockSrsConfig()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MockSrsConfig::~MockSrsConfig()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int MockSrsConfig::parse(string buf)
|
||||||
|
{
|
||||||
|
MockSrsConfigBuffer buffer(buf);
|
||||||
|
return parse_buffer(&buffer);
|
||||||
|
}
|
||||||
|
|
||||||
VOID TEST(ConfigTest, CheckMacros)
|
VOID TEST(ConfigTest, CheckMacros)
|
||||||
{
|
{
|
||||||
#ifndef SRS_CONSTS_LOCALHOST
|
#ifndef SRS_CONSTS_LOCALHOST
|
||||||
|
@ -777,3 +791,9 @@ VOID TEST(ConfigDirectiveTest, ParseLineNormal)
|
||||||
EXPECT_EQ(0, (int)dir2.directives.size());
|
EXPECT_EQ(0, (int)dir2.directives.size());
|
||||||
EXPECT_EQ(3, (int)dir2.conf_line);
|
EXPECT_EQ(3, (int)dir2.conf_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID TEST(ConfigMainTest, ParseEmpty)
|
||||||
|
{
|
||||||
|
MockSrsConfig conf;
|
||||||
|
EXPECT_TRUE(ERROR_SUCCESS != conf.parse(""));
|
||||||
|
}
|
||||||
|
|
|
@ -42,4 +42,13 @@ public:
|
||||||
virtual int fullfill(const char* filename);
|
virtual int fullfill(const char* filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MockSrsConfig : public SrsConfig
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MockSrsConfig();
|
||||||
|
virtual ~MockSrsConfig();
|
||||||
|
public:
|
||||||
|
virtual int parse(std::string buf);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue