mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
support server cycle handler. 2.0.153.
This commit is contained in:
parent
3b4bd194b6
commit
717d088376
10 changed files with 85 additions and 15 deletions
|
@ -389,6 +389,14 @@ void SrsSignalManager::sig_catcher(int signo)
|
|||
errno = err;
|
||||
}
|
||||
|
||||
ISrsServerCycle::ISrsServerCycle()
|
||||
{
|
||||
}
|
||||
|
||||
ISrsServerCycle::~ISrsServerCycle()
|
||||
{
|
||||
}
|
||||
|
||||
SrsServer::SrsServer()
|
||||
{
|
||||
signal_reload = false;
|
||||
|
@ -397,6 +405,8 @@ SrsServer::SrsServer()
|
|||
|
||||
signal_manager = NULL;
|
||||
|
||||
handler = NULL;
|
||||
|
||||
// donot new object in constructor,
|
||||
// for some global instance is not ready now,
|
||||
// new these objects in initialize instead.
|
||||
|
@ -456,6 +466,8 @@ void SrsServer::destroy()
|
|||
|
||||
srs_freep(signal_manager);
|
||||
|
||||
srs_freep(handler);
|
||||
|
||||
// @remark never destroy the connections,
|
||||
// for it's still alive.
|
||||
|
||||
|
@ -464,7 +476,7 @@ void SrsServer::destroy()
|
|||
// and segment fault.
|
||||
}
|
||||
|
||||
int SrsServer::initialize()
|
||||
int SrsServer::initialize(ISrsServerCycle* cycle_handler)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -480,6 +492,11 @@ int SrsServer::initialize()
|
|||
srs_assert(!signal_manager);
|
||||
signal_manager = new SrsSignalManager(this);
|
||||
|
||||
handler = cycle_handler;
|
||||
if(handler && (ret = handler->initialize()) != ERROR_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_API
|
||||
if ((ret = http_api_mux->initialize()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
|
@ -795,6 +812,11 @@ int SrsServer::do_cycle()
|
|||
|
||||
// the deamon thread, update the time cache
|
||||
while (true) {
|
||||
if(handler && (ret = handler->on_cycle(conns.size())) != ERROR_SUCCESS){
|
||||
srs_error("cycle handle failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// the interval in config.
|
||||
int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() / SRS_SYS_CYCLE_INTERVAL);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue