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
2015-08-31 12:06:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8a2709dd2c411266dd7a013da38e39bcd803b25e
8a2709dd
1 parent
a62c82bd
for #319, do not apply when config not changed.
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
78 行增加
和
13 行删除
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_http_api.cpp
trunk/src/app/srs_app_config.cpp
查看文件 @
8a2709d
...
...
@@ -67,9 +67,46 @@ using namespace _srs_internal;
// '\r'
#define SRS_CR (char)SRS_CONSTS_CR
// dumps the engine to amf0 object.
/**
* dumps the ingest/transcode-engine in @param dir to amf0 object @param engine.
* @param dir the transcode or ingest config directive.
* @param engine the amf0 object to dumps to.
*/
int
srs_config_dumps_engine
(
SrsConfDirective
*
dir
,
SrsAmf0Object
*
engine
);
/**
* whether the two vector actual equals, for instance,
* srs_vector_actual_equals([0, 1, 2], [0, 1, 2]) ==== true
* srs_vector_actual_equals([0, 1, 2], [2, 1, 0]) ==== true
* srs_vector_actual_equals([0, 1, 2], [0, 2, 1]) ==== true
* srs_vector_actual_equals([0, 1, 2], [0, 1, 2, 3]) ==== false
* srs_vector_actual_equals([1, 2, 3], [0, 1, 2]) ==== false
*/
template
<
typename
T
>
bool
srs_vector_actual_equals
(
const
vector
<
T
>&
a
,
const
vector
<
T
>&
b
)
{
// all elements of a in b.
for
(
int
i
=
0
;
i
<
(
int
)
a
.
size
();
i
++
)
{
const
T
&
e
=
a
.
at
(
i
);
if
(
::
find
(
b
.
begin
(),
b
.
end
(),
e
)
==
b
.
end
())
{
return
false
;
}
}
// all elements of b in a.
for
(
int
i
=
0
;
i
<
(
int
)
b
.
size
();
i
++
)
{
const
T
&
e
=
b
.
at
(
i
);
if
(
::
find
(
a
.
begin
(),
a
.
end
(),
e
)
==
a
.
end
())
{
return
false
;
}
}
return
true
;
}
/**
* whether the ch is common space.
*/
bool
is_common_space
(
char
ch
)
{
return
(
ch
==
' '
||
ch
==
'\t'
||
ch
==
SRS_CR
||
ch
==
SRS_LF
);
...
...
@@ -900,14 +937,9 @@ int SrsConfig::reload_conf(SrsConfig* conf)
// merge config: listen
if
(
!
srs_directive_equals
(
root
->
get
(
"listen"
),
old_root
->
get
(
"listen"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_listen
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload listen failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
ret
=
do_reload_listen
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
srs_trace
(
"reload listen success."
);
}
// merge config: pid
...
...
@@ -2175,13 +2207,34 @@ int SrsConfig::raw_to_json(SrsAmf0Object* obj)
return
ret
;
}
int
SrsConfig
::
raw_set_listen
(
const
vector
<
string
>&
eps
)
int
SrsConfig
::
raw_set_listen
(
const
vector
<
string
>&
eps
,
bool
&
applied
)
{
int
ret
=
ERROR_SUCCESS
;
applied
=
false
;
SrsConfDirective
*
listen
=
root
->
get
(
"listen"
);
// not changed, ignore.
if
(
srs_vector_actual_equals
(
listen
->
args
,
eps
))
{
return
ret
;
}
// changed, apply and reload.
listen
->
args
=
eps
;
if
((
ret
=
do_reload_listen
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
applied
=
true
;
return
ret
;
}
int
SrsConfig
::
do_reload_listen
()
{
int
ret
=
ERROR_SUCCESS
;
// force to reload the memory server.
vector
<
ISrsReloadHandler
*>::
iterator
it
;
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
8a2709d
...
...
@@ -331,8 +331,14 @@ public:
virtual
int
raw_to_json
(
SrsAmf0Object
*
obj
);
/**
* raw set the global listen.
* @param applied whether the config is applied.
*/
virtual
int
raw_set_listen
(
const
std
::
vector
<
std
::
string
>&
eps
);
virtual
int
raw_set_listen
(
const
std
::
vector
<
std
::
string
>&
eps
,
bool
&
applied
);
private
:
/**
* do reload listen, for reload from signal or raw api.
*/
virtual
int
do_reload_listen
();
public
:
/**
* get the config file path.
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
8a2709d
...
...
@@ -992,6 +992,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return
srs_api_response_code
(
w
,
r
,
ret
);
}
bool
applied
=
false
;
if
(
scope
==
"global.listen"
)
{
vector
<
string
>
eps
=
srs_string_split
(
value
,
","
);
...
...
@@ -1010,14 +1011,19 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return
srs_api_response_code
(
w
,
r
,
ret
);
}
if
((
ret
=
_srs_config
->
raw_set_listen
(
eps
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
_srs_config
->
raw_set_listen
(
eps
,
applied
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"raw api update global.listen=%s failed. ret=%d"
,
value
.
c_str
(),
ret
);
return
srs_api_response_code
(
w
,
r
,
ret
);
}
}
server
->
on_signal
(
SRS_SIGNAL_PERSISTENCE_CONFIG
);
srs_trace
(
"raw api update %s=%s ok."
,
scope
.
c_str
(),
value
.
c_str
());
// whether the config applied.
if
(
applied
)
{
server
->
on_signal
(
SRS_SIGNAL_PERSISTENCE_CONFIG
);
srs_trace
(
"raw api update %s=%s ok."
,
scope
.
c_str
(),
value
.
c_str
());
}
else
{
srs_warn
(
"raw api update not applied %s=%s."
,
scope
.
c_str
(),
value
.
c_str
());
}
return
srs_api_response
(
w
,
r
,
obj
->
to_json
());
}
...
...
请
注册
或
登录
后发表评论