fix #110, thread start segment fault, thread cycle stop destroy thread. 0.9.136
正在显示
6 个修改的文件
包含
19 行增加
和
2 行删除
| @@ -242,6 +242,7 @@ Supported operating systems and hardware: | @@ -242,6 +242,7 @@ Supported operating systems and hardware: | ||
| 242 | * 2013-10-17, Created.<br/> | 242 | * 2013-10-17, Created.<br/> |
| 243 | 243 | ||
| 244 | ## History | 244 | ## History |
| 245 | +* 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 | ||
| 245 | * 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 | 246 | * 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 |
| 246 | * <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> | 247 | * <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> |
| 247 | * v1.0, 2014-06-27, SRS online 30days with RTMP/HLS. | 248 | * v1.0, 2014-06-27, SRS online 30days with RTMP/HLS. |
| @@ -910,7 +910,7 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd) | @@ -910,7 +910,7 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd) | ||
| 910 | if ((ret = conn->start()) != ERROR_SUCCESS) { | 910 | if ((ret = conn->start()) != ERROR_SUCCESS) { |
| 911 | return ret; | 911 | return ret; |
| 912 | } | 912 | } |
| 913 | - srs_verbose("conn started success ."); | 913 | + srs_verbose("conn started success."); |
| 914 | 914 | ||
| 915 | srs_verbose("accept client finished. conns=%d, ret=%d", (int)conns.size(), ret); | 915 | srs_verbose("accept client finished. conns=%d, ret=%d", (int)conns.size(), ret); |
| 916 | 916 |
| @@ -67,6 +67,12 @@ SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us, boo | @@ -67,6 +67,12 @@ SrsThread::SrsThread(ISrsThreadHandler* thread_handler, int64_t interval_us, boo | ||
| 67 | loop = false; | 67 | loop = false; |
| 68 | _cid = -1; | 68 | _cid = -1; |
| 69 | _joinable = joinable; | 69 | _joinable = joinable; |
| 70 | + | ||
| 71 | + // in start(), the thread cycle method maybe stop and remove the thread itself, | ||
| 72 | + // and the thread start() is waiting for the _cid, and segment fault then. | ||
| 73 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/110 | ||
| 74 | + // thread will set _cid, callback on_thread_start(), then wait for the can_run signal. | ||
| 75 | + can_run = false; | ||
| 70 | } | 76 | } |
| 71 | 77 | ||
| 72 | SrsThread::~SrsThread() | 78 | SrsThread::~SrsThread() |
| @@ -102,6 +108,9 @@ int SrsThread::start() | @@ -102,6 +108,9 @@ int SrsThread::start() | ||
| 102 | st_usleep(10 * SRS_TIME_MILLISECONDS); | 108 | st_usleep(10 * SRS_TIME_MILLISECONDS); |
| 103 | } | 109 | } |
| 104 | 110 | ||
| 111 | + // now, cycle thread can run. | ||
| 112 | + can_run = true; | ||
| 113 | + | ||
| 105 | return ret; | 114 | return ret; |
| 106 | } | 115 | } |
| 107 | 116 | ||
| @@ -143,6 +152,11 @@ void SrsThread::thread_cycle() | @@ -143,6 +152,11 @@ void SrsThread::thread_cycle() | ||
| 143 | srs_assert(handler); | 152 | srs_assert(handler); |
| 144 | handler->on_thread_start(); | 153 | handler->on_thread_start(); |
| 145 | 154 | ||
| 155 | + // wait for cid to ready, for parent thread to get the cid. | ||
| 156 | + while (!can_run && loop) { | ||
| 157 | + st_usleep(10 * SRS_TIME_MILLISECONDS); | ||
| 158 | + } | ||
| 159 | + | ||
| 146 | while (loop) { | 160 | while (loop) { |
| 147 | if ((ret = handler->on_before_cycle()) != ERROR_SUCCESS) { | 161 | if ((ret = handler->on_before_cycle()) != ERROR_SUCCESS) { |
| 148 | srs_warn("thread on before cycle failed, ignored and retry, ret=%d", ret); | 162 | srs_warn("thread on before cycle failed, ignored and retry, ret=%d", ret); |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "135" | 34 | +#define VERSION_REVISION "136" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论