diff --git a/README.md b/README.md
index 80e2e46cc..324b85dd5 100755
--- a/README.md
+++ b/README.md
@@ -242,6 +242,7 @@ Supported operating systems and hardware:
* 2013-10-17, Created.
## 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
* 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.
* v1.0, 2014-06-27, SRS online 30days with RTMP/HLS.
diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf
index 4e4870c12..ee93964ca 100644
--- a/trunk/conf/full.conf
+++ b/trunk/conf/full.conf
@@ -70,6 +70,7 @@ heartbeat {
# {
# "summaries": summaries object.
# }
+ # @remark: optional config.
# default: off
summaries off;
}
diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp
index c74313d94..5a9b5c552 100644
--- a/trunk/src/app/srs_app_server.cpp
+++ b/trunk/src/app/srs_app_server.cpp
@@ -910,7 +910,7 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
if ((ret = conn->start()) != ERROR_SUCCESS) {
return ret;
}
- srs_verbose("conn started success .");
+ srs_verbose("conn started success.");
srs_verbose("accept client finished. conns=%d, ret=%d", (int)conns.size(), ret);
diff --git a/trunk/src/app/srs_app_thread.cpp b/trunk/src/app/srs_app_thread.cpp
index 0e75b5dfb..150a2dcd7 100644
--- a/trunk/src/app/srs_app_thread.cpp
+++ b/trunk/src/app/srs_app_thread.cpp
@@ -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);
diff --git a/trunk/src/app/srs_app_thread.hpp b/trunk/src/app/srs_app_thread.hpp
index ec9522bb9..35b936446 100644
--- a/trunk/src/app/srs_app_thread.hpp
+++ b/trunk/src/app/srs_app_thread.hpp
@@ -88,6 +88,7 @@ private:
st_thread_t tid;
int _cid;
bool loop;
+ bool can_run;
bool _joinable;
private:
ISrsThreadHandler* handler;
diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp
index 4ee5d9f01..961e18c16 100644
--- a/trunk/src/core/srs_core.hpp
+++ b/trunk/src/core/srs_core.hpp
@@ -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"