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 rtc publisher

This commit is contained in:
winlin 2021-02-11 22:49:54 +08:00
parent a049ce3fb7
commit df1eca10fb

View file

@ -593,7 +593,10 @@ srs_error_t SrsUdpMuxListener::cycle()
// and the size is not determined, so we think there is at least one copy, // and the size is not determined, so we think there is at least one copy,
// and we can reuse the plaintext h264/opus with players when got plaintext. // and we can reuse the plaintext h264/opus with players when got plaintext.
SrsUdpMuxSocket skt(lfd); SrsUdpMuxSocket skt(lfd);
// How many messages to run a yield.
uint32_t nn_msgs_for_yield = 0;
while (true) { while (true) {
if ((err = trd->pull()) != srs_success) { if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "udp listener"); return srs_error_wrap(err, "udp listener");
@ -660,7 +663,14 @@ srs_error_t SrsUdpMuxListener::cycle()
if (SrsUdpPacketRecvCycleInterval > 0) { if (SrsUdpPacketRecvCycleInterval > 0) {
srs_usleep(SrsUdpPacketRecvCycleInterval); srs_usleep(SrsUdpPacketRecvCycleInterval);
} }
// Yield to another coroutines.
// @see https://github.com/ossrs/srs/issues/2194#issuecomment-777485531
if (++nn_msgs_for_yield > 10) {
nn_msgs_for_yield = 0;
srs_thread_yield();
}
} }
return err; return err;