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-12-03 14:05:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c457364321d3e5e83296de77f49079df8c533a42
c4573643
1 parent
c0832387
for bug #237, add name for thread. 2.0.47
显示空白字符变更
内嵌
并排对比
正在显示
9 个修改的文件
包含
30 行增加
和
26 行删除
trunk/src/app/srs_app_conn.cpp
trunk/src/app/srs_app_edge.cpp
trunk/src/app/srs_app_encoder.cpp
trunk/src/app/srs_app_forward.cpp
trunk/src/app/srs_app_ingest.cpp
trunk/src/app/srs_app_recv_thread.cpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_thread.cpp
trunk/src/app/srs_app_thread.hpp
trunk/src/app/srs_app_conn.cpp
查看文件 @
c457364
...
...
@@ -37,7 +37,7 @@ SrsConnection::SrsConnection(SrsServer* srs_server, st_netfd_t client_stfd)
// so we never use joinable.
// TODO: FIXME: maybe other thread need to stop it.
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/78
pthread
=
new
SrsThread
(
this
,
0
,
false
);
pthread
=
new
SrsThread
(
"conn"
,
this
,
0
,
false
);
}
SrsConnection
::~
SrsConnection
()
...
...
trunk/src/app/srs_app_edge.cpp
查看文件 @
c457364
...
...
@@ -69,7 +69,7 @@ SrsEdgeIngester::SrsEdgeIngester()
origin_index
=
0
;
stream_id
=
0
;
stfd
=
NULL
;
pthread
=
new
SrsThread
(
this
,
SRS_EDGE_INGESTER_SLEEP_US
,
true
);
pthread
=
new
SrsThread
(
"edge-igs"
,
this
,
SRS_EDGE_INGESTER_SLEEP_US
,
true
);
}
SrsEdgeIngester
::~
SrsEdgeIngester
()
...
...
@@ -386,7 +386,7 @@ SrsEdgeForwarder::SrsEdgeForwarder()
origin_index
=
0
;
stream_id
=
0
;
stfd
=
NULL
;
pthread
=
new
SrsThread
(
this
,
SRS_EDGE_FORWARDER_SLEEP_US
,
true
);
pthread
=
new
SrsThread
(
"edge-fwr"
,
this
,
SRS_EDGE_FORWARDER_SLEEP_US
,
true
);
queue
=
new
SrsMessageQueue
();
send_error_code
=
ERROR_SUCCESS
;
}
...
...
trunk/src/app/srs_app_encoder.cpp
查看文件 @
c457364
...
...
@@ -44,7 +44,7 @@ static std::vector<std::string> _transcoded_url;
SrsEncoder
::
SrsEncoder
()
{
pthread
=
new
SrsThread
(
this
,
SRS_RTMP_ENCODER_SLEEP_US
,
true
);
pthread
=
new
SrsThread
(
"encoder"
,
this
,
SRS_RTMP_ENCODER_SLEEP_US
,
true
);
pithy_print
=
new
SrsPithyPrint
(
SRS_CONSTS_STAGE_ENCODER
);
}
...
...
trunk/src/app/srs_app_forward.cpp
查看文件 @
c457364
...
...
@@ -58,7 +58,7 @@ SrsForwarder::SrsForwarder(SrsSource* _source)
kbps
=
new
SrsKbps
();
stream_id
=
0
;
pthread
=
new
SrsThread
(
this
,
SRS_FORWARDER_SLEEP_US
,
true
);
pthread
=
new
SrsThread
(
"forward"
,
this
,
SRS_FORWARDER_SLEEP_US
,
true
);
queue
=
new
SrsMessageQueue
();
jitter
=
new
SrsRtmpJitter
();
...
...
trunk/src/app/srs_app_ingest.cpp
查看文件 @
c457364
...
...
@@ -36,7 +36,7 @@ using namespace std;
// when error, ingester sleep for a while and retry.
// ingest never sleep a long time, for we must start the stream ASAP.
#define SRS_AUTO_INGESTER_SLEEP_US (int64_t)(
6*1
00*1000LL)
#define SRS_AUTO_INGESTER_SLEEP_US (int64_t)(
3*10
00*1000LL)
SrsIngesterFFMPEG
::
SrsIngesterFFMPEG
(
SrsFFMPEG
*
_ffmpeg
,
string
_vhost
,
string
_id
)
{
...
...
@@ -54,7 +54,7 @@ SrsIngester::SrsIngester()
{
_srs_config
->
subscribe
(
this
);
pthread
=
new
SrsThread
(
this
,
SRS_AUTO_INGESTER_SLEEP_US
,
true
);
pthread
=
new
SrsThread
(
"ingest"
,
this
,
SRS_AUTO_INGESTER_SLEEP_US
,
true
);
pithy_print
=
new
SrsPithyPrint
(
SRS_CONSTS_STAGE_INGESTER
);
}
...
...
trunk/src/app/srs_app_recv_thread.cpp
查看文件 @
c457364
...
...
@@ -40,7 +40,7 @@ SrsRecvThread::SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtm
timeout
=
timeout_ms
;
handler
=
msg_handler
;
rtmp
=
rtmp_sdk
;
trd
=
new
SrsThread
(
this
,
0
,
true
);
trd
=
new
SrsThread
(
"recv"
,
this
,
0
,
true
);
}
SrsRecvThread
::~
SrsRecvThread
()
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
c457364
...
...
@@ -53,9 +53,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// system interval in ms,
// all resolution times should be times togother,
// for example, system-time is 3(300ms),
// then rusage can be 3*x, for instance, 3*10=30(3s),
// the meminfo canbe 30*x, for instance, 30*2=60(6s)
// for example, system-interval is x=1s(1000ms),
// then rusage can be 3*x, for instance, 3*1=3s,
// the meminfo canbe 6*x, for instance, 6*1=6s,
// for performance refine, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
// @remark, recomment to 1000ms.
#define SRS_SYS_CYCLE_INTERVAL 1000
...
...
@@ -63,7 +63,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// update time interval:
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_TIME_RESOLUTION_MS_TIMES
// @see SYS_TIME_RESOLUTION_US
#define SRS_SYS_TIME_RESOLUTION_MS_TIMES
3
#define SRS_SYS_TIME_RESOLUTION_MS_TIMES
1
// update rusage interval:
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_RUSAGE_RESOLUTION_TIMES
...
...
@@ -102,7 +102,7 @@ SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
_server
=
server
;
_type
=
type
;
pthread
=
new
SrsThread
(
this
,
0
,
true
);
pthread
=
new
SrsThread
(
"listen"
,
this
,
0
,
true
);
}
SrsListener
::~
SrsListener
()
...
...
@@ -215,7 +215,7 @@ SrsSignalManager::SrsSignalManager(SrsServer* server)
_server
=
server
;
sig_pipe
[
0
]
=
sig_pipe
[
1
]
=
-
1
;
pthread
=
new
SrsThread
(
this
,
0
,
true
);
pthread
=
new
SrsThread
(
"signal"
,
this
,
0
,
true
);
signal_read_stfd
=
NULL
;
}
...
...
@@ -714,7 +714,7 @@ int SrsServer::do_cycle()
srs_trace
(
"reload config success."
);
}
// update the cache time
or rusage.
// update the cache time
if
((
i
%
SRS_SYS_TIME_RESOLUTION_MS_TIMES
)
==
0
)
{
srs_info
(
"update current time cache."
);
srs_update_system_time_ms
();
...
...
trunk/src/app/srs_app_thread.cpp
查看文件 @
c457364
...
...
@@ -54,8 +54,9 @@ void ISrsThreadHandler::on_thread_stop()
{
}
SrsThread
::
SrsThread
(
ISrsThreadHandler
*
thread_handler
,
int64_t
interval_us
,
bool
joinable
)
SrsThread
::
SrsThread
(
const
char
*
name
,
ISrsThreadHandler
*
thread_handler
,
int64_t
interval_us
,
bool
joinable
)
{
_name
=
name
;
handler
=
thread_handler
;
cycle_interval_us
=
interval_us
;
...
...
@@ -86,7 +87,7 @@ int SrsThread::start()
int
ret
=
ERROR_SUCCESS
;
if
(
tid
)
{
srs_info
(
"thread
already running."
);
srs_info
(
"thread
%s already running."
,
_name
);
return
ret
;
}
...
...
@@ -141,7 +142,7 @@ void SrsThread::thread_cycle()
int
ret
=
ERROR_SUCCESS
;
_srs_context
->
generate_id
();
srs_info
(
"thread
cycle start"
);
srs_info
(
"thread
%s cycle start"
,
_name
);
_cid
=
_srs_context
->
get_id
();
...
...
@@ -155,24 +156,24 @@ void SrsThread::thread_cycle()
while
(
loop
)
{
if
((
ret
=
handler
->
on_before_cycle
())
!=
ERROR_SUCCESS
)
{
srs_warn
(
"thread
on before cycle failed, ignored and retry, ret=%d"
,
ret
);
srs_warn
(
"thread
%s on before cycle failed, ignored and retry, ret=%d"
,
_name
,
ret
);
goto
failed
;
}
srs_info
(
"thread on before cycle success"
);
srs_info
(
"thread
%s
on before cycle success"
);
if
((
ret
=
handler
->
cycle
())
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
srs_warn
(
"thread cycle failed, ignored and retry, ret=%d"
,
ret
);
srs_warn
(
"thread cycle failed, ignored and retry, ret=%d"
,
_name
,
ret
);
}
goto
failed
;
}
srs_info
(
"thread
cycle success"
);
srs_info
(
"thread
%s cycle success"
,
_name
);
if
((
ret
=
handler
->
on_end_cycle
())
!=
ERROR_SUCCESS
)
{
srs_warn
(
"thread
on end cycle failed, ignored and retry, ret=%d"
,
ret
);
srs_warn
(
"thread
%s on end cycle failed, ignored and retry, ret=%d"
,
_name
,
ret
);
goto
failed
;
}
srs_info
(
"thread
on end cycle success"
);
srs_info
(
"thread
%s on end cycle success"
,
_name
);
failed
:
if
(
!
loop
)
{
...
...
@@ -187,7 +188,7 @@ failed:
}
handler
->
on_thread_stop
();
srs_info
(
"thread
cycle finished"
);
srs_info
(
"thread
%s cycle finished"
,
_name
);
}
void
*
SrsThread
::
thread_fun
(
void
*
arg
)
...
...
trunk/src/app/srs_app_thread.hpp
查看文件 @
c457364
...
...
@@ -88,23 +88,26 @@ private:
bool
loop
;
bool
can_run
;
bool
_joinable
;
const
char
*
_name
;
private
:
ISrsThreadHandler
*
handler
;
int64_t
cycle_interval_us
;
public
:
/**
* initialize the thread.
* @param name, human readable name for st debug.
* @param thread_handler, the cycle handler for the thread.
* @param interval_us, the sleep interval when cycle finished.
* @param joinable, if joinable, other thread must stop the thread.
* @remark if joinable, thread never quit itself, or memory leak.
* @see: https://github.com/winlinvip/simple-rtmp-server/issues/78
* @remark about st debug, see st-1.9/README, _st_iterate_threads_flag
*/
/**
* TODO: FIXME: maybe all thread must be reap by others threads,
* @see: https://github.com/winlinvip/simple-rtmp-server/issues/77
*/
SrsThread
(
ISrsThreadHandler
*
thread_handler
,
int64_t
interval_us
,
bool
joinable
);
SrsThread
(
const
char
*
name
,
ISrsThreadHandler
*
thread_handler
,
int64_t
interval_us
,
bool
joinable
);
virtual
~
SrsThread
();
public
:
/**
...
...
请
注册
或
登录
后发表评论