Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-07-20 17:08:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0db2e6b8e9291ca01cc4435ec1181698e96a23ef
0db2e6b8
1 parent
75bfe2af
fix the empty config error
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
37 行增加
和
1 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/utest/srs_utest_config.cpp
trunk/src/utest/srs_utest_config.hpp
trunk/src/app/srs_app_config.cpp
查看文件 @
0db2e6b
...
...
@@ -1182,6 +1182,13 @@ int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer)
if
((
ret
=
root
->
parse
(
buffer
))
!=
ERROR_SUCCESS
)
{
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.
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.
if
(
_srs_config
->
get_listen
().
size
()
<=
0
)
{
if
(
get_listen
().
size
()
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive
\"
listen
\"
is empty, ret=%d"
,
ret
);
return
ret
;
...
...
trunk/src/utest/srs_utest_config.cpp
查看文件 @
0db2e6b
...
...
@@ -53,6 +53,20 @@ int MockSrsConfigBuffer::fullfill(const char* /*filename*/)
return
ERROR_SUCCESS
;
}
MockSrsConfig
::
MockSrsConfig
()
{
}
MockSrsConfig
::~
MockSrsConfig
()
{
}
int
MockSrsConfig
::
parse
(
string
buf
)
{
MockSrsConfigBuffer
buffer
(
buf
);
return
parse_buffer
(
&
buffer
);
}
VOID
TEST
(
ConfigTest
,
CheckMacros
)
{
#ifndef SRS_CONSTS_LOCALHOST
...
...
@@ -777,3 +791,9 @@ VOID TEST(ConfigDirectiveTest, ParseLineNormal)
EXPECT_EQ
(
0
,
(
int
)
dir2
.
directives
.
size
());
EXPECT_EQ
(
3
,
(
int
)
dir2
.
conf_line
);
}
VOID
TEST
(
ConfigMainTest
,
ParseEmpty
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
""
));
}
...
...
trunk/src/utest/srs_utest_config.hpp
查看文件 @
0db2e6b
...
...
@@ -42,4 +42,13 @@ public:
virtual
int
fullfill
(
const
char
*
filename
);
};
class
MockSrsConfig
:
public
SrsConfig
{
public
:
MockSrsConfig
();
virtual
~
MockSrsConfig
();
public
:
virtual
int
parse
(
std
::
string
buf
);
};
#endif
...
...
请
注册
或
登录
后发表评论