1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #913, refine server utility

This commit is contained in:
winlin 2017-06-10 15:20:48 +08:00
parent ca9f0bdb1e
commit a20e2c3ef6
15 changed files with 222 additions and 244 deletions

View file

@ -49,37 +49,29 @@ bool srs_st_epoll_is_supported(void)
}
#endif
int srs_st_init()
srs_error_t srs_st_init()
{
int ret = ERROR_SUCCESS;
#ifdef __linux__
// check epoll, some old linux donot support epoll.
// @see https://github.com/ossrs/srs/issues/162
if (!srs_st_epoll_is_supported()) {
ret = ERROR_ST_SET_EPOLL;
srs_error("epoll required on Linux. ret=%d", ret);
return ret;
return srs_error_new(ERROR_ST_SET_EPOLL, "linux epoll disabled");
}
#endif
// Select the best event system available on the OS. In Linux this is
// epoll(). On BSD it will be kqueue.
if (st_set_eventsys(ST_EVENTSYS_ALT) == -1) {
ret = ERROR_ST_SET_EPOLL;
srs_error("st_set_eventsys use %s failed. ret=%d", st_get_eventsys_name(), ret);
return ret;
return srs_error_new(ERROR_ST_SET_EPOLL, "st enable st failed, current is %s", st_get_eventsys_name());
}
srs_info("st_set_eventsys to %s", st_get_eventsys_name());
if(st_init() != 0){
ret = ERROR_ST_INITIALIZE;
srs_error("st_init failed. ret=%d", ret);
return ret;
int r0 = 0;
if((r0 = st_init()) != 0){
return srs_error_new(ERROR_ST_INITIALIZE, "st initialize failed, r0=%d", r0);
}
srs_trace("st_init success, use %s", st_get_eventsys_name());
return ret;
return srs_success;
}
void srs_close_stfd(srs_netfd_t& stfd)

View file

@ -40,7 +40,7 @@ typedef uint64_t srs_utime_t;
#define SRS_UTIME_NO_TIMEOUT ((srs_utime_t) -1LL)
// initialize st, requires epoll.
extern int srs_st_init();
extern srs_error_t srs_st_init();
// close the netfd, and close the underlayer fd.
// @remark when close, user must ensure io completed.