正在显示
3 个修改的文件
包含
17 行增加
和
14 行删除
| @@ -293,10 +293,14 @@ private: | @@ -293,10 +293,14 @@ private: | ||
| 293 | virtual void dispose(); | 293 | virtual void dispose(); |
| 294 | // server startup workflow, @see run_master() | 294 | // server startup workflow, @see run_master() |
| 295 | public: | 295 | public: |
| 296 | + /** | ||
| 297 | + * initialize server with callback handler. | ||
| 298 | + * @remark user must free the cycle handler. | ||
| 299 | + */ | ||
| 296 | virtual int initialize(ISrsServerCycle* cycle_handler); | 300 | virtual int initialize(ISrsServerCycle* cycle_handler); |
| 301 | + virtual int initialize_st(); | ||
| 297 | virtual int initialize_signal(); | 302 | virtual int initialize_signal(); |
| 298 | virtual int acquire_pid_file(); | 303 | virtual int acquire_pid_file(); |
| 299 | - virtual int initialize_st(); | ||
| 300 | virtual int listen(); | 304 | virtual int listen(); |
| 301 | virtual int register_signal(); | 305 | virtual int register_signal(); |
| 302 | virtual int http_handle(); | 306 | virtual int http_handle(); |
| @@ -129,19 +129,20 @@ namespace internal { | @@ -129,19 +129,20 @@ namespace internal { | ||
| 129 | if (ret) { | 129 | if (ret) { |
| 130 | srs_warn("core: ignore join thread failed."); | 130 | srs_warn("core: ignore join thread failed."); |
| 131 | } | 131 | } |
| 132 | + } | ||
| 133 | + | ||
| 134 | + // wait the thread actually terminated. | ||
| 135 | + // sometimes the thread join return -1, for example, | ||
| 136 | + // when thread use st_recvfrom, the thread join return -1. | ||
| 137 | + // so here, we use a variable to ensure the thread stopped. | ||
| 138 | + // @remark even the thread not joinable, we must ensure the thread stopped when stop. | ||
| 139 | + while (!really_terminated) { | ||
| 140 | + st_usleep(10 * 1000); | ||
| 132 | 141 | ||
| 133 | - // wait the thread actually terminated. | ||
| 134 | - // sometimes the thread join return -1, for example, | ||
| 135 | - // when thread use st_recvfrom, the thread join return -1. | ||
| 136 | - // so here, we use a variable to ensure the thread stopped. | ||
| 137 | - while (!really_terminated) { | ||
| 138 | - st_usleep(10 * 1000); | ||
| 139 | - | ||
| 140 | - if (really_terminated) { | ||
| 141 | - break; | ||
| 142 | - } | ||
| 143 | - srs_warn("core: wait thread to actually terminated"); | 142 | + if (really_terminated) { |
| 143 | + break; | ||
| 144 | } | 144 | } |
| 145 | + srs_warn("core: wait thread to actually terminated"); | ||
| 145 | } | 146 | } |
| 146 | 147 | ||
| 147 | tid = NULL; | 148 | tid = NULL; |
-
请 注册 或 登录 后发表评论