mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix #1206, dispose ingester while server quiting. 3.0.111
This commit is contained in:
parent
a6f88805f3
commit
23ece94064
9 changed files with 77 additions and 12 deletions
|
@ -97,11 +97,17 @@ void SrsIngesterFFMPEG::fast_stop()
|
|||
ffmpeg->fast_stop();
|
||||
}
|
||||
|
||||
void SrsIngesterFFMPEG::fast_kill()
|
||||
{
|
||||
ffmpeg->fast_kill();
|
||||
}
|
||||
|
||||
SrsIngester::SrsIngester()
|
||||
{
|
||||
_srs_config->subscribe(this);
|
||||
|
||||
expired = false;
|
||||
disposed = false;
|
||||
|
||||
trd = new SrsDummyCoroutine();
|
||||
pprint = SrsPithyPrint::create_ingester();
|
||||
|
@ -117,11 +123,18 @@ SrsIngester::~SrsIngester()
|
|||
|
||||
void SrsIngester::dispose()
|
||||
{
|
||||
if (disposed) {
|
||||
return;
|
||||
}
|
||||
disposed = true;
|
||||
|
||||
// first, use fast stop to notice all FFMPEG to quit gracefully.
|
||||
fast_stop();
|
||||
|
||||
srs_usleep(100 * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
// then, use stop to wait FFMPEG quit one by one and send SIGKILL if needed.
|
||||
stop();
|
||||
// then, use fast kill to ensure FFMPEG quit.
|
||||
fast_kill();
|
||||
}
|
||||
|
||||
srs_error_t SrsIngester::start()
|
||||
|
@ -166,6 +179,19 @@ void SrsIngester::fast_stop()
|
|||
}
|
||||
}
|
||||
|
||||
void SrsIngester::fast_kill()
|
||||
{
|
||||
std::vector<SrsIngesterFFMPEG*>::iterator it;
|
||||
for (it = ingesters.begin(); it != ingesters.end(); ++it) {
|
||||
SrsIngesterFFMPEG* ingester = *it;
|
||||
ingester->fast_kill();
|
||||
}
|
||||
|
||||
if (!ingesters.empty()) {
|
||||
srs_trace("fast kill all ingesters ok.");
|
||||
}
|
||||
}
|
||||
|
||||
// when error, ingester sleep for a while and retry.
|
||||
// ingest never sleep a long time, for we must start the stream ASAP.
|
||||
#define SRS_AUTO_INGESTER_CIMS (3 * SRS_UTIME_SECONDS)
|
||||
|
@ -174,7 +200,7 @@ srs_error_t SrsIngester::cycle()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
while (true) {
|
||||
while (!disposed) {
|
||||
if ((err = do_cycle()) != srs_success) {
|
||||
srs_warn("Ingester: Ignore error, %s", srs_error_desc(err).c_str());
|
||||
srs_freep(err);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue