mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix bug #162, requires epoll. 0.9.222
This commit is contained in:
parent
967de9d2e7
commit
b830b995e6
5 changed files with 54 additions and 13 deletions
|
@ -23,6 +23,52 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_st.hpp>
|
||||
|
||||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_kernel_log.hpp>
|
||||
|
||||
#include <sys/epoll.h>
|
||||
bool srs_st_epoll_is_supported(void)
|
||||
{
|
||||
struct epoll_event ev;
|
||||
|
||||
ev.events = EPOLLIN;
|
||||
ev.data.ptr = NULL;
|
||||
/* Guaranteed to fail */
|
||||
epoll_ctl(-1, EPOLL_CTL_ADD, -1, &ev);
|
||||
|
||||
return (errno != ENOSYS);
|
||||
}
|
||||
|
||||
int srs_init_st()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// check epoll, some old linux donot support epoll.
|
||||
// @see https://github.com/winlinvip/simple-rtmp-server/issues/162
|
||||
if (!srs_st_epoll_is_supported()) {
|
||||
ret = ERROR_ST_SET_EPOLL;
|
||||
srs_error("epoll required. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// use linux epoll.
|
||||
if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) {
|
||||
ret = ERROR_ST_SET_EPOLL;
|
||||
srs_error("st_set_eventsys use linux epoll failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("st_set_eventsys use linux epoll success");
|
||||
|
||||
if(st_init() != 0){
|
||||
ret = ERROR_ST_INITIALIZE;
|
||||
srs_error("st_init failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("st_init success");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void srs_close_stfd(st_netfd_t& stfd)
|
||||
{
|
||||
if (stfd) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue