Refactor HTTP recv request timeout to 15s.

pull/1568/head
winlin 5 years ago
parent 2df1dcb05a
commit 1e83da7812

@ -81,11 +81,9 @@ srs_error_t SrsHttpConn::do_cycle()
{
srs_error_t err = srs_success;
srs_trace("HTTP client ip=%s", ip.c_str());
// initialize parser
if ((err = parser->initialize(HTTP_REQUEST, false)) != srs_success) {
return srs_error_wrap(err, "init parser");
return srs_error_wrap(err, "init parser for %s", ip.c_str());
}
// set the recv timeout, for some clients never disconnect the connection.
@ -102,10 +100,12 @@ srs_error_t SrsHttpConn::do_cycle()
}
// process http messages.
while ((err = trd->pull()) == srs_success) {
ISrsHttpMessage* req = NULL;
for (int req_id = 0; (err = trd->pull()) == srs_success; req_id++) {
// Try to receive a message from http.
srs_trace("HTTP client ip=%s, request=%d, to=%dms", ip.c_str(), req_id, srsu2ms(SRS_HTTP_RECV_TIMEOUT));
// get a http message
ISrsHttpMessage* req = NULL;
if ((err = parser->parse_message(skt, &req)) != srs_success) {
break;
}

@ -597,7 +597,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
if ((err = hc->set_socket_buffer(mw_sleep)) != srs_success) {
return srs_error_wrap(err, "set mw_sleep %" PRId64, mw_sleep);
}
SrsHttpRecvThread* trd = new SrsHttpRecvThread(hc);
SrsAutoFree(SrsHttpRecvThread, trd);
@ -610,6 +610,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
enc->has_cache(), msgs.max);
// 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();
@ -659,7 +660,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
return srs_error_wrap(err, "send messages");
}
}
return err;
}

@ -213,7 +213,7 @@
#define SRS_CONSTS_HTTP_QUERY_SEP '?'
// The default recv timeout.
#define SRS_HTTP_RECV_TIMEOUT (60 * SRS_UTIME_SECONDS)
#define SRS_HTTP_RECV_TIMEOUT (15 * SRS_UTIME_SECONDS)
// 6.1.1 Status Code and Reason Phrase
#define SRS_CONSTS_HTTP_Continue 100

Loading…
Cancel
Save