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-01-01 16:27:45 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
99b9fa0c251a27bb3a9e724de67578111066c17f
99b9fa0c
1 parent
fabdf950
fix the forwarder dead when st_thread interrupt at st_usleep, check thread->can_loop().
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
29 行增加
和
1 行删除
trunk/src/core/srs_core_forward.cpp
trunk/src/core/srs_core_thread.cpp
trunk/src/core/srs_core_thread.hpp
trunk/src/core/srs_core_forward.cpp
查看文件 @
99b9fa0
...
...
@@ -290,7 +290,7 @@ int SrsForwarder::forward()
SrsPithyPrint
pithy_print
(
SRS_STAGE_FORWARDER
);
while
(
true
)
{
while
(
pthread
->
can_loop
()
)
{
// switch to other st-threads.
st_usleep
(
0
);
...
...
trunk/src/core/srs_core_thread.cpp
查看文件 @
99b9fa0
...
...
@@ -102,6 +102,11 @@ void SrsThread::stop()
}
}
bool
SrsThread
::
can_loop
()
{
return
loop
;
}
void
SrsThread
::
thread_cycle
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/core/srs_core_thread.hpp
查看文件 @
99b9fa0
...
...
@@ -43,6 +43,23 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* when stop, the thread will interrupt the st_thread,
* which will cause the socket to return error and
* terminate the cycle thread.
*
* when thread interrupt, the socket maybe not got EINT,
* espectially on st_usleep(), so the cycle must check the loop,
* when handler->cycle() has loop itself, for example:
* handler->cycle() is:
* while (true):
* st_usleep(0);
* if (read_from_socket(skt) < 0) break;
* if thread stop when read_from_socket, it's ok, the loop will break,
* but when thread stop interrupt the s_usleep(0), then the loop is
* death loop.
* in a word, the handler->cycle() must:
* handler->cycle() is:
* while (pthread->can_loop()):
* st_usleep(0);
* if (read_from_socket(skt) < 0) break;
* check the loop, then it works.
*/
class
ISrsThreadHandler
{
...
...
@@ -90,6 +107,12 @@ public:
* @remark user can stop multiple times, ignore if already stopped.
*/
virtual
void
stop
();
/**
* whether the thread should loop,
* used for handler->cycle() which has a loop method,
* to check this method, break if false.
*/
virtual
bool
can_loop
();
private
:
virtual
void
thread_cycle
();
static
void
*
thread_fun
(
void
*
arg
);
...
...
请
注册
或
登录
后发表评论