mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
for bug #194, use play fd poll to improve performance, it works.
This commit is contained in:
parent
164f632b62
commit
21f16f3a83
1 changed files with 9 additions and 4 deletions
|
@ -26,6 +26,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_kernel_log.hpp>
|
||||
|
||||
// the interval in us to refresh the poll for all fds.
|
||||
// for performance refine, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
|
||||
#define SRS_POLL_CYCLE_INTERVAL 10 * 1000 * 1000
|
||||
|
||||
SrsPoll::SrsPoll()
|
||||
{
|
||||
_pds = NULL;
|
||||
|
@ -54,10 +58,8 @@ int SrsPoll::cycle()
|
|||
}
|
||||
|
||||
int nb_pds = (int)fds.size();
|
||||
|
||||
st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||
return ret;
|
||||
|
||||
// TODO: FIXME: use more efficient way for the poll.
|
||||
srs_freep(_pds);
|
||||
_pds = new pollfd[nb_pds];
|
||||
|
||||
|
@ -77,7 +79,10 @@ return ret;
|
|||
srs_assert(index == (int)fds.size());
|
||||
}
|
||||
|
||||
if (st_poll(_pds, nb_pds, ST_UTIME_NO_TIMEOUT) <= 0) {
|
||||
// Upon successful completion, a non-negative value is returned.
|
||||
// A positive value indicates the total number of OS file descriptors in pds that have events.
|
||||
// A value of 0 indicates that the call timed out.
|
||||
if (st_poll(_pds, nb_pds, SRS_POLL_CYCLE_INTERVAL) < 0) {
|
||||
srs_warn("ignore st_poll failed, size=%d", nb_pds);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue