From 45ed458927a76265431653121ca243e8a7ae4001 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 16 Dec 2019 16:07:17 +0800 Subject: [PATCH] Eliminate dead code of ts cache for HTTP message --- trunk/src/protocol/srs_http_stack.cpp | 14 ++++++-------- trunk/src/protocol/srs_http_stack.hpp | 10 ---------- trunk/src/service/srs_service_http_conn.cpp | 2 -- trunk/src/service/srs_service_http_conn.hpp | 2 -- 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/trunk/src/protocol/srs_http_stack.cpp b/trunk/src/protocol/srs_http_stack.cpp index b21db2d0b..6e6fdf248 100644 --- a/trunk/src/protocol/srs_http_stack.cpp +++ b/trunk/src/protocol/srs_http_stack.cpp @@ -35,9 +35,13 @@ using namespace std; #include #include #include +#include #define SRS_HTTP_DEFAULT_PAGE "index.html" +// @see ISrsHttpMessage._http_ts_send_buffer +#define SRS_HTTP_TS_SEND_BUFFER_SIZE 4096 + // get the status text of code. string srs_generate_http_status_text(int status) { @@ -492,7 +496,8 @@ srs_error_t SrsHttpFileServer::copy(ISrsHttpResponseWriter* w, SrsFileReader* fs srs_error_t err = srs_success; int left = size; - char* buf = r->http_ts_send_buffer(); + char* buf = new char[SRS_HTTP_TS_SEND_BUFFER_SIZE]; + SrsAutoFreeA(char, buf); while (left > 0) { ssize_t nread = -1; @@ -822,17 +827,10 @@ srs_error_t SrsHttpCorsMux::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessag ISrsHttpMessage::ISrsHttpMessage() { - _http_ts_send_buffer = new char[SRS_HTTP_TS_SEND_BUFFER_SIZE]; } ISrsHttpMessage::~ISrsHttpMessage() { - srs_freepa(_http_ts_send_buffer); -} - -char* ISrsHttpMessage::http_ts_send_buffer() -{ - return _http_ts_send_buffer; } SrsHttpUri::SrsHttpUri() diff --git a/trunk/src/protocol/srs_http_stack.hpp b/trunk/src/protocol/srs_http_stack.hpp index a6691ce33..e38ae9db1 100644 --- a/trunk/src/protocol/srs_http_stack.hpp +++ b/trunk/src/protocol/srs_http_stack.hpp @@ -63,9 +63,6 @@ class SrsJsonObject; #define SRS_HTTP_CRLF "\r\n" // 0x0D0A #define SRS_HTTP_CRLFCRLF "\r\n\r\n" // 0x0D0A0D0A -// @see ISrsHttpMessage._http_ts_send_buffer -#define SRS_HTTP_TS_SEND_BUFFER_SIZE 4096 - // For ead all of http body, read each time. #define SRS_HTTP_READ_CACHE_BYTES 4096 @@ -455,16 +452,9 @@ public: // @rmark for mode 2, the infinite chunked, all left data is body. class ISrsHttpMessage { -private: - // Use a buffer to read and send ts file. - // TODO: FIXME: remove it. - char* _http_ts_send_buffer; public: ISrsHttpMessage(); virtual ~ISrsHttpMessage(); -public: - // The http request level cache. - virtual char* http_ts_send_buffer(); public: virtual uint8_t method() = 0; virtual uint16_t status_code() = 0; diff --git a/trunk/src/service/srs_service_http_conn.cpp b/trunk/src/service/srs_service_http_conn.cpp index 4048f2934..3cb58f54a 100644 --- a/trunk/src/service/srs_service_http_conn.cpp +++ b/trunk/src/service/srs_service_http_conn.cpp @@ -258,7 +258,6 @@ SrsHttpMessage::SrsHttpMessage(ISrsReader* reader, SrsFastStream* buffer) : ISrs infinite_chunked = false; _uri = new SrsHttpUri(); _body = new SrsHttpResponseReader(this, reader, buffer); - _http_ts_send_buffer = new char[SRS_HTTP_TS_SEND_BUFFER_SIZE]; jsonp = false; @@ -272,7 +271,6 @@ SrsHttpMessage::~SrsHttpMessage() { srs_freep(_body); srs_freep(_uri); - srs_freepa(_http_ts_send_buffer); } void SrsHttpMessage::set_basic(uint8_t method, uint16_t status, int64_t content_length) diff --git a/trunk/src/service/srs_service_http_conn.hpp b/trunk/src/service/srs_service_http_conn.hpp index f4716b885..6d956f1de 100644 --- a/trunk/src/service/srs_service_http_conn.hpp +++ b/trunk/src/service/srs_service_http_conn.hpp @@ -100,8 +100,6 @@ private: // Whether the body is infinite chunked. bool infinite_chunked; // Use a buffer to read and send ts file. - // TODO: FIXME: remove it. - char* _http_ts_send_buffer; // The transport connection, can be NULL. SrsConnection* owner_conn; private: