Fix #1629, fix kickoff FLV client bug. 3.0.137

pull/1672/head
winlin 5 years ago
parent 850a4bbf20
commit 0dd6c31487

@ -146,6 +146,7 @@ For previous versions, please read:
## V3 changes ## V3 changes
* v3.0, 2020-03-21, For [#1629][bug #1629], fix kickoff FLV client bug. 3.0.137
* v3.0, 2020-03-21, For [#1619][bug #1619], configure without utest by default. 3.0.136 * v3.0, 2020-03-21, For [#1619][bug #1619], configure without utest by default. 3.0.136
* v3.0, 2020-03-21, For [#1651][bug #1651], fix return pnwrite of srs_write_large_iovs. 3.0.135 * v3.0, 2020-03-21, For [#1651][bug #1651], fix return pnwrite of srs_write_large_iovs. 3.0.135
* <strong>v3.0, 2020-03-18, [3.0 beta3(3.0.134)][r3.0b3] released. 122509 lines.</strong> * <strong>v3.0, 2020-03-18, [3.0 beta3(3.0.134)][r3.0b3] released. 122509 lines.</strong>
@ -1680,6 +1681,7 @@ Winlin
[bug #1635]: https://github.com/ossrs/srs/issues/1635 [bug #1635]: https://github.com/ossrs/srs/issues/1635
[bug #1651]: https://github.com/ossrs/srs/issues/1651 [bug #1651]: https://github.com/ossrs/srs/issues/1651
[bug #1619]: https://github.com/ossrs/srs/issues/1619 [bug #1619]: https://github.com/ossrs/srs/issues/1619
[bug #1629]: https://github.com/ossrs/srs/issues/1629
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy [bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy
[exo #828]: https://github.com/google/ExoPlayer/pull/828 [exo #828]: https://github.com/google/ExoPlayer/pull/828

@ -198,19 +198,32 @@ srs_error_t SrsResponseOnlyHttpConn::pop_message(ISrsHttpMessage** preq)
srs_error_t err = srs_success; srs_error_t err = srs_success;
SrsStSocket skt; SrsStSocket skt;
if ((err = skt.initialize(stfd)) != srs_success) { if ((err = skt.initialize(stfd)) != srs_success) {
return srs_error_wrap(err, "init socket"); return srs_error_wrap(err, "init socket");
} }
if ((err = parser->parse_message(&skt, preq)) != srs_success) { // Check user interrupt by interval.
return srs_error_wrap(err, "parse message"); skt.set_recv_timeout(3 * SRS_UTIME_SECONDS);
// drop all request body.
char body[4096];
while (true) {
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "timeout");
}
if ((err = skt.read(body, 4096, NULL)) != srs_success) {
// Because we use timeout to check trd state, so we should ignore any timeout.
if (srs_error_code(err) == ERROR_SOCKET_TIMEOUT) {
srs_freep(err);
continue;
}
return srs_error_wrap(err, "read response");
}
} }
// Attach owner connection to message.
SrsHttpMessage* hreq = (SrsHttpMessage*)(*preq);
hreq->set_connection(this);
return err; return err;
} }
@ -219,12 +232,12 @@ srs_error_t SrsResponseOnlyHttpConn::on_got_http_message(ISrsHttpMessage* msg)
srs_error_t err = srs_success; srs_error_t err = srs_success;
ISrsHttpResponseReader* br = msg->body_reader(); ISrsHttpResponseReader* br = msg->body_reader();
// when not specified the content length, ignore. // when not specified the content length, ignore.
if (msg->content_length() == -1) { if (msg->content_length() == -1) {
return err; return err;
} }
// drop all request body. // drop all request body.
char body[4096]; char body[4096];
while (!br->eof()) { while (!br->eof()) {
@ -236,6 +249,11 @@ srs_error_t SrsResponseOnlyHttpConn::on_got_http_message(ISrsHttpMessage* msg)
return err; return err;
} }
void SrsResponseOnlyHttpConn::expire()
{
SrsHttpConn::expire();
}
SrsHttpServer::SrsHttpServer(SrsServer* svr) SrsHttpServer::SrsHttpServer(SrsServer* svr)
{ {
server = svr; server = svr;

@ -101,6 +101,9 @@ public:
virtual srs_error_t pop_message(ISrsHttpMessage** preq); virtual srs_error_t pop_message(ISrsHttpMessage** preq);
public: public:
virtual srs_error_t on_got_http_message(ISrsHttpMessage* msg); virtual srs_error_t on_got_http_message(ISrsHttpMessage* msg);
public:
// Set connection to expired.
virtual void expire();
}; };
// The http server, use http stream or static server to serve requests. // The http server, use http stream or static server to serve requests.

@ -592,10 +592,15 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
SrsAutoFree(SrsPithyPrint, pprint); SrsAutoFree(SrsPithyPrint, pprint);
SrsMessageArray msgs(SRS_PERF_MW_MSGS); SrsMessageArray msgs(SRS_PERF_MW_MSGS);
// Use receive thread to accept the close event to avoid FD leak.
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
// update the statistic when source disconveried. // update the statistic when source disconveried.
SrsStatistic* stat = SrsStatistic::instance(); SrsStatistic* stat = SrsStatistic::instance();
if ((err = stat->on_client(_srs_context->get_id(), req, NULL, SrsRtmpConnPlay)) != srs_success) { if ((err = stat->on_client(_srs_context->get_id(), req, hc, SrsRtmpConnPlay)) != srs_success) {
return srs_error_wrap(err, "stat on client"); return srs_error_wrap(err, "stat on client");
} }
@ -613,11 +618,6 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
} }
SrsFlvStreamEncoder* ffe = dynamic_cast<SrsFlvStreamEncoder*>(enc); SrsFlvStreamEncoder* ffe = dynamic_cast<SrsFlvStreamEncoder*>(enc);
// Use receive thread to accept the close event to avoid FD leak.
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
// Set the socket options for transport. // Set the socket options for transport.
bool tcp_nodelay = _srs_config->get_tcp_nodelay(req->vhost); bool tcp_nodelay = _srs_config->get_tcp_nodelay(req->vhost);

@ -24,6 +24,6 @@
#ifndef SRS_CORE_VERSION3_HPP #ifndef SRS_CORE_VERSION3_HPP
#define SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP
#define SRS_VERSION3_REVISION 136 #define SRS_VERSION3_REVISION 137
#endif #endif

Loading…
Cancel
Save