mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the signal manager.
This commit is contained in:
parent
7996b3b789
commit
d317528af9
1 changed files with 21 additions and 19 deletions
|
@ -374,8 +374,6 @@ SrsSignalManager::SrsSignalManager(SrsServer* server)
|
||||||
|
|
||||||
SrsSignalManager::~SrsSignalManager()
|
SrsSignalManager::~SrsSignalManager()
|
||||||
{
|
{
|
||||||
srs_freep(pthread);
|
|
||||||
|
|
||||||
srs_close_stfd(signal_read_stfd);
|
srs_close_stfd(signal_read_stfd);
|
||||||
|
|
||||||
if (sig_pipe[0] > 0) {
|
if (sig_pipe[0] > 0) {
|
||||||
|
@ -384,24 +382,13 @@ SrsSignalManager::~SrsSignalManager()
|
||||||
if (sig_pipe[1] > 0) {
|
if (sig_pipe[1] > 0) {
|
||||||
::close(sig_pipe[1]);
|
::close(sig_pipe[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srs_freep(pthread);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsSignalManager::initialize()
|
int SrsSignalManager::initialize()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsSignalManager::start()
|
|
||||||
{
|
|
||||||
int ret = ERROR_SUCCESS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Note that if multiple processes are used (see below),
|
|
||||||
* the signal pipe should be initialized after the fork(2) call
|
|
||||||
* so that each process has its own private pipe.
|
|
||||||
*/
|
|
||||||
struct sigaction sa;
|
|
||||||
|
|
||||||
/* Create signal pipe */
|
/* Create signal pipe */
|
||||||
if (pipe(sig_pipe) < 0) {
|
if (pipe(sig_pipe) < 0) {
|
||||||
|
@ -410,6 +397,24 @@ int SrsSignalManager::start()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((signal_read_stfd = st_netfd_open(sig_pipe[0])) == NULL) {
|
||||||
|
ret = ERROR_SYSTEM_CREATE_PIPE;
|
||||||
|
srs_error("create signal manage st pipe failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsSignalManager::start()
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Note that if multiple processes are used (see below),
|
||||||
|
* the signal pipe should be initialized after the fork(2) call
|
||||||
|
* so that each process has its own private pipe.
|
||||||
|
*/
|
||||||
|
struct sigaction sa;
|
||||||
|
|
||||||
/* Install sig_catcher() as a signal handler */
|
/* Install sig_catcher() as a signal handler */
|
||||||
sa.sa_handler = SrsSignalManager::sig_catcher;
|
sa.sa_handler = SrsSignalManager::sig_catcher;
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
|
@ -439,10 +444,6 @@ int SrsSignalManager::start()
|
||||||
int SrsSignalManager::cycle()
|
int SrsSignalManager::cycle()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
if (signal_read_stfd == NULL) {
|
|
||||||
signal_read_stfd = st_netfd_open(sig_pipe[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int signo;
|
int signo;
|
||||||
|
|
||||||
|
@ -852,6 +853,7 @@ int SrsServer::cycle()
|
||||||
#else
|
#else
|
||||||
srs_warn("main cycle terminated, system quit normally.");
|
srs_warn("main cycle terminated, system quit normally.");
|
||||||
dispose();
|
dispose();
|
||||||
|
srs_trace("srs terminated");
|
||||||
exit(0);
|
exit(0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue