for bug #237, refine the thread loop for publish thread. 2.0.47
正在显示
2 个修改的文件
包含
15 行增加
和
17 行删除
| @@ -66,16 +66,23 @@ int SrsRecvThread::cycle() | @@ -66,16 +66,23 @@ int SrsRecvThread::cycle() | ||
| 66 | { | 66 | { |
| 67 | int ret = ERROR_SUCCESS; | 67 | int ret = ERROR_SUCCESS; |
| 68 | 68 | ||
| 69 | + while (trd->can_loop()) { | ||
| 69 | if (!handler->can_handle()) { | 70 | if (!handler->can_handle()) { |
| 70 | st_usleep(timeout * 1000); | 71 | st_usleep(timeout * 1000); |
| 71 | - return ret; | 72 | + continue; |
| 72 | } | 73 | } |
| 73 | 74 | ||
| 74 | SrsMessage* msg = NULL; | 75 | SrsMessage* msg = NULL; |
| 75 | 76 | ||
| 76 | - if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) { | 77 | + // recv and handle message |
| 78 | + ret = rtmp->recv_message(&msg); | ||
| 79 | + if (ret == ERROR_SUCCESS) { | ||
| 80 | + ret = handler->handle(msg); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + if (ret != ERROR_SUCCESS) { | ||
| 77 | if (!srs_is_client_gracefully_close(ret)) { | 84 | if (!srs_is_client_gracefully_close(ret)) { |
| 78 | - srs_error("recv client control message failed. ret=%d", ret); | 85 | + srs_error("thread process message failed. ret=%d", ret); |
| 79 | } | 86 | } |
| 80 | 87 | ||
| 81 | // we use no timeout to recv, should never got any error. | 88 | // we use no timeout to recv, should never got any error. |
| @@ -86,9 +93,8 @@ int SrsRecvThread::cycle() | @@ -86,9 +93,8 @@ int SrsRecvThread::cycle() | ||
| 86 | 93 | ||
| 87 | return ret; | 94 | return ret; |
| 88 | } | 95 | } |
| 89 | - srs_verbose("play loop recv message. ret=%d", ret); | ||
| 90 | - | ||
| 91 | - handler->handle(msg); | 96 | + srs_verbose("thread loop recv message. ret=%d", ret); |
| 97 | + } | ||
| 92 | 98 | ||
| 93 | return ret; | 99 | return ret; |
| 94 | } | 100 | } |
| @@ -263,21 +269,13 @@ int SrsPublishRecvThread::handle(SrsMessage* msg) | @@ -263,21 +269,13 @@ int SrsPublishRecvThread::handle(SrsMessage* msg) | ||
| 263 | 269 | ||
| 264 | _nb_msgs++; | 270 | _nb_msgs++; |
| 265 | 271 | ||
| 266 | - // the rtmp connection will handle this message, | ||
| 267 | - // quit the thread loop when error. | ||
| 268 | - recv_error_code = ret = _conn->handle_publish_message(_source, msg, _is_fmle, _is_edge); | ||
| 269 | - | ||
| 270 | - // when error, use stop loop to terminate the thread normally, | ||
| 271 | - // for we are in the thread loop now, and should never use stop() to terminate it. | ||
| 272 | - if (ret != ERROR_SUCCESS) { | ||
| 273 | - trd.stop_loop(); | ||
| 274 | - } | 272 | + // the rtmp connection will handle this message |
| 273 | + ret = _conn->handle_publish_message(_source, msg, _is_fmle, _is_edge); | ||
| 275 | 274 | ||
| 276 | // must always free it, | 275 | // must always free it, |
| 277 | // the source will copy it if need to use. | 276 | // the source will copy it if need to use. |
| 278 | srs_freep(msg); | 277 | srs_freep(msg); |
| 279 | 278 | ||
| 280 | - // TODO: FIXME: implements it. | ||
| 281 | return ret; | 279 | return ret; |
| 282 | } | 280 | } |
| 283 | 281 |
| @@ -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 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 46 | 34 | +#define VERSION_REVISION 47 |
| 35 | // server info. | 35 | // server info. |
| 36 | #define RTMP_SIG_SRS_KEY "SRS" | 36 | #define RTMP_SIG_SRS_KEY "SRS" |
| 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" | 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" |
-
请 注册 或 登录 后发表评论