mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #1657, refine http api disconnect log
This commit is contained in:
parent
74799a31e3
commit
4b082ea96c
6 changed files with 23 additions and 11 deletions
|
@ -269,11 +269,13 @@ srs_error_t SrsDynamicHttpConn::on_http_message(ISrsHttpMessage* r, SrsHttpRespo
|
||||||
return srs_success;
|
return srs_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsDynamicHttpConn::on_conn_done()
|
srs_error_t SrsDynamicHttpConn::on_conn_done(srs_error_t r0)
|
||||||
{
|
{
|
||||||
// Because we use manager to manage this object,
|
// Because we use manager to manage this object,
|
||||||
// not the http connection object, so we must remove it here.
|
// not the http connection object, so we must remove it here.
|
||||||
manager->remove(this);
|
manager->remove(this);
|
||||||
|
|
||||||
|
return r0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SrsDynamicHttpConn::desc()
|
std::string SrsDynamicHttpConn::desc()
|
||||||
|
|
|
@ -101,7 +101,7 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_start();
|
virtual srs_error_t on_start();
|
||||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||||
virtual void on_conn_done();
|
virtual srs_error_t on_conn_done(srs_error_t r0);
|
||||||
// Interface ISrsResource.
|
// Interface ISrsResource.
|
||||||
public:
|
public:
|
||||||
virtual std::string desc();
|
virtual std::string desc();
|
||||||
|
|
|
@ -1720,11 +1720,20 @@ srs_error_t SrsHttpApi::on_http_message(ISrsHttpMessage* r, SrsHttpResponseWrite
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsHttpApi::on_conn_done()
|
srs_error_t SrsHttpApi::on_conn_done(srs_error_t r0)
|
||||||
{
|
{
|
||||||
// Because we use manager to manage this object,
|
// Because we use manager to manage this object,
|
||||||
// not the http connection object, so we must remove it here.
|
// not the http connection object, so we must remove it here.
|
||||||
manager->remove(this);
|
manager->remove(this);
|
||||||
|
|
||||||
|
// For HTTP-API timeout, we think it's done successfully,
|
||||||
|
// because there may be no request or response for HTTP-API.
|
||||||
|
if (srs_error_code(r0) == ERROR_SOCKET_TIMEOUT) {
|
||||||
|
srs_freep(r0);
|
||||||
|
return srs_success;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string SrsHttpApi::desc()
|
std::string SrsHttpApi::desc()
|
||||||
|
|
|
@ -270,7 +270,7 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_start();
|
virtual srs_error_t on_start();
|
||||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||||
virtual void on_conn_done();
|
virtual srs_error_t on_conn_done(srs_error_t r0);
|
||||||
// Interface ISrsResource.
|
// Interface ISrsResource.
|
||||||
public:
|
public:
|
||||||
virtual std::string desc();
|
virtual std::string desc();
|
||||||
|
|
|
@ -127,7 +127,8 @@ srs_error_t SrsHttpConn::cycle()
|
||||||
srs_error_t err = do_cycle();
|
srs_error_t err = do_cycle();
|
||||||
|
|
||||||
// Notify handler to handle it.
|
// Notify handler to handle it.
|
||||||
handler_->on_conn_done();
|
// @remark The error may be transformed by handler.
|
||||||
|
err = handler_->on_conn_done(err);
|
||||||
|
|
||||||
// success.
|
// success.
|
||||||
if (err == srs_success) {
|
if (err == srs_success) {
|
||||||
|
@ -179,9 +180,6 @@ srs_error_t SrsHttpConn::do_cycle()
|
||||||
|
|
||||||
// process http messages.
|
// process http messages.
|
||||||
for (int req_id = 0; (err = trd->pull()) == srs_success; req_id++) {
|
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:%d, request=%d, to=%dms", ip.c_str(), port, req_id, srsu2ms(SRS_HTTP_RECV_TIMEOUT));
|
|
||||||
|
|
||||||
// get a http message
|
// get a http message
|
||||||
ISrsHttpMessage* req = NULL;
|
ISrsHttpMessage* req = NULL;
|
||||||
if ((err = parser->parse_message(skt, &req)) != srs_success) {
|
if ((err = parser->parse_message(skt, &req)) != srs_success) {
|
||||||
|
@ -388,11 +386,13 @@ srs_error_t SrsResponseOnlyHttpConn::on_http_message(ISrsHttpMessage* r, SrsHttp
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsResponseOnlyHttpConn::on_conn_done()
|
srs_error_t SrsResponseOnlyHttpConn::on_conn_done(srs_error_t r0)
|
||||||
{
|
{
|
||||||
// Because we use manager to manage this object,
|
// Because we use manager to manage this object,
|
||||||
// not the http connection object, so we must remove it here.
|
// not the http connection object, so we must remove it here.
|
||||||
manager->remove(this);
|
manager->remove(this);
|
||||||
|
|
||||||
|
return r0;
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_error_t SrsResponseOnlyHttpConn::set_tcp_nodelay(bool v)
|
srs_error_t SrsResponseOnlyHttpConn::set_tcp_nodelay(bool v)
|
||||||
|
|
|
@ -68,7 +68,8 @@ public:
|
||||||
// For the stream caster, for instance, http flv streaming, may discard the flv header or not.
|
// For the stream caster, for instance, http flv streaming, may discard the flv header or not.
|
||||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w) = 0;
|
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w) = 0;
|
||||||
// When connection is destroy, should use manager to dispose it.
|
// When connection is destroy, should use manager to dispose it.
|
||||||
virtual void on_conn_done() = 0;
|
// The r0 is the original error, we will use the returned new error.
|
||||||
|
virtual srs_error_t on_conn_done(srs_error_t r0) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The http connection which request the static or stream content.
|
// The http connection which request the static or stream content.
|
||||||
|
@ -170,7 +171,7 @@ public:
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_start();
|
virtual srs_error_t on_start();
|
||||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||||
virtual void on_conn_done();
|
virtual srs_error_t on_conn_done(srs_error_t r0);
|
||||||
// Extract APIs from SrsTcpConnection.
|
// Extract APIs from SrsTcpConnection.
|
||||||
public:
|
public:
|
||||||
// Set socket option TCP_NODELAY.
|
// Set socket option TCP_NODELAY.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue