正在显示
1 个修改的文件
包含
17 行增加
和
15 行删除
@@ -374,8 +374,6 @@ SrsSignalManager::SrsSignalManager(SrsServer* server) | @@ -374,8 +374,6 @@ SrsSignalManager::SrsSignalManager(SrsServer* server) | ||
374 | 374 | ||
375 | SrsSignalManager::~SrsSignalManager() | 375 | SrsSignalManager::~SrsSignalManager() |
376 | { | 376 | { |
377 | - srs_freep(pthread); | ||
378 | - | ||
379 | srs_close_stfd(signal_read_stfd); | 377 | srs_close_stfd(signal_read_stfd); |
380 | 378 | ||
381 | if (sig_pipe[0] > 0) { | 379 | if (sig_pipe[0] > 0) { |
@@ -384,18 +382,32 @@ SrsSignalManager::~SrsSignalManager() | @@ -384,18 +382,32 @@ SrsSignalManager::~SrsSignalManager() | ||
384 | if (sig_pipe[1] > 0) { | 382 | if (sig_pipe[1] > 0) { |
385 | ::close(sig_pipe[1]); | 383 | ::close(sig_pipe[1]); |
386 | } | 384 | } |
385 | + | ||
386 | + srs_freep(pthread); | ||
387 | } | 387 | } |
388 | 388 | ||
389 | int SrsSignalManager::initialize() | 389 | int SrsSignalManager::initialize() |
390 | { | 390 | { |
391 | int ret = ERROR_SUCCESS; | 391 | int ret = ERROR_SUCCESS; |
392 | + | ||
393 | + /* Create signal pipe */ | ||
394 | + if (pipe(sig_pipe) < 0) { | ||
395 | + ret = ERROR_SYSTEM_CREATE_PIPE; | ||
396 | + srs_error("create signal manager pipe failed. ret=%d", ret); | ||
397 | + return ret; | ||
398 | + } | ||
399 | + | ||
400 | + if ((signal_read_stfd = st_netfd_open(sig_pipe[0])) == NULL) { | ||
401 | + ret = ERROR_SYSTEM_CREATE_PIPE; | ||
402 | + srs_error("create signal manage st pipe failed. ret=%d", ret); | ||
403 | + return ret; | ||
404 | + } | ||
405 | + | ||
392 | return ret; | 406 | return ret; |
393 | } | 407 | } |
394 | 408 | ||
395 | int SrsSignalManager::start() | 409 | int SrsSignalManager::start() |
396 | { | 410 | { |
397 | - int ret = ERROR_SUCCESS; | ||
398 | - | ||
399 | /** | 411 | /** |
400 | * Note that if multiple processes are used (see below), | 412 | * Note that if multiple processes are used (see below), |
401 | * the signal pipe should be initialized after the fork(2) call | 413 | * the signal pipe should be initialized after the fork(2) call |
@@ -403,13 +415,6 @@ int SrsSignalManager::start() | @@ -403,13 +415,6 @@ int SrsSignalManager::start() | ||
403 | */ | 415 | */ |
404 | struct sigaction sa; | 416 | struct sigaction sa; |
405 | 417 | ||
406 | - /* Create signal pipe */ | ||
407 | - if (pipe(sig_pipe) < 0) { | ||
408 | - ret = ERROR_SYSTEM_CREATE_PIPE; | ||
409 | - srs_error("create signal manager pipe failed. ret=%d", ret); | ||
410 | - return ret; | ||
411 | - } | ||
412 | - | ||
413 | /* Install sig_catcher() as a signal handler */ | 418 | /* Install sig_catcher() as a signal handler */ |
414 | sa.sa_handler = SrsSignalManager::sig_catcher; | 419 | sa.sa_handler = SrsSignalManager::sig_catcher; |
415 | sigemptyset(&sa.sa_mask); | 420 | sigemptyset(&sa.sa_mask); |
@@ -440,10 +445,6 @@ int SrsSignalManager::cycle() | @@ -440,10 +445,6 @@ int SrsSignalManager::cycle() | ||
440 | { | 445 | { |
441 | int ret = ERROR_SUCCESS; | 446 | int ret = ERROR_SUCCESS; |
442 | 447 | ||
443 | - if (signal_read_stfd == NULL) { | ||
444 | - signal_read_stfd = st_netfd_open(sig_pipe[0]); | ||
445 | - } | ||
446 | - | ||
447 | int signo; | 448 | int signo; |
448 | 449 | ||
449 | /* Read the next signal from the pipe */ | 450 | /* Read the next signal from the pipe */ |
@@ -852,6 +853,7 @@ int SrsServer::cycle() | @@ -852,6 +853,7 @@ int SrsServer::cycle() | ||
852 | #else | 853 | #else |
853 | srs_warn("main cycle terminated, system quit normally."); | 854 | srs_warn("main cycle terminated, system quit normally."); |
854 | dispose(); | 855 | dispose(); |
856 | + srs_trace("srs terminated"); | ||
855 | exit(0); | 857 | exit(0); |
856 | #endif | 858 | #endif |
857 | 859 |
-
请 注册 或 登录 后发表评论