From 21f16f3a83b63ffb7d868bf0ddcf9e5a655ddecc Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 11 Nov 2014 18:46:35 +0800 Subject: [PATCH] for bug #194, use play fd poll to improve performance, it works. --- trunk/src/app/srs_app_poll.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/trunk/src/app/srs_app_poll.cpp b/trunk/src/app/srs_app_poll.cpp index 6ead87078..859e49e11 100644 --- a/trunk/src/app/srs_app_poll.cpp +++ b/trunk/src/app/srs_app_poll.cpp @@ -26,6 +26,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +// 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; }