mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for #374, use fast stop for ingesters to stop many FFMPEG.
This commit is contained in:
parent
d611bb6b45
commit
860d68e6e7
6 changed files with 76 additions and 7 deletions
|
@ -44,6 +44,9 @@ using namespace std;
|
|||
#include <srs_app_json.hpp>
|
||||
#include <srs_kernel_stream.hpp>
|
||||
|
||||
// the longest time to wait for a process to quit.
|
||||
#define SRS_PROCESS_QUIT_TIMEOUT_MS 1000
|
||||
|
||||
int srs_socket_connect(string server, int port, int64_t timeout, st_netfd_t* pstfd)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -223,7 +226,6 @@ void srs_parse_endpoint(string ip_port, string& ip, int& port)
|
|||
port = ::atoi(the_port.c_str());
|
||||
}
|
||||
|
||||
#define SRS_PROCESS_QUIT_TIMEOUT_MS 1000
|
||||
int srs_kill_forced(int& pid)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -232,13 +234,13 @@ int srs_kill_forced(int& pid)
|
|||
return ret;
|
||||
}
|
||||
|
||||
// first, try kill by SIGINT.
|
||||
if (kill(pid, SIGINT) < 0) {
|
||||
// first, try kill by SIGTERM.
|
||||
if (kill(pid, SIGTERM) < 0) {
|
||||
return ERROR_SYSTEM_KILL;
|
||||
}
|
||||
|
||||
// wait to quit.
|
||||
srs_trace("send SIGINT to pid=%d", pid);
|
||||
srs_trace("send SIGTERM to pid=%d", pid);
|
||||
for (int i = 0; i < SRS_PROCESS_QUIT_TIMEOUT_MS / 10; i++) {
|
||||
int status = 0;
|
||||
pid_t qpid = -1;
|
||||
|
@ -253,7 +255,7 @@ int srs_kill_forced(int& pid)
|
|||
}
|
||||
|
||||
// killed, set pid to -1.
|
||||
srs_trace("SIGINT stop process pid=%d ok.", pid);
|
||||
srs_trace("SIGTERM stop process pid=%d ok.", pid);
|
||||
pid = -1;
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue