Skip to content

Commit

Permalink
For #2194, yield for timer, for live publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Feb 19, 2021
1 parent d1bcc03 commit a5a9649
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion trunk/src/app/srs_app_recv_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions trunk/src/app/srs_app_recv_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions trunk/src/app/srs_app_rtmp_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit a5a9649

Please sign in to comment.