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
2016-12-08 17:35:33 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dd1c769f65433d0436c8713634eded01be0bd406
dd1c769f
1 parent
83c251fc
refine main
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
112 行增加
和
111 行删除
trunk/src/core/srs_core.hpp
trunk/src/main/srs_main_server.cpp
trunk/src/core/srs_core.hpp
查看文件 @
dd1c769
...
...
@@ -59,7 +59,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define RTMP_SIG_SRS_SERVER RTMP_SIG_SRS_KEY"/"RTMP_SIG_SRS_VERSION"("RTMP_SIG_SRS_CODE")"
// stable major version
#define VERSION_STABLE
1
#define VERSION_STABLE
2
#define VERSION_STABLE_BRANCH SRS_XSTR(VERSION_STABLE)".0release"
// internal macros, covert macro values to str,
...
...
trunk/src/main/srs_main_server.cpp
查看文件 @
dd1c769
...
...
@@ -51,6 +51,7 @@ using namespace std;
// pre-declare
int
run
(
SrsServer
*
svr
);
int
run_master
(
SrsServer
*
svr
);
void
show_macro_features
();
// @global log and context.
ISrsLog
*
_srs_log
=
new
SrsFastLog
();
...
...
@@ -62,8 +63,113 @@ SrsConfig* _srs_config = new SrsConfig();
extern
const
char
*
_srs_version
;
/**
*
show the features by macro, the actual macro values
.
*
main entrance
.
*/
int
main
(
int
argc
,
char
**
argv
)
{
int
ret
=
ERROR_SUCCESS
;
// TODO: support both little and big endian.
srs_assert
(
srs_is_little_endian
());
// for gperf gmp or gcp,
// should never enable it when not enabled for performance issue.
#ifdef SRS_AUTO_GPERF_MP
HeapProfilerStart
(
"gperf.srs.gmp"
);
#endif
#ifdef SRS_AUTO_GPERF_CP
ProfilerStart
(
"gperf.srs.gcp"
);
#endif
// directly compile error when these two macro defines.
#if defined(SRS_AUTO_GPERF_MC) && defined(SRS_AUTO_GPERF_MP)
#error ("option --with-gmc confict with --with-gmp, "
"@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html
\n
"
"Note that since the heap-checker uses the heap-profiling framework internally, "
"it is not possible to run both the heap-checker and heap profiler at the same time"
);
#endif
// never use gmp to check memory leak.
#ifdef SRS_AUTO_GPERF_MP
#warning "gmp is not used for memory leak, please use gmc instead."
#endif
// never use srs log(srs_trace, srs_error, etc) before config parse the option,
// which will load the log config and apply it.
if
((
ret
=
_srs_config
->
parse_options
(
argc
,
argv
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// change the work dir and set cwd.
string
cwd
=
_srs_config
->
get_work_dir
();
if
(
!
cwd
.
empty
()
&&
cwd
!=
"./"
&&
(
ret
=
chdir
(
cwd
.
c_str
()))
!=
ERROR_SUCCESS
)
{
srs_error
(
"change cwd to %s failed. ret=%d"
,
cwd
.
c_str
(),
ret
);
return
ret
;
}
if
((
ret
=
_srs_config
->
initialize_cwd
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// config parsed, initialize log.
if
((
ret
=
_srs_log
->
initialize
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// config already applied to log.
srs_trace
(
RTMP_SIG_SRS_SERVER
", stable is "
RTMP_SIG_SRS_PRIMARY
);
srs_trace
(
"license: "
RTMP_SIG_SRS_LICENSE
", "
RTMP_SIG_SRS_COPYRIGHT
);
srs_trace
(
"authors: "
RTMP_SIG_SRS_AUTHROS
);
srs_trace
(
"contributors: "
SRS_AUTO_CONSTRIBUTORS
);
srs_trace
(
"build: %s, configure:%s, uname: %s"
,
SRS_AUTO_BUILD_DATE
,
SRS_AUTO_USER_CONFIGURE
,
SRS_AUTO_UNAME
);
srs_trace
(
"configure detail: "
SRS_AUTO_CONFIGURE
);
#ifdef SRS_AUTO_EMBEDED_TOOL_CHAIN
srs_trace
(
"crossbuild tool chain: "
SRS_AUTO_EMBEDED_TOOL_CHAIN
);
#endif
srs_trace
(
"cwd=%s, work_dir=%s"
,
_srs_config
->
cwd
().
c_str
(),
cwd
.
c_str
());
#ifdef SRS_PERF_GLIBC_MEMORY_CHECK
// ensure glibc write error to stderr.
setenv
(
"LIBC_FATAL_STDERR_"
,
"1"
,
1
);
// ensure glibc to do alloc check.
setenv
(
"MALLOC_CHECK_"
,
"1"
,
1
);
srs_trace
(
"env MALLOC_CHECK_=1 LIBC_FATAL_STDERR_=1"
);
#endif
#ifdef SRS_AUTO_GPERF_MD
char
*
TCMALLOC_PAGE_FENCE
=
getenv
(
"TCMALLOC_PAGE_FENCE"
);
if
(
!
TCMALLOC_PAGE_FENCE
||
strcmp
(
TCMALLOC_PAGE_FENCE
,
"1"
))
{
srs_trace
(
"gmd enabled without env TCMALLOC_PAGE_FENCE=1"
);
}
else
{
srs_trace
(
"env TCMALLOC_PAGE_FENCE=1"
);
}
#endif
// we check the config when the log initialized.
if
((
ret
=
_srs_config
->
check_config
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// features
show_macro_features
();
SrsServer
*
svr
=
new
SrsServer
();
SrsAutoFree
(
SrsServer
,
svr
);
/**
* we do nothing in the constructor of server,
* and use initialize to create members, set hooks for instance the reload handler,
* all initialize will done in this stage.
*/
if
((
ret
=
svr
->
initialize
(
NULL
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
run
(
svr
);
}
/**
* show the features by macro, the actual macro values.
*/
void
show_macro_features
()
{
if
(
true
)
{
...
...
@@ -205,130 +311,25 @@ void show_macro_features()
SRS_PERF_MW_SLEEP
,
possible_mr_latency
,
SRS_PERF_PLAY_QUEUE
*
1000
);
#ifdef SRS_AUTO_MEM_WATCH
#warning "srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script."
#warning "srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script."
srs_warn
(
"srs memory watcher will hurts performance. user should kill by SIGTERM or init.d script."
);
#endif
#if defined(SRS_AUTO_STREAM_CASTER)
#warning "stream caster is experiment feature."
#warning "stream caster is experiment feature."
srs_warn
(
"stream caster is experiment feature."
);
#endif
#if VERSION_MAJOR > VERSION_STABLE
#warning "current branch is not stable, please use stable branch instead."
#warning "current branch is not stable, please use stable branch instead."
srs_warn
(
"SRS %s is not stable, please use stable branch %s instead"
,
RTMP_SIG_SRS_VERSION
,
VERSION_STABLE_BRANCH
);
#endif
#if defined(SRS_PERF_SO_SNDBUF_SIZE) && !defined(SRS_PERF_MW_SO_SNDBUF)
#error "SRS_PERF_SO_SNDBUF_SIZE depends on SRS_PERF_MW_SO_SNDBUF"
#error "SRS_PERF_SO_SNDBUF_SIZE depends on SRS_PERF_MW_SO_SNDBUF"
#endif
}
/**
* main entrance.
*/
int
main
(
int
argc
,
char
**
argv
)
{
int
ret
=
ERROR_SUCCESS
;
// TODO: support both little and big endian.
srs_assert
(
srs_is_little_endian
());
// for gperf gmp or gcp,
// should never enable it when not enabled for performance issue.
#ifdef SRS_AUTO_GPERF_MP
HeapProfilerStart
(
"gperf.srs.gmp"
);
#endif
#ifdef SRS_AUTO_GPERF_CP
ProfilerStart
(
"gperf.srs.gcp"
);
#endif
// directly compile error when these two macro defines.
#if defined(SRS_AUTO_GPERF_MC) && defined(SRS_AUTO_GPERF_MP)
#error ("option --with-gmc confict with --with-gmp, "
"@see: http://google-perftools.googlecode.com/svn/trunk/doc/heap_checker.html
\n
"
"Note that since the heap-checker uses the heap-profiling framework internally, "
"it is not possible to run both the heap-checker and heap profiler at the same time"
);
#endif
// never use gmp to check memory leak.
#ifdef SRS_AUTO_GPERF_MP
#warning "gmp is not used for memory leak, please use gmc instead."
#endif
// never use srs log(srs_trace, srs_error, etc) before config parse the option,
// which will load the log config and apply it.
if
((
ret
=
_srs_config
->
parse_options
(
argc
,
argv
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// change the work dir and set cwd.
string
cwd
=
_srs_config
->
get_work_dir
();
if
(
!
cwd
.
empty
()
&&
cwd
!=
"./"
&&
(
ret
=
chdir
(
cwd
.
c_str
()))
!=
ERROR_SUCCESS
)
{
srs_error
(
"change cwd to %s failed. ret=%d"
,
cwd
.
c_str
(),
ret
);
return
ret
;
}
if
((
ret
=
_srs_config
->
initialize_cwd
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// config parsed, initialize log.
if
((
ret
=
_srs_log
->
initialize
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// config already applied to log.
srs_trace
(
RTMP_SIG_SRS_SERVER
", stable is "
RTMP_SIG_SRS_PRIMARY
);
srs_trace
(
"license: "
RTMP_SIG_SRS_LICENSE
", "
RTMP_SIG_SRS_COPYRIGHT
);
srs_trace
(
"authors: "
RTMP_SIG_SRS_AUTHROS
);
srs_trace
(
"contributors: "
SRS_AUTO_CONSTRIBUTORS
);
srs_trace
(
"build: %s, configure:%s, uname: %s"
,
SRS_AUTO_BUILD_DATE
,
SRS_AUTO_USER_CONFIGURE
,
SRS_AUTO_UNAME
);
srs_trace
(
"configure detail: "
SRS_AUTO_CONFIGURE
);
#ifdef SRS_AUTO_EMBEDED_TOOL_CHAIN
srs_trace
(
"crossbuild tool chain: "
SRS_AUTO_EMBEDED_TOOL_CHAIN
);
#endif
srs_trace
(
"cwd=%s, work_dir=%s"
,
_srs_config
->
cwd
().
c_str
(),
cwd
.
c_str
());
#ifdef SRS_PERF_GLIBC_MEMORY_CHECK
// ensure glibc write error to stderr.
setenv
(
"LIBC_FATAL_STDERR_"
,
"1"
,
1
);
// ensure glibc to do alloc check.
setenv
(
"MALLOC_CHECK_"
,
"1"
,
1
);
srs_trace
(
"env MALLOC_CHECK_=1 LIBC_FATAL_STDERR_=1"
);
#endif
#ifdef SRS_AUTO_GPERF_MD
char
*
TCMALLOC_PAGE_FENCE
=
getenv
(
"TCMALLOC_PAGE_FENCE"
);
if
(
!
TCMALLOC_PAGE_FENCE
||
strcmp
(
TCMALLOC_PAGE_FENCE
,
"1"
))
{
srs_trace
(
"gmd enabled without env TCMALLOC_PAGE_FENCE=1"
);
}
else
{
srs_trace
(
"env TCMALLOC_PAGE_FENCE=1"
);
}
#endif
// we check the config when the log initialized.
if
((
ret
=
_srs_config
->
check_config
())
!=
ERROR_SUCCESS
)
{
return
ret
;
}
// features
show_macro_features
();
SrsServer
*
svr
=
new
SrsServer
();
SrsAutoFree
(
SrsServer
,
svr
);
/**
* we do nothing in the constructor of server,
* and use initialize to create members, set hooks for instance the reload handler,
* all initialize will done in this stage.
*/
if
((
ret
=
svr
->
initialize
(
NULL
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
return
run
(
svr
);
}
int
run
(
SrsServer
*
svr
)
{
// if not deamon, directly run master.
...
...
请
注册
或
登录
后发表评论