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
胡斌
2017-06-07 13:00:12 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
28057db4f5c5b9ab70284aee2801970a3d53bd76
28057db4
1 parent
74e2be35
add root directive cpu_affinity, to set the cpu affinity of srs
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
25 行增加
和
3 行删除
trunk/conf/full.conf
trunk/src/app/srs_app_config.cpp
trunk/conf/full.conf
查看文件 @
28057db
...
...
@@ -65,6 +65,9 @@ asprocess off;
# whether using build-in speex to aac transcoding
# default: off
speex2aac
off
;
# set cpu affinity,the index of the cpu core,0,1,2,...
# default -1,don't set affinity
cpu_affinity
-
1
;
#############################################################################################
# heartbeat/stats sections
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
28057db
...
...
@@ -47,6 +47,10 @@ using namespace std;
#include <srs_app_utility.hpp>
#include <srs_core_performance.hpp>
#include "../../objs/version.h"
#ifndef __USE_GNU
#define __USE_GNU
#endif
#include<sched.h>
using
namespace
_srs_internal
;
...
...
@@ -1007,8 +1011,6 @@ int SrsConfig::reload_conf(SrsConfig* conf)
return
ret
;
}
set_config_static
();
return
ret
;
}
...
...
@@ -1584,6 +1586,7 @@ int SrsConfig::check_config()
&&
n
!=
"http_api"
&&
n
!=
"stats"
&&
n
!=
"vhost"
&&
n
!=
"pithy_print_ms"
&&
n
!=
"http_stream"
&&
n
!=
"http_server"
&&
n
!=
"stream_caster"
&&
n
!=
"utc_time"
&&
n
!=
"work_dir"
&&
n
!=
"asprocess"
&&
n
!=
"speex2aac"
&&
n
!=
"cpu_affinity"
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"unsupported directive %s, ret=%d"
,
n
.
c_str
(),
ret
);
...
...
@@ -2102,7 +2105,23 @@ void SrsConfig::set_config_static()
}
else
_speex2aac
=
false
;
conf
=
root
->
get
(
"cpu_affinity"
);
int
cpu_index
=
-
1
;
if
(
conf
){
cpu_index
=
atoi
(
conf
->
arg0
().
c_str
());
}
if
(
cpu_index
>=
0
){
cpu_set_t
mask
;
CPU_ZERO
(
&
mask
);
CPU_SET
(
cpu_index
,
&
mask
);
if
(
sched_setaffinity
(
0
,
sizeof
(
mask
),
&
mask
)
==
-
1
){
srs_error
(
"error when set cpu affinity to CPU:%d"
,
cpu_index
);
}
else
{
srs_trace
(
"success in set cpu affinity to CPU:%d"
,
cpu_index
);
}
}
}
int
SrsConfig
::
parse_buffer
(
SrsConfigBuffer
*
buffer
)
...
...
请
注册
或
登录
后发表评论