正在显示
3 个修改的文件
包含
17 行增加
和
4 行删除
| @@ -515,6 +515,7 @@ SrsHttpMessage::SrsHttpMessage() | @@ -515,6 +515,7 @@ SrsHttpMessage::SrsHttpMessage() | ||
| 515 | _uri = new SrsHttpUri(); | 515 | _uri = new SrsHttpUri(); |
| 516 | _match = NULL; | 516 | _match = NULL; |
| 517 | _requires_crossdomain = false; | 517 | _requires_crossdomain = false; |
| 518 | + _http_ts_send_buffer = new char[HTTP_TS_SEND_BUFFER_SIZE]; | ||
| 518 | } | 519 | } |
| 519 | 520 | ||
| 520 | SrsHttpMessage::~SrsHttpMessage() | 521 | SrsHttpMessage::~SrsHttpMessage() |
| @@ -522,6 +523,12 @@ SrsHttpMessage::~SrsHttpMessage() | @@ -522,6 +523,12 @@ SrsHttpMessage::~SrsHttpMessage() | ||
| 522 | srs_freep(_body); | 523 | srs_freep(_body); |
| 523 | srs_freep(_uri); | 524 | srs_freep(_uri); |
| 524 | srs_freep(_match); | 525 | srs_freep(_match); |
| 526 | + srs_freepa(_http_ts_send_buffer); | ||
| 527 | +} | ||
| 528 | + | ||
| 529 | +char* SrsHttpMessage::http_ts_send_buffer() | ||
| 530 | +{ | ||
| 531 | + return _http_ts_send_buffer; | ||
| 525 | } | 532 | } |
| 526 | 533 | ||
| 527 | void SrsHttpMessage::reset() | 534 | void SrsHttpMessage::reset() |
| @@ -145,6 +145,9 @@ class SrsHttpHandler; | @@ -145,6 +145,9 @@ class SrsHttpHandler; | ||
| 145 | #define HTTP_GatewayTimeout_str "Gateway Timeout" | 145 | #define HTTP_GatewayTimeout_str "Gateway Timeout" |
| 146 | #define HTTP_HTTPVersionNotSupported_str "HTTP Version Not Supported" | 146 | #define HTTP_HTTPVersionNotSupported_str "HTTP Version Not Supported" |
| 147 | 147 | ||
| 148 | +// @see SrsHttpMessage._http_ts_send_buffer | ||
| 149 | +#define HTTP_TS_SEND_BUFFER_SIZE 4096 | ||
| 150 | + | ||
| 148 | // linux path seprator | 151 | // linux path seprator |
| 149 | #define __PATH_SEP '/' | 152 | #define __PATH_SEP '/' |
| 150 | // query string seprator | 153 | // query string seprator |
| @@ -310,10 +313,15 @@ private: | @@ -310,10 +313,15 @@ private: | ||
| 310 | * whether the message requires crossdomain. | 313 | * whether the message requires crossdomain. |
| 311 | */ | 314 | */ |
| 312 | bool _requires_crossdomain; | 315 | bool _requires_crossdomain; |
| 316 | + /** | ||
| 317 | + * use a buffer to read and send ts file. | ||
| 318 | + */ | ||
| 319 | + char* _http_ts_send_buffer; | ||
| 313 | public: | 320 | public: |
| 314 | SrsHttpMessage(); | 321 | SrsHttpMessage(); |
| 315 | virtual ~SrsHttpMessage(); | 322 | virtual ~SrsHttpMessage(); |
| 316 | public: | 323 | public: |
| 324 | + virtual char* http_ts_send_buffer(); | ||
| 317 | virtual void reset(); | 325 | virtual void reset(); |
| 318 | virtual int parse_uri(); | 326 | virtual int parse_uri(); |
| 319 | public: | 327 | public: |
| @@ -195,14 +195,12 @@ int SrsHttpVhost::do_process_request(SrsSocket* skt, SrsHttpMessage* req) | @@ -195,14 +195,12 @@ int SrsHttpVhost::do_process_request(SrsSocket* skt, SrsHttpMessage* req) | ||
| 195 | 195 | ||
| 196 | // write body. | 196 | // write body. |
| 197 | int64_t left = length; | 197 | int64_t left = length; |
| 198 | - const static int HTTP_PKT_SIZE = 4096; | ||
| 199 | - char* buf = new char[HTTP_PKT_SIZE]; | ||
| 200 | - SrsAutoFree(char, buf, true); | 198 | + char* buf = req->http_ts_send_buffer(); |
| 201 | 199 | ||
| 202 | while (left > 0) { | 200 | while (left > 0) { |
| 203 | ssize_t nread = -1; | 201 | ssize_t nread = -1; |
| 204 | // TODO: FIXME: use st_read. | 202 | // TODO: FIXME: use st_read. |
| 205 | - if ((nread = ::read(fd, buf, HTTP_PKT_SIZE)) < 0) { | 203 | + if ((nread = ::read(fd, buf, HTTP_TS_SEND_BUFFER_SIZE)) < 0) { |
| 206 | ::close(fd); | 204 | ::close(fd); |
| 207 | ret = ERROR_HTTP_READ_FILE; | 205 | ret = ERROR_HTTP_READ_FILE; |
| 208 | srs_warn("read file %s failed, ret=%d", fullpath.c_str(), ret); | 206 | srs_warn("read file %s failed, ret=%d", fullpath.c_str(), ret); |
-
请 注册 或 登录 后发表评论