Skip to content

Commit

Permalink
For #1634, always check status in thread loop. 3.0.126
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Mar 12, 2020
1 parent 6c55fd3 commit c1e07d6
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 38 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ For previous versions, please read:

## V3 changes

* v3.0, 2020-03-12, For [#1634][bug #1634], always check status in thread loop. 3.0.126
* v3.0, 2020-03-11, For [#1634][bug #1634], refactor output with datetime for ingest/encoder/exec. 3.0.125
* v3.0, 2020-03-11, For [#1634][bug #1634], fix quit by accident SIGTERM while killing FFMPEG. 3.0.124
* <strong>v3.0, 2020-03-05, [3.0 beta2(3.0.123)][r3.0b2] released. 122170 lines.</strong>
Expand Down
25 changes: 14 additions & 11 deletions trunk/src/app/srs_app_edge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,17 @@ srs_error_t SrsEdgeIngester::cycle()
srs_error_t err = srs_success;

while (true) {
// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "edge ingester");
}

if ((err = do_cycle()) != srs_success) {
srs_warn("EdgeIngester: Ignore error, %s", srs_error_desc(err).c_str());
srs_freep(err);
}

if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "edge ingester");
}


srs_usleep(SRS_EDGE_INGESTER_CIMS);
}

Expand Down Expand Up @@ -314,7 +316,6 @@ srs_error_t SrsEdgeIngester::ingest(string& redirect)
redirect = "";

while (true) {
srs_error_t err = srs_success;
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "thread quit");
}
Expand Down Expand Up @@ -534,14 +535,16 @@ srs_error_t SrsEdgeForwarder::cycle()
srs_error_t err = srs_success;

while (true) {
if ((err = do_cycle()) != srs_success) {
return srs_error_wrap(err, "do cycle");
}

// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "thread pull");
}


if ((err = do_cycle()) != srs_success) {
return srs_error_wrap(err, "do cycle");
}

srs_usleep(SRS_EDGE_FORWARDER_CIMS);
}

Expand Down
12 changes: 7 additions & 5 deletions trunk/src/app/srs_app_forward.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,17 @@ srs_error_t SrsForwarder::cycle()
srs_error_t err = srs_success;

while (true) {
// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "forwarder");
}

if ((err = do_cycle()) != srs_success) {
srs_warn("Forwarder: Ignore error, %s", srs_error_desc(err).c_str());
srs_freep(err);
}

if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "forwarder");
}


srs_usleep(SRS_FORWARDER_CIMS);
}

Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_http_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,13 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
// TODO: free and erase the disabled entry after all related connections is closed.
// TODO: FXIME: Support timeout for player, quit infinite-loop.
while (entry->enabled) {
pprint->elapse();

// Whether client closed the FD.
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "recv thread");
}

pprint->elapse();

// get messages from consumer.
// each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
int count = 0;
Expand Down
12 changes: 7 additions & 5 deletions trunk/src/app/srs_app_ingest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,17 @@ srs_error_t SrsIngester::cycle()
srs_error_t err = srs_success;

while (!disposed) {
// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "ingester");
}

if ((err = do_cycle()) != srs_success) {
srs_warn("Ingester: Ignore error, %s", srs_error_desc(err).c_str());
srs_freep(err);
}

if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "ingester");
}


srs_usleep(SRS_AUTO_INGESTER_CIMS);
}

Expand Down
14 changes: 8 additions & 6 deletions trunk/src/app/srs_app_ng_exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,18 @@ srs_error_t SrsNgExec::cycle()
srs_error_t err = srs_success;

while (true) {
if ((err = do_cycle()) != srs_success) {
srs_warn("EXEC: Ignore error, %s", srs_error_desc(err).c_str());
srs_freep(err);
}

// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
if ((err = trd->pull()) != srs_success) {
err = srs_error_wrap(err, "ng exec cycle");
break;
}


if ((err = do_cycle()) != srs_success) {
srs_warn("EXEC: Ignore error, %s", srs_error_desc(err).c_str());
srs_freep(err);
}

srs_usleep(SRS_RTMP_EXEC_CIMS);
}

Expand Down
15 changes: 7 additions & 8 deletions trunk/src/app/srs_app_rtmp_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ srs_error_t SrsRtmpConn::service_cycle()
}

while (true) {
srs_error_t err = srs_success;
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "rtmp: thread quit");
}
Expand Down Expand Up @@ -704,14 +703,14 @@ srs_error_t SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, Sr
srsu2msi(send_min_interval), srsu2msi(mw_sleep), mw_enabled, realtime, tcp_nodelay);

while (true) {
// collect elapse for pithy print.
pprint->elapse();

// when source is set to expired, disconnect it.
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "rtmp: thread quit");
}


// collect elapse for pithy print.
pprint->elapse();

// to use isolate thread to recv, can improve about 33% performance.
// @see: https://github.com/ossrs/srs/issues/196
// @see: https://github.com/ossrs/srs/issues/217
Expand Down Expand Up @@ -872,12 +871,12 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread*
int64_t nb_msgs = 0;
uint64_t nb_frames = 0;
while (true) {
pprint->elapse();

if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "rtmp: thread quit");
}


pprint->elapse();

// cond wait for timeout.
if (nb_msgs == 0) {
// when not got msgs, wait for a larger timeout.
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION3_HPP
#define SRS_CORE_VERSION3_HPP

#define SRS_VERSION3_REVISION 125
#define SRS_VERSION3_REVISION 126

#endif

0 comments on commit c1e07d6

Please sign in to comment.