1
0
Fork 0
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:
winlin 2015-05-30 11:25:33 +08:00
parent d611bb6b45
commit 860d68e6e7
6 changed files with 76 additions and 7 deletions

View file

@ -52,6 +52,7 @@ using namespace std;
SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
{
started = false;
fast_stopped = false;
pid = -1;
ffmpeg = ffmpeg_bin;
@ -484,6 +485,11 @@ int SrsFFMPEG::cycle()
return ret;
}
// ffmpeg is prepare to stop, donot cycle.
if (fast_stopped) {
return ret;
}
int status = 0;
pid_t p = waitpid(pid, &status, WNOHANG);
@ -524,6 +530,27 @@ void SrsFFMPEG::stop()
started = false;
}
void SrsFFMPEG::fast_stop()
{
int ret = ERROR_SUCCESS;
if (!started) {
return;
}
if (pid <= 0) {
return;
}
if (kill(pid, SIGTERM) < 0) {
ret = ERROR_SYSTEM_KILL;
srs_warn("ignore fast stop ffmpeg failed, pid=%d. ret=%d", pid, ret);
return;
}
return;
}
#endif