for bug #194, use play fd poll to improve performance, it works.
正在显示
1 个修改的文件
包含
9 行增加
和
4 行删除
| @@ -26,6 +26,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -26,6 +26,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 26 | #include <srs_kernel_error.hpp> | 26 | #include <srs_kernel_error.hpp> |
| 27 | #include <srs_kernel_log.hpp> | 27 | #include <srs_kernel_log.hpp> |
| 28 | 28 | ||
| 29 | +// the interval in us to refresh the poll for all fds. | ||
| 30 | +// for performance refine, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194 | ||
| 31 | +#define SRS_POLL_CYCLE_INTERVAL 10 * 1000 * 1000 | ||
| 32 | + | ||
| 29 | SrsPoll::SrsPoll() | 33 | SrsPoll::SrsPoll() |
| 30 | { | 34 | { |
| 31 | _pds = NULL; | 35 | _pds = NULL; |
| @@ -54,10 +58,8 @@ int SrsPoll::cycle() | @@ -54,10 +58,8 @@ int SrsPoll::cycle() | ||
| 54 | } | 58 | } |
| 55 | 59 | ||
| 56 | int nb_pds = (int)fds.size(); | 60 | int nb_pds = (int)fds.size(); |
| 57 | - | ||
| 58 | -st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); | ||
| 59 | -return ret; | ||
| 60 | 61 | ||
| 62 | + // TODO: FIXME: use more efficient way for the poll. | ||
| 61 | srs_freep(_pds); | 63 | srs_freep(_pds); |
| 62 | _pds = new pollfd[nb_pds]; | 64 | _pds = new pollfd[nb_pds]; |
| 63 | 65 | ||
| @@ -77,7 +79,10 @@ return ret; | @@ -77,7 +79,10 @@ return ret; | ||
| 77 | srs_assert(index == (int)fds.size()); | 79 | srs_assert(index == (int)fds.size()); |
| 78 | } | 80 | } |
| 79 | 81 | ||
| 80 | - if (st_poll(_pds, nb_pds, ST_UTIME_NO_TIMEOUT) <= 0) { | 82 | + // Upon successful completion, a non-negative value is returned. |
| 83 | + // A positive value indicates the total number of OS file descriptors in pds that have events. | ||
| 84 | + // A value of 0 indicates that the call timed out. | ||
| 85 | + if (st_poll(_pds, nb_pds, SRS_POLL_CYCLE_INTERVAL) < 0) { | ||
| 81 | srs_warn("ignore st_poll failed, size=%d", nb_pds); | 86 | srs_warn("ignore st_poll failed, size=%d", nb_pds); |
| 82 | return ret; | 87 | return ret; |
| 83 | } | 88 | } |
-
请 注册 或 登录 后发表评论