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-03 14:11:21 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
65b2ed7ac552e5db080221fe32cb93803358bed2
65b2ed7a
1 parent
71f2726b
refine code, move the order of functions.
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
528 行增加
和
527 行删除
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_ingest.cpp
trunk/src/app/srs_app_config.cpp
查看文件 @
65b2ed7
...
...
@@ -535,271 +535,6 @@ int SrsConfig::reload()
return
reload_conf
(
&
conf
);
}
int
SrsConfig
::
reload_conf
(
SrsConfig
*
conf
)
{
int
ret
=
ERROR_SUCCESS
;
SrsConfDirective
*
old_root
=
root
;
SrsAutoFree
(
SrsConfDirective
,
old_root
);
root
=
conf
->
root
;
conf
->
root
=
NULL
;
// merge config.
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
// never support reload:
// daemon
//
// always support reload without additional code:
// chunk_size, ff_log_dir,
// bandcheck, http_hooks, heartbeat,
// token_traverse, debug_srs_upnode,
// security
// merge config: max_connections
if
(
!
srs_directive_equals
(
root
->
get
(
"max_connections"
),
old_root
->
get
(
"max_connections"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_max_conns
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload max_connections failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload max_connections success."
);
}
// 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
;
}
}
srs_trace
(
"reload listen success."
);
}
// merge config: pid
if
(
!
srs_directive_equals
(
root
->
get
(
"pid"
),
old_root
->
get
(
"pid"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_pid
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload pid failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload pid success."
);
}
// merge config: srs_log_tank
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_tank"
),
old_root
->
get
(
"srs_log_tank"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_tank
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_tank failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_tank success."
);
}
// merge config: srs_log_level
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_level"
),
old_root
->
get
(
"srs_log_level"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_level
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_level failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_level success."
);
}
// merge config: srs_log_file
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_file"
),
old_root
->
get
(
"srs_log_file"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_file
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_file failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_file success."
);
}
// merge config: pithy_print_ms
if
(
!
srs_directive_equals
(
root
->
get
(
"pithy_print_ms"
),
old_root
->
get
(
"pithy_print_ms"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_pithy_print
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes pithy_print_ms listen failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload pithy_print_ms success."
);
}
// merge config: http_api
if
((
ret
=
reload_http_api
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// merge config: http_stream
if
((
ret
=
reload_http_stream
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// TODO: FIXME: support reload stream_caster.
// merge config: vhost
if
((
ret
=
reload_vhost
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
int
SrsConfig
::
reload_http_api
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
// merge config.
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
// state graph
// old_http_api new_http_api
// DISABLED => ENABLED
// ENABLED => DISABLED
// ENABLED => ENABLED (modified)
SrsConfDirective
*
new_http_api
=
root
->
get
(
"http_api"
);
SrsConfDirective
*
old_http_api
=
old_root
->
get
(
"http_api"
);
// DISABLED => ENABLED
if
(
!
get_http_api_enabled
(
old_http_api
)
&&
get_http_api_enabled
(
new_http_api
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_api_enabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_api disabled=>enabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload disabled=>enabled http_api success."
);
return
ret
;
}
// ENABLED => DISABLED
if
(
get_http_api_enabled
(
old_http_api
)
&&
!
get_http_api_enabled
(
new_http_api
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_api_disabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_api enabled=>disabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled=>disabled http_api success."
);
return
ret
;
}
// ENABLED => ENABLED (modified)
if
(
get_http_api_enabled
(
old_http_api
)
&&
get_http_api_enabled
(
new_http_api
)
&&
!
srs_directive_equals
(
old_http_api
,
new_http_api
)
)
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_api_enabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_api enabled modified failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled modified http_api success."
);
return
ret
;
}
srs_trace
(
"reload http_api not changed success."
);
return
ret
;
}
int
SrsConfig
::
reload_http_stream
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
// merge config.
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
// state graph
// old_http_stream new_http_stream
// DISABLED => ENABLED
// ENABLED => DISABLED
// ENABLED => ENABLED (modified)
SrsConfDirective
*
new_http_stream
=
root
->
get
(
"http_stream"
);
// http_stream rename to http_server in SRS2.
if
(
!
new_http_stream
)
{
new_http_stream
=
root
->
get
(
"http_server"
);
}
SrsConfDirective
*
old_http_stream
=
old_root
->
get
(
"http_stream"
);
// http_stream rename to http_server in SRS2.
if
(
!
old_http_stream
)
{
old_http_stream
=
root
->
get
(
"http_server"
);
}
// DISABLED => ENABLED
if
(
!
get_http_stream_enabled
(
old_http_stream
)
&&
get_http_stream_enabled
(
new_http_stream
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_enabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream disabled=>enabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload disabled=>enabled http_stream success."
);
return
ret
;
}
// ENABLED => DISABLED
if
(
get_http_stream_enabled
(
old_http_stream
)
&&
!
get_http_stream_enabled
(
new_http_stream
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_disabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream enabled=>disabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled=>disabled http_stream success."
);
return
ret
;
}
// ENABLED => ENABLED (modified)
if
(
get_http_stream_enabled
(
old_http_stream
)
&&
get_http_stream_enabled
(
new_http_stream
)
&&
!
srs_directive_equals
(
old_http_stream
,
new_http_stream
)
)
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_updated
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream enabled modified failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled modified http_stream success."
);
return
ret
;
}
srs_trace
(
"reload http_stream not changed success."
);
return
ret
;
}
int
SrsConfig
::
reload_vhost
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -1067,20 +802,285 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
}
srs_trace
(
"vhost %s reload http_remux success."
,
vhost
.
c_str
());
}
// transcode, many per vhost.
if
((
ret
=
reload_transcode
(
new_vhost
,
old_vhost
))
!=
ERROR_SUCCESS
)
{
// transcode, many per vhost.
if
((
ret
=
reload_transcode
(
new_vhost
,
old_vhost
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// ingest, many per vhost.
if
((
ret
=
reload_ingest
(
new_vhost
,
old_vhost
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
continue
;
}
srs_trace
(
"ignore reload vhost, enabled old: %d, new: %d"
,
get_vhost_enabled
(
old_vhost
),
get_vhost_enabled
(
new_vhost
));
}
return
ret
;
}
int
SrsConfig
::
reload_conf
(
SrsConfig
*
conf
)
{
int
ret
=
ERROR_SUCCESS
;
SrsConfDirective
*
old_root
=
root
;
SrsAutoFree
(
SrsConfDirective
,
old_root
);
root
=
conf
->
root
;
conf
->
root
=
NULL
;
// merge config.
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
// never support reload:
// daemon
//
// always support reload without additional code:
// chunk_size, ff_log_dir,
// bandcheck, http_hooks, heartbeat,
// token_traverse, debug_srs_upnode,
// security
// merge config: max_connections
if
(
!
srs_directive_equals
(
root
->
get
(
"max_connections"
),
old_root
->
get
(
"max_connections"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_max_conns
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload max_connections failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload max_connections success."
);
}
// 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
;
}
}
srs_trace
(
"reload listen success."
);
}
// merge config: pid
if
(
!
srs_directive_equals
(
root
->
get
(
"pid"
),
old_root
->
get
(
"pid"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_pid
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload pid failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload pid success."
);
}
// merge config: srs_log_tank
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_tank"
),
old_root
->
get
(
"srs_log_tank"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_tank
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_tank failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_tank success."
);
}
// merge config: srs_log_level
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_level"
),
old_root
->
get
(
"srs_log_level"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_level
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_level failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_level success."
);
}
// merge config: srs_log_file
if
(
!
srs_directive_equals
(
root
->
get
(
"srs_log_file"
),
old_root
->
get
(
"srs_log_file"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_log_file
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes reload srs_log_file failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload srs_log_file success."
);
}
// merge config: pithy_print_ms
if
(
!
srs_directive_equals
(
root
->
get
(
"pithy_print_ms"
),
old_root
->
get
(
"pithy_print_ms"
)))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_pithy_print
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes pithy_print_ms listen failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload pithy_print_ms success."
);
}
// merge config: http_api
if
((
ret
=
reload_http_api
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// merge config: http_stream
if
((
ret
=
reload_http_stream
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// TODO: FIXME: support reload stream_caster.
// merge config: vhost
if
((
ret
=
reload_vhost
(
old_root
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
ret
;
}
int
SrsConfig
::
reload_http_api
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
// merge config.
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
// state graph
// old_http_api new_http_api
// DISABLED => ENABLED
// ENABLED => DISABLED
// ENABLED => ENABLED (modified)
SrsConfDirective
*
new_http_api
=
root
->
get
(
"http_api"
);
SrsConfDirective
*
old_http_api
=
old_root
->
get
(
"http_api"
);
// DISABLED => ENABLED
if
(
!
get_http_api_enabled
(
old_http_api
)
&&
get_http_api_enabled
(
new_http_api
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_api_enabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_api disabled=>enabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload disabled=>enabled http_api success."
);
return
ret
;
}
// ENABLED => DISABLED
if
(
get_http_api_enabled
(
old_http_api
)
&&
!
get_http_api_enabled
(
new_http_api
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_api_disabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_api enabled=>disabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled=>disabled http_api success."
);
return
ret
;
}
// ENABLED => ENABLED (modified)
if
(
get_http_api_enabled
(
old_http_api
)
&&
get_http_api_enabled
(
new_http_api
)
&&
!
srs_directive_equals
(
old_http_api
,
new_http_api
)
)
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_api_enabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_api enabled modified failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload enabled modified http_api success."
);
return
ret
;
}
srs_trace
(
"reload http_api not changed success."
);
return
ret
;
}
int
SrsConfig
::
reload_http_stream
(
SrsConfDirective
*
old_root
)
{
int
ret
=
ERROR_SUCCESS
;
// merge config.
std
::
vector
<
ISrsReloadHandler
*>::
iterator
it
;
// state graph
// old_http_stream new_http_stream
// DISABLED => ENABLED
// ENABLED => DISABLED
// ENABLED => ENABLED (modified)
SrsConfDirective
*
new_http_stream
=
root
->
get
(
"http_stream"
);
// http_stream rename to http_server in SRS2.
if
(
!
new_http_stream
)
{
new_http_stream
=
root
->
get
(
"http_server"
);
}
SrsConfDirective
*
old_http_stream
=
old_root
->
get
(
"http_stream"
);
// http_stream rename to http_server in SRS2.
if
(
!
old_http_stream
)
{
old_http_stream
=
root
->
get
(
"http_server"
);
}
// DISABLED => ENABLED
if
(
!
get_http_stream_enabled
(
old_http_stream
)
&&
get_http_stream_enabled
(
new_http_stream
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_enabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream disabled=>enabled failed. ret=%d"
,
ret
);
return
ret
;
}
}
srs_trace
(
"reload disabled=>enabled http_stream success."
);
return
ret
;
}
// ENABLED => DISABLED
if
(
get_http_stream_enabled
(
old_http_stream
)
&&
!
get_http_stream_enabled
(
new_http_stream
))
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_disabled
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream enabled=>disabled failed. ret=%d"
,
ret
);
return
ret
;
}
// ingest, many per vhost.
if
((
ret
=
reload_ingest
(
new_vhost
,
old_vhost
))
!=
ERROR_SUCCESS
)
{
}
srs_trace
(
"reload enabled=>disabled http_stream success."
);
return
ret
;
}
// ENABLED => ENABLED (modified)
if
(
get_http_stream_enabled
(
old_http_stream
)
&&
get_http_stream_enabled
(
new_http_stream
)
&&
!
srs_directive_equals
(
old_http_stream
,
new_http_stream
)
)
{
for
(
it
=
subscribes
.
begin
();
it
!=
subscribes
.
end
();
++
it
)
{
ISrsReloadHandler
*
subscribe
=
*
it
;
if
((
ret
=
subscribe
->
on_reload_http_stream_updated
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"notify subscribes http_stream enabled modified failed. ret=%d"
,
ret
);
return
ret
;
}
continue
;
}
srs_trace
(
"ignore reload vhost, enabled old: %d, new: %d"
,
get_vhost_enabled
(
old_vhost
),
get_vhost_enabled
(
new_vhost
));
srs_trace
(
"reload enabled modified http_stream success."
);
return
ret
;
}
srs_trace
(
"reload http_stream not changed success."
);
return
ret
;
}
...
...
@@ -1481,9 +1481,6 @@ int SrsConfig::check_config()
int
ret
=
ERROR_SUCCESS
;
srs_trace
(
"srs checking config..."
);
vector
<
SrsConfDirective
*>
vhosts
=
get_vhosts
();
vector
<
SrsConfDirective
*>
stream_casters
=
get_stream_casters
();
////////////////////////////////////////////////////////////////////////
// check empty
...
...
@@ -1493,71 +1490,235 @@ int SrsConfig::check_config()
srs_error
(
"conf is empty, ret=%d"
,
ret
);
return
ret
;
}
////////////////////////////////////////////////////////////////////////
// check root directives.
////////////////////////////////////////////////////////////////////////
for
(
int
i
=
0
;
i
<
(
int
)
root
->
directives
.
size
();
i
++
)
{
SrsConfDirective
*
conf
=
root
->
at
(
i
);
std
::
string
n
=
conf
->
name
;
if
(
n
!=
"listen"
&&
n
!=
"pid"
&&
n
!=
"chunk_size"
&&
n
!=
"ff_log_dir"
&&
n
!=
"srs_log_tank"
&&
n
!=
"srs_log_level"
&&
n
!=
"srs_log_file"
&&
n
!=
"max_connections"
&&
n
!=
"daemon"
&&
n
!=
"heartbeat"
&&
n
!=
"http_api"
&&
n
!=
"stats"
&&
n
!=
"vhost"
&&
n
!=
"pithy_print_ms"
&&
n
!=
"http_stream"
&&
n
!=
"http_server"
&&
n
!=
"stream_caster"
&&
n
!=
"utc_time"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_http_api
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"listen"
&&
n
!=
"crossdomain"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported http_api directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_http_stream
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"listen"
&&
n
!=
"dir"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported http_stream directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_heartbeart
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"interval"
&&
n
!=
"url"
&&
n
!=
"device_id"
&&
n
!=
"summaries"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported heartbeat directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_stats
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"network"
&&
n
!=
"disk"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported stats directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
}
////////////////////////////////////////////////////////////////////////
// check listen for rtmp.
////////////////////////////////////////////////////////////////////////
if
(
true
)
{
vector
<
string
>
listens
=
get_listens
();
if
(
listens
.
size
()
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive
\"
listen
\"
is empty, ret=%d"
,
ret
);
return
ret
;
}
for
(
int
i
=
0
;
i
<
(
int
)
listens
.
size
();
i
++
)
{
string
port
=
listens
[
i
];
if
(
port
.
empty
()
||
::
atoi
(
port
.
c_str
())
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive listen invalid, port=%s, ret=%d"
,
port
.
c_str
(),
ret
);
return
ret
;
}
}
}
////////////////////////////////////////////////////////////////////////
// check max connections
////////////////////////////////////////////////////////////////////////
if
(
get_max_connections
()
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive max_connections invalid, max_connections=%d, ret=%d"
,
get_max_connections
(),
ret
);
return
ret
;
}
// check max connections of system limits
if
(
true
)
{
int
nb_consumed_fds
=
(
int
)
get_listens
().
size
();
if
(
!
get_http_api_listen
().
empty
())
{
nb_consumed_fds
++
;
}
if
(
!
get_http_stream_listen
().
empty
())
{
nb_consumed_fds
++
;
}
if
(
get_log_tank_file
())
{
nb_consumed_fds
++
;
}
// 0, 1, 2 for stdin, stdout and stderr.
nb_consumed_fds
+=
3
;
int
nb_connections
=
get_max_connections
();
int
nb_total
=
nb_connections
+
nb_consumed_fds
;
int
max_open_files
=
(
int
)
sysconf
(
_SC_OPEN_MAX
);
int
nb_canbe
=
max_open_files
-
nb_consumed_fds
-
1
;
// for each play connections, we open a pipe(2fds) to convert SrsConsumver to io,
// refine performance, @see: https://github.com/simple-rtmp-server/srs/issues/194
if
(
nb_total
>=
max_open_files
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"invalid max_connections=%d, required=%d, system limit to %d, "
"total=%d(max_connections=%d, nb_consumed_fds=%d), ret=%d. "
"you can change max_connections from %d to %d, or "
"you can login as root and set the limit: ulimit -HSn %d"
,
nb_connections
,
nb_total
+
1
,
max_open_files
,
nb_total
,
nb_connections
,
nb_consumed_fds
,
ret
,
nb_connections
,
nb_canbe
,
nb_total
+
1
);
return
ret
;
}
}
////////////////////////////////////////////////////////////////////////
// check heartbeat
////////////////////////////////////////////////////////////////////////
if
(
get_heartbeat_interval
()
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive heartbeat interval invalid, interval=%"
PRId64
", ret=%d"
,
get_heartbeat_interval
(),
ret
);
return
ret
;
}
////////////////////////////////////////////////////////////////////////
// check stats
////////////////////////////////////////////////////////////////////////
if
(
get_stats_network
()
<
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive stats network invalid, network=%d, ret=%d"
,
get_stats_network
(),
ret
);
return
ret
;
}
if
(
true
)
{
vector
<
std
::
string
>
ips
=
srs_get_local_ipv4_ips
();
int
index
=
get_stats_network
();
if
(
index
>=
(
int
)
ips
.
size
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"stats network invalid, total local ip count=%d, index=%d, ret=%d"
,
(
int
)
ips
.
size
(),
index
,
ret
);
return
ret
;
}
srs_warn
(
"stats network use index=%d, ip=%s"
,
index
,
ips
.
at
(
index
).
c_str
());
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_stats_disk_device
();
if
(
conf
==
NULL
||
(
int
)
conf
->
args
.
size
()
<=
0
)
{
srs_warn
(
"stats disk not configed, disk iops disabled."
);
}
else
{
string
disks
;
for
(
int
i
=
0
;
i
<
(
int
)
conf
->
args
.
size
();
i
++
)
{
disks
+=
conf
->
args
.
at
(
i
);
disks
+=
" "
;
}
srs_warn
(
"stats disk list: %s"
,
disks
.
c_str
());
}
}
////////////////////////////////////////////////////////////////////////
// check http api
////////////////////////////////////////////////////////////////////////
if
(
get_http_api_listen
().
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive http_api listen invalid, listen=%s, ret=%d"
,
get_http_api_listen
().
c_str
(),
ret
);
return
ret
;
}
////////////////////////////////////////////////////////////////////////
// check http stream
////////////////////////////////////////////////////////////////////////
if
(
get_http_stream_listen
().
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive http_stream listen invalid, listen=%s, ret=%d"
,
get_http_stream_listen
().
c_str
(),
ret
);
return
ret
;
}
////////////////////////////////////////////////////////////////////////
// check
root directives.
// check
log name and level
////////////////////////////////////////////////////////////////////////
for
(
int
i
=
0
;
i
<
(
int
)
root
->
directives
.
size
();
i
++
)
{
SrsConfDirective
*
conf
=
root
->
at
(
i
);
std
::
string
n
=
conf
->
name
;
if
(
n
!=
"listen"
&&
n
!=
"pid"
&&
n
!=
"chunk_size"
&&
n
!=
"ff_log_dir"
&&
n
!=
"srs_log_tank"
&&
n
!=
"srs_log_level"
&&
n
!=
"srs_log_file"
&&
n
!=
"max_connections"
&&
n
!=
"daemon"
&&
n
!=
"heartbeat"
&&
n
!=
"http_api"
&&
n
!=
"stats"
&&
n
!=
"vhost"
&&
n
!=
"pithy_print_ms"
&&
n
!=
"http_stream"
&&
n
!=
"http_server"
&&
n
!=
"stream_caster"
&&
n
!=
"utc_time"
)
{
if
(
true
)
{
std
::
string
log_filename
=
this
->
get_log_file
();
if
(
get_log_tank_file
()
&&
log_filename
.
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"
unsupported directive %s, ret=%d"
,
n
.
c_str
()
,
ret
);
srs_error
(
"
must specifies the file to write log to. ret=%d"
,
ret
);
return
ret
;
}
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_http_api
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"listen"
&&
n
!=
"crossdomain"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported http_api directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_http_stream
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"listen"
&&
n
!=
"dir"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported http_stream directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
if
(
get_log_tank_file
())
{
srs_trace
(
"write log to file %s"
,
log_filename
.
c_str
());
srs_trace
(
"you can: tailf %s"
,
log_filename
.
c_str
());
srs_trace
(
"@see: %s"
,
SRS_WIKI_URL_LOG
);
}
else
{
srs_trace
(
"write log to console"
);
}
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_heartbeart
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"interval"
&&
n
!=
"url"
&&
n
!=
"device_id"
&&
n
!=
"summaries"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported heartbeat directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
////////////////////////////////////////////////////////////////////////
// check features
////////////////////////////////////////////////////////////////////////
#ifndef SRS_AUTO_HTTP_SERVER
if
(
get_http_stream_enabled
())
{
srs_warn
(
"http_stream is disabled by configure"
);
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_stats
();
for
(
int
i
=
0
;
conf
&&
i
<
(
int
)
conf
->
directives
.
size
();
i
++
)
{
string
n
=
conf
->
at
(
i
)
->
name
;
if
(
n
!=
"network"
&&
n
!=
"disk"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported stats directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
#endif
#ifndef SRS_AUTO_HTTP_API
if
(
get_http_api_enabled
())
{
srs_warn
(
"http_api is disabled by configure"
);
}
#endif
vector
<
SrsConfDirective
*>
stream_casters
=
get_stream_casters
();
for
(
int
n
=
0
;
n
<
(
int
)
stream_casters
.
size
();
n
++
)
{
SrsConfDirective
*
stream_caster
=
stream_casters
[
n
];
for
(
int
i
=
0
;
stream_caster
&&
i
<
(
int
)
stream_caster
->
directives
.
size
();
i
++
)
{
...
...
@@ -1565,13 +1726,16 @@ int SrsConfig::check_config()
string
n
=
conf
->
name
;
if
(
n
!=
"enabled"
&&
n
!=
"caster"
&&
n
!=
"output"
&&
n
!=
"listen"
&&
n
!=
"rtp_port_min"
&&
n
!=
"rtp_port_max"
)
{
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported stream_caster directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
return
ret
;
}
}
}
vector
<
SrsConfDirective
*>
vhosts
;
get_vhosts
(
vhosts
);
for
(
int
n
=
0
;
n
<
(
int
)
vhosts
.
size
();
n
++
)
{
SrsConfDirective
*
vhost
=
vhosts
[
n
];
for
(
int
i
=
0
;
vhost
&&
i
<
(
int
)
vhost
->
directives
.
size
();
i
++
)
{
...
...
@@ -1601,7 +1765,7 @@ int SrsConfig::check_config()
string
m
=
conf
->
at
(
j
)
->
name
.
c_str
();
if
(
m
!=
"enabled"
&&
m
!=
"dvr_path"
&&
m
!=
"dvr_plan"
&&
m
!=
"dvr_duration"
&&
m
!=
"dvr_wait_keyframe"
&&
m
!=
"time_jitter"
)
{
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost dvr directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -1611,7 +1775,7 @@ int SrsConfig::check_config()
for
(
int
j
=
0
;
j
<
(
int
)
conf
->
directives
.
size
();
j
++
)
{
string
m
=
conf
->
at
(
j
)
->
name
.
c_str
();
if
(
m
!=
"enabled"
&&
m
!=
"latency"
)
{
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost mr directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -1622,7 +1786,7 @@ int SrsConfig::check_config()
string
m
=
conf
->
at
(
j
)
->
name
.
c_str
();
if
(
m
!=
"enabled"
&&
m
!=
"input"
&&
m
!=
"ffmpeg"
&&
m
!=
"engine"
)
{
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost ingest directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -1653,7 +1817,7 @@ int SrsConfig::check_config()
&&
m
!=
"hls_storage"
&&
m
!=
"hls_mount"
&&
m
!=
"hls_td_ratio"
&&
m
!=
"hls_aof_ratio"
&&
m
!=
"hls_acodec"
&&
m
!=
"hls_vcodec"
&&
m
!=
"hls_m3u8_file"
&&
m
!=
"hls_ts_file"
&&
m
!=
"hls_ts_floor"
&&
m
!=
"hls_cleanup"
&&
m
!=
"hls_nb_notify"
&&
m
!=
"hls_wait_keyframe"
&&
m
!=
"hls_dispose"
)
{
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost hls directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -1665,7 +1829,7 @@ int SrsConfig::check_config()
if
(
m
!=
"enabled"
&&
m
!=
"on_connect"
&&
m
!=
"on_close"
&&
m
!=
"on_publish"
&&
m
!=
"on_unpublish"
&&
m
!=
"on_play"
&&
m
!=
"on_stop"
&&
m
!=
"on_dvr"
&&
m
!=
"on_hls"
&&
m
!=
"on_hls_notify"
)
{
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost http_hooks directive %s, ret=%d"
,
m
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -1709,7 +1873,7 @@ int SrsConfig::check_config()
&&
e
!=
"acodec"
&&
e
!=
"abitrate"
&&
e
!=
"asample_rate"
&&
e
!=
"achannels"
&&
e
!=
"aparams"
&&
e
!=
"output"
&&
e
!=
"iformat"
&&
e
!=
"oformat"
)
{
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported vhost transcode engine directive %s, ret=%d"
,
e
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -1733,19 +1897,19 @@ int SrsConfig::check_config()
for
(
int
i
=
0
;
i
<
(
int
)
vhosts
.
size
();
i
++
)
{
SrsConfDirective
*
vhost
=
vhosts
[
i
];
std
::
vector
<
std
::
string
>
ids
;
for
(
int
j
=
0
;
j
<
(
int
)
vhost
->
directives
.
size
();
j
++
)
{
SrsConfDirective
*
conf
=
vhost
->
at
(
j
);
if
(
conf
->
name
!=
"ingest"
)
{
continue
;
}
std
::
string
id
=
conf
->
arg0
();
for
(
int
k
=
0
;
k
<
(
int
)
ids
.
size
();
k
++
)
{
if
(
id
==
ids
.
at
(
k
))
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive
\"
ingest
\"
id duplicated, vhost=%s, id=%s, ret=%d"
,
vhost
->
name
.
c_str
(),
id
.
c_str
(),
ret
);
srs_error
(
"directive
\"
ingest
\"
id duplicated, vhost=%s, id=%s, ret=%d"
,
vhost
->
name
.
c_str
(),
id
.
c_str
(),
ret
);
return
ret
;
}
}
...
...
@@ -1754,135 +1918,6 @@ int SrsConfig::check_config()
}
////////////////////////////////////////////////////////////////////////
// check listen for rtmp.
////////////////////////////////////////////////////////////////////////
if
(
true
)
{
vector
<
string
>
listens
=
get_listens
();
if
(
listens
.
size
()
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive
\"
listen
\"
is empty, ret=%d"
,
ret
);
return
ret
;
}
for
(
int
i
=
0
;
i
<
(
int
)
listens
.
size
();
i
++
)
{
string
port
=
listens
[
i
];
if
(
port
.
empty
()
||
::
atoi
(
port
.
c_str
())
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive listen invalid, port=%s, ret=%d"
,
port
.
c_str
(),
ret
);
return
ret
;
}
}
}
////////////////////////////////////////////////////////////////////////
// check max connections
////////////////////////////////////////////////////////////////////////
if
(
get_max_connections
()
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive max_connections invalid, max_connections=%d, ret=%d"
,
get_max_connections
(),
ret
);
return
ret
;
}
// check max connections of system limits
if
(
true
)
{
int
nb_consumed_fds
=
(
int
)
get_listens
().
size
();
if
(
!
get_http_api_listen
().
empty
())
{
nb_consumed_fds
++
;
}
if
(
!
get_http_stream_listen
().
empty
())
{
nb_consumed_fds
++
;
}
if
(
get_log_tank_file
())
{
nb_consumed_fds
++
;
}
// 0, 1, 2 for stdin, stdout and stderr.
nb_consumed_fds
+=
3
;
int
nb_connections
=
get_max_connections
();
int
nb_total
=
nb_connections
+
nb_consumed_fds
;
int
max_open_files
=
(
int
)
sysconf
(
_SC_OPEN_MAX
);
int
nb_canbe
=
max_open_files
-
nb_consumed_fds
-
1
;
// for each play connections, we open a pipe(2fds) to convert SrsConsumver to io,
// refine performance, @see: https://github.com/simple-rtmp-server/srs/issues/194
if
(
nb_total
>=
max_open_files
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"invalid max_connections=%d, required=%d, system limit to %d, "
"total=%d(max_connections=%d, nb_consumed_fds=%d), ret=%d. "
"you can change max_connections from %d to %d, or "
"you can login as root and set the limit: ulimit -HSn %d"
,
nb_connections
,
nb_total
+
1
,
max_open_files
,
nb_total
,
nb_connections
,
nb_consumed_fds
,
ret
,
nb_connections
,
nb_canbe
,
nb_total
+
1
);
return
ret
;
}
}
////////////////////////////////////////////////////////////////////////
// check heartbeat
////////////////////////////////////////////////////////////////////////
if
(
get_heartbeat_interval
()
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive heartbeat interval invalid, interval=%"
PRId64
", ret=%d"
,
get_heartbeat_interval
(),
ret
);
return
ret
;
}
////////////////////////////////////////////////////////////////////////
// check stats
////////////////////////////////////////////////////////////////////////
if
(
get_stats_network
()
<
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive stats network invalid, network=%d, ret=%d"
,
get_stats_network
(),
ret
);
return
ret
;
}
if
(
true
)
{
vector
<
std
::
string
>
ips
=
srs_get_local_ipv4_ips
();
int
index
=
get_stats_network
();
if
(
index
>=
(
int
)
ips
.
size
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"stats network invalid, total local ip count=%d, index=%d, ret=%d"
,
(
int
)
ips
.
size
(),
index
,
ret
);
return
ret
;
}
srs_warn
(
"stats network use index=%d, ip=%s"
,
index
,
ips
.
at
(
index
).
c_str
());
}
if
(
true
)
{
SrsConfDirective
*
conf
=
get_stats_disk_device
();
if
(
conf
==
NULL
||
(
int
)
conf
->
args
.
size
()
<=
0
)
{
srs_warn
(
"stats disk not configed, disk iops disabled."
);
}
else
{
string
disks
;
for
(
int
i
=
0
;
i
<
(
int
)
conf
->
args
.
size
();
i
++
)
{
disks
+=
conf
->
args
.
at
(
i
);
disks
+=
" "
;
}
srs_warn
(
"stats disk list: %s"
,
disks
.
c_str
());
}
}
////////////////////////////////////////////////////////////////////////
// check http api
////////////////////////////////////////////////////////////////////////
if
(
get_http_api_listen
().
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive http_api listen invalid, listen=%s, ret=%d"
,
get_http_api_listen
().
c_str
(),
ret
);
return
ret
;
}
////////////////////////////////////////////////////////////////////////
// check http stream
////////////////////////////////////////////////////////////////////////
if
(
get_http_stream_listen
().
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"directive http_stream listen invalid, listen=%s, ret=%d"
,
get_http_stream_listen
().
c_str
(),
ret
);
return
ret
;
}
////////////////////////////////////////////////////////////////////////
// check chunk size
////////////////////////////////////////////////////////////////////////
if
(
get_global_chunk_size
()
<
SRS_CONSTS_RTMP_MIN_CHUNK_SIZE
...
...
@@ -1906,39 +1941,6 @@ int SrsConfig::check_config()
return
ret
;
}
}
////////////////////////////////////////////////////////////////////////
// check log name and level
////////////////////////////////////////////////////////////////////////
if
(
true
)
{
std
::
string
log_filename
=
this
->
get_log_file
();
if
(
get_log_tank_file
()
&&
log_filename
.
empty
())
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"must specifies the file to write log to. ret=%d"
,
ret
);
return
ret
;
}
if
(
get_log_tank_file
())
{
srs_trace
(
"write log to file %s"
,
log_filename
.
c_str
());
srs_trace
(
"you can: tailf %s"
,
log_filename
.
c_str
());
srs_trace
(
"@see: %s"
,
SRS_WIKI_URL_LOG
);
}
else
{
srs_trace
(
"write log to console"
);
}
}
////////////////////////////////////////////////////////////////////////
// check features
////////////////////////////////////////////////////////////////////////
#ifndef SRS_AUTO_HTTP_SERVER
if
(
get_http_stream_enabled
())
{
srs_warn
(
"http_stream is disabled by configure"
);
}
#endif
#ifndef SRS_AUTO_HTTP_API
if
(
get_http_api_enabled
())
{
srs_warn
(
"http_api is disabled by configure"
);
}
#endif
for
(
int
i
=
0
;
i
<
(
int
)
vhosts
.
size
();
i
++
)
{
SrsConfDirective
*
vhost
=
vhosts
[
i
];
srs_assert
(
vhost
!=
NULL
);
...
...
@@ -2207,23 +2209,19 @@ SrsConfDirective* SrsConfig::get_vhost(string vhost)
return
NULL
;
}
v
ector
<
SrsConfDirective
*>
SrsConfig
::
get_vhosts
(
)
v
oid
SrsConfig
::
get_vhosts
(
vector
<
SrsConfDirective
*>&
vhosts
)
{
srs_assert
(
root
);
std
::
vector
<
SrsConfDirective
*>
vhosts
;
for
(
int
i
=
0
;
i
<
(
int
)
root
->
directives
.
size
();
i
++
)
{
SrsConfDirective
*
conf
=
root
->
at
(
i
);
if
(
!
conf
->
is_vhost
())
{
continue
;
}
vhosts
.
push_back
(
conf
);
}
return
vhosts
;
}
bool
SrsConfig
::
get_vhost_enabled
(
string
vhost
)
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
65b2ed7
...
...
@@ -253,6 +253,11 @@ public:
* @remark, user can test the config before reload it.
*/
virtual
int
reload
();
private
:
/**
* reload the vhost section of config.
*/
virtual
int
reload_vhost
(
SrsConfDirective
*
old_root
);
protected
:
/**
* reload from the config.
...
...
@@ -269,10 +274,6 @@ private:
*/
virtual
int
reload_http_stream
(
SrsConfDirective
*
old_root
);
/**
* reload the vhost section of config.
*/
virtual
int
reload_vhost
(
SrsConfDirective
*
old_root
);
/**
* reload the transcode section of vhost of config.
*/
virtual
int
reload_transcode
(
SrsConfDirective
*
new_vhost
,
SrsConfDirective
*
old_vhost
);
...
...
@@ -413,7 +414,7 @@ public:
/**
* get all vhosts in config file.
*/
virtual
std
::
vector
<
SrsConfDirective
*>
get_vhosts
(
);
virtual
void
get_vhosts
(
std
::
vector
<
SrsConfDirective
*>&
vhosts
);
/**
* whether vhost is enabled
* @param vhost, the vhost name.
...
...
trunk/src/app/srs_app_http_api.cpp
查看文件 @
65b2ed7
...
...
@@ -543,20 +543,21 @@ int SrsHttpApi::do_cycle()
// always free it in this scope.
SrsAutoFree
(
ISrsHttpMessage
,
req
);
// TODO: FIXME: use the post body.
std
::
string
res
;
// get response body.
if
((
ret
=
req
->
body_read_all
(
res
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// ok, handle http request.
SrsHttpResponseWriter
writer
(
&
skt
);
if
((
ret
=
process_request
(
&
writer
,
req
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// read all rest bytes in request body.
char
buf
[
SRS_HTTP_READ_CACHE_BYTES
];
ISrsHttpResponseReader
*
br
=
req
->
body_reader
();
while
(
!
br
->
eof
())
{
if
((
ret
=
br
->
read
(
buf
,
SRS_HTTP_READ_CACHE_BYTES
,
NULL
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
}
// donot keep alive, disconnect it.
// @see https://github.com/simple-rtmp-server/srs/issues/399
if
(
!
req
->
is_keep_alive
())
{
...
...
trunk/src/app/srs_app_ingest.cpp
查看文件 @
65b2ed7
...
...
@@ -293,7 +293,8 @@ int SrsIngester::parse()
int
ret
=
ERROR_SUCCESS
;
// parse ingesters
std
::
vector
<
SrsConfDirective
*>
vhosts
=
_srs_config
->
get_vhosts
();
std
::
vector
<
SrsConfDirective
*>
vhosts
;
_srs_config
->
get_vhosts
(
vhosts
);
for
(
int
i
=
0
;
i
<
(
int
)
vhosts
.
size
();
i
++
)
{
SrsConfDirective
*
vhost
=
vhosts
[
i
];
...
...
请
注册
或
登录
后发表评论