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:
parent
d1bcc03d9a
commit
a5a96491a3
3 changed files with 11 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue