正在显示
1 个修改的文件
包含
9 行增加
和
5 行删除
| @@ -127,8 +127,6 @@ namespace internal | @@ -127,8 +127,6 @@ namespace internal | ||
| 127 | return; | 127 | return; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | - loop = false; | ||
| 131 | - | ||
| 132 | dispose(); | 130 | dispose(); |
| 133 | 131 | ||
| 134 | _cid = -1; | 132 | _cid = -1; |
| @@ -152,6 +150,9 @@ namespace internal | @@ -152,6 +150,9 @@ namespace internal | ||
| 152 | return; | 150 | return; |
| 153 | } | 151 | } |
| 154 | 152 | ||
| 153 | + // notify the cycle to stop loop. | ||
| 154 | + loop = false; | ||
| 155 | + | ||
| 155 | // the interrupt will cause the socket to read/write error, | 156 | // the interrupt will cause the socket to read/write error, |
| 156 | // which will terminate the cycle thread. | 157 | // which will terminate the cycle thread. |
| 157 | st_thread_interrupt(tid); | 158 | st_thread_interrupt(tid); |
| @@ -186,9 +187,11 @@ namespace internal | @@ -186,9 +187,11 @@ namespace internal | ||
| 186 | { | 187 | { |
| 187 | int ret = ERROR_SUCCESS; | 188 | int ret = ERROR_SUCCESS; |
| 188 | 189 | ||
| 190 | + // TODO: FIXME: it's better for user to specifies the cid, | ||
| 191 | + // because sometimes we need to merge cid, for example, | ||
| 192 | + // the publish thread should use the same cid of connection. | ||
| 189 | _srs_context->generate_id(); | 193 | _srs_context->generate_id(); |
| 190 | srs_info("thread %s cycle start", _name); | 194 | srs_info("thread %s cycle start", _name); |
| 191 | - | ||
| 192 | _cid = _srs_context->get_id(); | 195 | _cid = _srs_context->get_id(); |
| 193 | 196 | ||
| 194 | srs_assert(handler); | 197 | srs_assert(handler); |
| @@ -238,8 +241,9 @@ namespace internal | @@ -238,8 +241,9 @@ namespace internal | ||
| 238 | // readly terminated now. | 241 | // readly terminated now. |
| 239 | really_terminated = true; | 242 | really_terminated = true; |
| 240 | 243 | ||
| 241 | - handler->on_thread_stop(); | ||
| 242 | srs_info("thread %s cycle finished", _name); | 244 | srs_info("thread %s cycle finished", _name); |
| 245 | + // @remark in this callback, user may delete this, so never use this->xxx anymore. | ||
| 246 | + handler->on_thread_stop(); | ||
| 243 | } | 247 | } |
| 244 | 248 | ||
| 245 | void* SrsThread::thread_fun(void* arg) | 249 | void* SrsThread::thread_fun(void* arg) |
| @@ -249,7 +253,7 @@ namespace internal | @@ -249,7 +253,7 @@ namespace internal | ||
| 249 | 253 | ||
| 250 | obj->thread_cycle(); | 254 | obj->thread_cycle(); |
| 251 | 255 | ||
| 252 | - // for valgrind to detect. | 256 | + // delete cid for valgrind to detect memory leak. |
| 253 | SrsThreadContext* ctx = dynamic_cast<SrsThreadContext*>(_srs_context); | 257 | SrsThreadContext* ctx = dynamic_cast<SrsThreadContext*>(_srs_context); |
| 254 | if (ctx) { | 258 | if (ctx) { |
| 255 | ctx->clear_cid(); | 259 | ctx->clear_cid(); |
-
请 注册 或 登录 后发表评论