mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for bug #237, refine the thread loop for publish thread. 2.0.47
This commit is contained in:
parent
24a6a723ee
commit
463e1fbc41
2 changed files with 30 additions and 32 deletions
|
@ -66,16 +66,23 @@ int SrsRecvThread::cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
while (trd->can_loop()) {
|
||||||
if (!handler->can_handle()) {
|
if (!handler->can_handle()) {
|
||||||
st_usleep(timeout * 1000);
|
st_usleep(timeout * 1000);
|
||||||
return ret;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsMessage* msg = NULL;
|
SrsMessage* msg = NULL;
|
||||||
|
|
||||||
if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) {
|
// recv and handle message
|
||||||
|
ret = rtmp->recv_message(&msg);
|
||||||
|
if (ret == ERROR_SUCCESS) {
|
||||||
|
ret = handler->handle(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret != ERROR_SUCCESS) {
|
||||||
if (!srs_is_client_gracefully_close(ret)) {
|
if (!srs_is_client_gracefully_close(ret)) {
|
||||||
srs_error("recv client control message failed. ret=%d", ret);
|
srs_error("thread process message failed. ret=%d", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
// we use no timeout to recv, should never got any error.
|
// we use no timeout to recv, should never got any error.
|
||||||
|
@ -86,9 +93,8 @@ int SrsRecvThread::cycle()
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_verbose("play loop recv message. ret=%d", ret);
|
srs_verbose("thread loop recv message. ret=%d", ret);
|
||||||
|
}
|
||||||
handler->handle(msg);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -263,21 +269,13 @@ int SrsPublishRecvThread::handle(SrsMessage* msg)
|
||||||
|
|
||||||
_nb_msgs++;
|
_nb_msgs++;
|
||||||
|
|
||||||
// the rtmp connection will handle this message,
|
// the rtmp connection will handle this message
|
||||||
// quit the thread loop when error.
|
ret = _conn->handle_publish_message(_source, msg, _is_fmle, _is_edge);
|
||||||
recv_error_code = ret = _conn->handle_publish_message(_source, msg, _is_fmle, _is_edge);
|
|
||||||
|
|
||||||
// when error, use stop loop to terminate the thread normally,
|
|
||||||
// for we are in the thread loop now, and should never use stop() to terminate it.
|
|
||||||
if (ret != ERROR_SUCCESS) {
|
|
||||||
trd.stop_loop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// must always free it,
|
// must always free it,
|
||||||
// the source will copy it if need to use.
|
// the source will copy it if need to use.
|
||||||
srs_freep(msg);
|
srs_freep(msg);
|
||||||
|
|
||||||
// TODO: FIXME: implements it.
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// current release version
|
// current release version
|
||||||
#define VERSION_MAJOR 2
|
#define VERSION_MAJOR 2
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 46
|
#define VERSION_REVISION 47
|
||||||
// server info.
|
// server info.
|
||||||
#define RTMP_SIG_SRS_KEY "SRS"
|
#define RTMP_SIG_SRS_KEY "SRS"
|
||||||
#define RTMP_SIG_SRS_ROLE "origin/edge server"
|
#define RTMP_SIG_SRS_ROLE "origin/edge server"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue