1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix #78 st joinable thread must be stop by other threads, 0.9.113

This commit is contained in:
winlin 2014-05-23 17:23:33 +08:00
parent 6fba0db9b5
commit 0eb9e0af5b
14 changed files with 96 additions and 16 deletions

View file

@ -54,7 +54,7 @@ void ISrsThreadHandler::on_thread_stop()
{
}
SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us)
SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us, bool joinable)
{
handler = thread_handler;
cycle_interval_us = interval_us;
@ -62,6 +62,7 @@ SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us)
tid = NULL;
loop = false;
_cid = -1;
_joinable = joinable;
}
SrsThread::~SrsThread()
@ -83,7 +84,7 @@ int SrsThread::start()
return ret;
}
if((tid = st_thread_create(thread_fun, this, 1, 0)) == NULL){
if((tid = st_thread_create(thread_fun, this, (_joinable? 1:0), 0)) == NULL){
ret = ERROR_ST_CREATE_CYCLE_THREAD;
srs_error("st_thread_create failed. ret=%d", ret);
return ret;
@ -93,7 +94,7 @@ int SrsThread::start()
loop = true;
// wait for cid to ready, for parent thread to get the cid.
while (_cid < 0) {
while (_cid < 0 && loop) {
st_usleep(10 * SRS_TIME_MILLISECONDS);
}