mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #2194, yield for timer, for rtc player
This commit is contained in:
parent
5a28e658a4
commit
ccb79bc7eb
2 changed files with 11 additions and 1 deletions
|
@ -292,6 +292,7 @@ srs_error_t SrsTcpListener::cycle()
|
||||||
|
|
||||||
SrsUdpMuxSocket::SrsUdpMuxSocket(srs_netfd_t fd)
|
SrsUdpMuxSocket::SrsUdpMuxSocket(srs_netfd_t fd)
|
||||||
{
|
{
|
||||||
|
nn_msgs_for_yield_ = 0;
|
||||||
nb_buf = SRS_UDP_MAX_PACKET_SIZE;
|
nb_buf = SRS_UDP_MAX_PACKET_SIZE;
|
||||||
buf = new char[nb_buf];
|
buf = new char[nb_buf];
|
||||||
nread = 0;
|
nread = 0;
|
||||||
|
@ -359,7 +360,14 @@ srs_error_t SrsUdpMuxSocket::sendto(void* data, int size, srs_utime_t timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
return srs_error_new(ERROR_SOCKET_WRITE, "sendto");
|
return srs_error_new(ERROR_SOCKET_WRITE, "sendto");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Yield to another coroutines.
|
||||||
|
// @see https://github.com/ossrs/srs/issues/2194#issuecomment-777542162
|
||||||
|
if (++nn_msgs_for_yield_ > 20) {
|
||||||
|
nn_msgs_for_yield_ = 0;
|
||||||
|
srs_thread_yield();
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,8 @@ public:
|
||||||
class SrsUdpMuxSocket
|
class SrsUdpMuxSocket
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
// For sender yield only.
|
||||||
|
uint32_t nn_msgs_for_yield_;
|
||||||
std::map<uint32_t, std::string> cache_;
|
std::map<uint32_t, std::string> cache_;
|
||||||
SrsBuffer* cache_buffer_;
|
SrsBuffer* cache_buffer_;
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue