Skip to content

Commit 0dd6c31

Browse files
committed
Fix ossrs#1629, fix kickoff FLV client bug. 3.0.137
1 parent 850a4bb commit 0dd6c31

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ For previous versions, please read:
146146

147147
## V3 changes
148148

149+
* v3.0, 2020-03-21, For [#1629][bug #1629], fix kickoff FLV client bug. 3.0.137
149150
* v3.0, 2020-03-21, For [#1619][bug #1619], configure without utest by default. 3.0.136
150151
* v3.0, 2020-03-21, For [#1651][bug #1651], fix return pnwrite of srs_write_large_iovs. 3.0.135
151152
* <strong>v3.0, 2020-03-18, [3.0 beta3(3.0.134)][r3.0b3] released. 122509 lines.</strong>
@@ -1680,6 +1681,7 @@ Winlin
16801681
[bug #1635]: https://github.com/ossrs/srs/issues/1635
16811682
[bug #1651]: https://github.com/ossrs/srs/issues/1651
16821683
[bug #1619]: https://github.com/ossrs/srs/issues/1619
1684+
[bug #1629]: https://github.com/ossrs/srs/issues/1629
16831685
[bug #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy
16841686

16851687
[exo #828]: https://github.com/google/ExoPlayer/pull/828

trunk/src/app/srs_app_http_conn.cpp

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,32 @@ srs_error_t SrsResponseOnlyHttpConn::pop_message(ISrsHttpMessage** preq)
198198
srs_error_t err = srs_success;
199199

200200
SrsStSocket skt;
201-
201+
202202
if ((err = skt.initialize(stfd)) != srs_success) {
203203
return srs_error_wrap(err, "init socket");
204204
}
205-
206-
if ((err = parser->parse_message(&skt, preq)) != srs_success) {
207-
return srs_error_wrap(err, "parse message");
205+
206+
// Check user interrupt by interval.
207+
skt.set_recv_timeout(3 * SRS_UTIME_SECONDS);
208+
209+
// drop all request body.
210+
char body[4096];
211+
while (true) {
212+
if ((err = trd->pull()) != srs_success) {
213+
return srs_error_wrap(err, "timeout");
214+
}
215+
216+
if ((err = skt.read(body, 4096, NULL)) != srs_success) {
217+
// Because we use timeout to check trd state, so we should ignore any timeout.
218+
if (srs_error_code(err) == ERROR_SOCKET_TIMEOUT) {
219+
srs_freep(err);
220+
continue;
221+
}
222+
223+
return srs_error_wrap(err, "read response");
224+
}
208225
}
209226

210-
// Attach owner connection to message.
211-
SrsHttpMessage* hreq = (SrsHttpMessage*)(*preq);
212-
hreq->set_connection(this);
213-
214227
return err;
215228
}
216229

@@ -219,12 +232,12 @@ srs_error_t SrsResponseOnlyHttpConn::on_got_http_message(ISrsHttpMessage* msg)
219232
srs_error_t err = srs_success;
220233

221234
ISrsHttpResponseReader* br = msg->body_reader();
222-
235+
223236
// when not specified the content length, ignore.
224237
if (msg->content_length() == -1) {
225238
return err;
226239
}
227-
240+
228241
// drop all request body.
229242
char body[4096];
230243
while (!br->eof()) {
@@ -236,6 +249,11 @@ srs_error_t SrsResponseOnlyHttpConn::on_got_http_message(ISrsHttpMessage* msg)
236249
return err;
237250
}
238251

252+
void SrsResponseOnlyHttpConn::expire()
253+
{
254+
SrsHttpConn::expire();
255+
}
256+
239257
SrsHttpServer::SrsHttpServer(SrsServer* svr)
240258
{
241259
server = svr;

trunk/src/app/srs_app_http_conn.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class SrsResponseOnlyHttpConn : public SrsHttpConn
101101
virtual srs_error_t pop_message(ISrsHttpMessage** preq);
102102
public:
103103
virtual srs_error_t on_got_http_message(ISrsHttpMessage* msg);
104+
public:
105+
// Set connection to expired.
106+
virtual void expire();
104107
};
105108

106109
// The http server, use http stream or static server to serve requests.

trunk/src/app/srs_app_http_stream.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,10 +592,15 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
592592
SrsAutoFree(SrsPithyPrint, pprint);
593593

594594
SrsMessageArray msgs(SRS_PERF_MW_MSGS);
595+
596+
// Use receive thread to accept the close event to avoid FD leak.
597+
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
598+
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
599+
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
595600

596601
// update the statistic when source disconveried.
597602
SrsStatistic* stat = SrsStatistic::instance();
598-
if ((err = stat->on_client(_srs_context->get_id(), req, NULL, SrsRtmpConnPlay)) != srs_success) {
603+
if ((err = stat->on_client(_srs_context->get_id(), req, hc, SrsRtmpConnPlay)) != srs_success) {
599604
return srs_error_wrap(err, "stat on client");
600605
}
601606

@@ -613,11 +618,6 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
613618
}
614619

615620
SrsFlvStreamEncoder* ffe = dynamic_cast<SrsFlvStreamEncoder*>(enc);
616-
617-
// Use receive thread to accept the close event to avoid FD leak.
618-
// @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427
619-
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
620-
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
621621

622622
// Set the socket options for transport.
623623
bool tcp_nodelay = _srs_config->get_tcp_nodelay(req->vhost);

trunk/src/core/srs_core_version3.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
#ifndef SRS_CORE_VERSION3_HPP
2525
#define SRS_CORE_VERSION3_HPP
2626

27-
#define SRS_VERSION3_REVISION 136
27+
#define SRS_VERSION3_REVISION 137
2828

2929
#endif

0 commit comments

Comments
 (0)