正在显示
5 个修改的文件
包含
54 行增加
和
13 行删除
| @@ -208,6 +208,7 @@ Supported operating systems and hardware: | @@ -208,6 +208,7 @@ Supported operating systems and hardware: | ||
| 208 | * 2013-10-17, Created.<br/> | 208 | * 2013-10-17, Created.<br/> |
| 209 | 209 | ||
| 210 | ## History | 210 | ## History |
| 211 | +* v1.0, 2014-09-30, fix [#162](https://github.com/winlinvip/simple-rtmp-server/issues/162), failed if no epoll. 0.9.222. | ||
| 211 | * v1.0, 2014-09-30, fix [#180](https://github.com/winlinvip/simple-rtmp-server/issues/180), crash for multiple edge publishing the same stream. 0.9.220. | 212 | * v1.0, 2014-09-30, fix [#180](https://github.com/winlinvip/simple-rtmp-server/issues/180), crash for multiple edge publishing the same stream. 0.9.220. |
| 212 | * v1.0, 2014-09-26, fix hls bug, refine config and log, according to clion of jetbrains. 0.9.216. | 213 | * v1.0, 2014-09-26, fix hls bug, refine config and log, according to clion of jetbrains. 0.9.216. |
| 213 | * v1.0, 2014-09-25, fix [#177](https://github.com/winlinvip/simple-rtmp-server/issues/177), dvr segment add config dvr_wait_keyframe. 0.9.213. | 214 | * v1.0, 2014-09-25, fix [#177](https://github.com/winlinvip/simple-rtmp-server/issues/177), dvr segment add config dvr_wait_keyframe. 0.9.213. |
| @@ -528,20 +528,11 @@ int SrsServer::initialize_st() | @@ -528,20 +528,11 @@ int SrsServer::initialize_st() | ||
| 528 | { | 528 | { |
| 529 | int ret = ERROR_SUCCESS; | 529 | int ret = ERROR_SUCCESS; |
| 530 | 530 | ||
| 531 | - // use linux epoll. | ||
| 532 | - if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) { | ||
| 533 | - ret = ERROR_ST_SET_EPOLL; | ||
| 534 | - srs_error("st_set_eventsys use linux epoll failed. ret=%d", ret); | 531 | + // init st |
| 532 | + if ((ret = srs_init_st()) != ERROR_SUCCESS) { | ||
| 533 | + srs_error("init st failed. ret=%d", ret); | ||
| 535 | return ret; | 534 | return ret; |
| 536 | } | 535 | } |
| 537 | - srs_verbose("st_set_eventsys use linux epoll success"); | ||
| 538 | - | ||
| 539 | - if(st_init() != 0){ | ||
| 540 | - ret = ERROR_ST_INITIALIZE; | ||
| 541 | - srs_error("st_init failed. ret=%d", ret); | ||
| 542 | - return ret; | ||
| 543 | - } | ||
| 544 | - srs_verbose("st_init success"); | ||
| 545 | 536 | ||
| 546 | // @remark, st alloc segment use mmap, which only support 32757 threads, | 537 | // @remark, st alloc segment use mmap, which only support 32757 threads, |
| 547 | // if need to support more, for instance, 100k threads, define the macro MALLOC_STACK. | 538 | // if need to support more, for instance, 100k threads, define the macro MALLOC_STACK. |
| @@ -23,6 +23,52 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -23,6 +23,52 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 23 | 23 | ||
| 24 | #include <srs_app_st.hpp> | 24 | #include <srs_app_st.hpp> |
| 25 | 25 | ||
| 26 | +#include <srs_kernel_error.hpp> | ||
| 27 | +#include <srs_kernel_log.hpp> | ||
| 28 | + | ||
| 29 | +#include <sys/epoll.h> | ||
| 30 | +bool srs_st_epoll_is_supported(void) | ||
| 31 | +{ | ||
| 32 | + struct epoll_event ev; | ||
| 33 | + | ||
| 34 | + ev.events = EPOLLIN; | ||
| 35 | + ev.data.ptr = NULL; | ||
| 36 | + /* Guaranteed to fail */ | ||
| 37 | + epoll_ctl(-1, EPOLL_CTL_ADD, -1, &ev); | ||
| 38 | + | ||
| 39 | + return (errno != ENOSYS); | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +int srs_init_st() | ||
| 43 | +{ | ||
| 44 | + int ret = ERROR_SUCCESS; | ||
| 45 | + | ||
| 46 | + // check epoll, some old linux donot support epoll. | ||
| 47 | + // @see https://github.com/winlinvip/simple-rtmp-server/issues/162 | ||
| 48 | + if (!srs_st_epoll_is_supported()) { | ||
| 49 | + ret = ERROR_ST_SET_EPOLL; | ||
| 50 | + srs_error("epoll required. ret=%d", ret); | ||
| 51 | + return ret; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + // use linux epoll. | ||
| 55 | + if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) { | ||
| 56 | + ret = ERROR_ST_SET_EPOLL; | ||
| 57 | + srs_error("st_set_eventsys use linux epoll failed. ret=%d", ret); | ||
| 58 | + return ret; | ||
| 59 | + } | ||
| 60 | + srs_verbose("st_set_eventsys use linux epoll success"); | ||
| 61 | + | ||
| 62 | + if(st_init() != 0){ | ||
| 63 | + ret = ERROR_ST_INITIALIZE; | ||
| 64 | + srs_error("st_init failed. ret=%d", ret); | ||
| 65 | + return ret; | ||
| 66 | + } | ||
| 67 | + srs_verbose("st_init success"); | ||
| 68 | + | ||
| 69 | + return ret; | ||
| 70 | +} | ||
| 71 | + | ||
| 26 | void srs_close_stfd(st_netfd_t& stfd) | 72 | void srs_close_stfd(st_netfd_t& stfd) |
| 27 | { | 73 | { |
| 28 | if (stfd) { | 74 | if (stfd) { |
| @@ -32,6 +32,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -32,6 +32,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 32 | 32 | ||
| 33 | #include <st.h> | 33 | #include <st.h> |
| 34 | 34 | ||
| 35 | +// initialize st, requires epoll. | ||
| 36 | +extern int srs_init_st(); | ||
| 37 | + | ||
| 35 | // close the netfd, and close the underlayer fd. | 38 | // close the netfd, and close the underlayer fd. |
| 36 | extern void srs_close_stfd(st_netfd_t& stfd); | 39 | extern void srs_close_stfd(st_netfd_t& stfd); |
| 37 | 40 |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "221" | 34 | +#define VERSION_REVISION "222" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论