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

fix #110, thread start segment fault, thread cycle stop destroy thread. 0.9.136

This commit is contained in:
winlin 2014-06-28 10:57:58 +08:00
parent efed34301c
commit a3f9aa7e1e
6 changed files with 19 additions and 2 deletions

View file

@ -242,6 +242,7 @@ Supported operating systems and hardware:
* 2013-10-17, Created.<br/>
## History
* v1.0, 2014-06-25, fix [#110](https://github.com/winlinvip/simple-rtmp-server/issues/110), thread start segment fault, thread cycle stop destroy thread. 0.9.136
* v1.0, 2014-06-25, fix [#109](https://github.com/winlinvip/simple-rtmp-server/issues/109), fix the system jump time, adjust system startup time. 0.9.135
* <strong>v1.0, 2014-06-27, [1.0 mainline5(0.9.134)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline5) released. 41573 lines.</strong>
* v1.0, 2014-06-27, SRS online 30days with RTMP/HLS.

View file

@ -70,6 +70,7 @@ heartbeat {
# {
# "summaries": summaries object.
# }
# @remark: optional config.
# default: off
summaries off;
}

View file

@ -67,6 +67,12 @@ SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us, boo
loop = false;
_cid = -1;
_joinable = joinable;
// in start(), the thread cycle method maybe stop and remove the thread itself,
// and the thread start() is waiting for the _cid, and segment fault then.
// @see https://github.com/winlinvip/simple-rtmp-server/issues/110
// thread will set _cid, callback on_thread_start(), then wait for the can_run signal.
can_run = false;
}
SrsThread::~SrsThread()
@ -102,6 +108,9 @@ int SrsThread::start()
st_usleep(10 * SRS_TIME_MILLISECONDS);
}
// now, cycle thread can run.
can_run = true;
return ret;
}
@ -143,6 +152,11 @@ void SrsThread::thread_cycle()
srs_assert(handler);
handler->on_thread_start();
// wait for cid to ready, for parent thread to get the cid.
while (!can_run && loop) {
st_usleep(10 * SRS_TIME_MILLISECONDS);
}
while (loop) {
if ((ret = handler->on_before_cycle()) != ERROR_SUCCESS) {
srs_warn("thread on before cycle failed, ignored and retry, ret=%d", ret);

View file

@ -88,6 +88,7 @@ private:
st_thread_t tid;
int _cid;
bool loop;
bool can_run;
bool _joinable;
private:
ISrsThreadHandler* handler;

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "135"
#define VERSION_REVISION "136"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"