1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #2194, yield for timer, for live publisher

This commit is contained in:
winlin 2021-02-11 22:03:00 +08:00
parent 211b05fc64
commit 4fc1a19415
3 changed files with 11 additions and 1 deletions

View file

@ -288,7 +288,8 @@ SrsPublishRecvThread::SrsPublishRecvThread(SrsRtmpServer* rtmp_sdk, SrsRequest*
_conn = conn;
_source = source;
nn_msgs_for_yield_ = 0;
recv_error = srs_success;
_nb_msgs = 0;
video_frames = 0;
@ -401,6 +402,13 @@ srs_error_t SrsPublishRecvThread::consume(SrsCommonMessage* msg)
if (err != srs_success) {
return srs_error_wrap(err, "handle publish message");
}
// Yield to another coroutines.
// @see https://github.com/ossrs/srs/issues/2194#issuecomment-777463768
if (++nn_msgs_for_yield_ >= 15) {
nn_msgs_for_yield_ = 0;
srs_thread_yield();
}
return err;
}

View file

@ -144,6 +144,7 @@ class SrsPublishRecvThread : virtual public ISrsMessagePumper, virtual public IS
#endif
{
private:
uint32_t nn_msgs_for_yield_;
SrsRecvThread trd;
SrsRtmpServer* rtmp;
SrsRequest* req;

View file

@ -828,6 +828,7 @@ srs_error_t SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, Sr
}
// Yield to another coroutines.
// @see https://github.com/ossrs/srs/issues/2194#issuecomment-777437476
srs_thread_yield();
}