正在显示
4 个修改的文件
包含
11 行增加
和
9 行删除
| @@ -539,6 +539,7 @@ public: | @@ -539,6 +539,7 @@ public: | ||
| 539 | * get the mr sleep time in ms for vhost. | 539 | * get the mr sleep time in ms for vhost. |
| 540 | * @param vhost, the vhost to get the mr sleep time. | 540 | * @param vhost, the vhost to get the mr sleep time. |
| 541 | */ | 541 | */ |
| 542 | + // TODO: FIXME: add utest for mr config. | ||
| 542 | virtual int get_mr_sleep_ms(std::string vhost); | 543 | virtual int get_mr_sleep_ms(std::string vhost); |
| 543 | private: | 544 | private: |
| 544 | /** | 545 | /** |
| @@ -33,6 +33,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -33,6 +33,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 33 | 33 | ||
| 34 | using namespace std; | 34 | using namespace std; |
| 35 | 35 | ||
| 36 | +// the max small bytes to group | ||
| 37 | +#define SRS_MR_SMALL_BYTES 4096 | ||
| 38 | + | ||
| 36 | ISrsMessageHandler::ISrsMessageHandler() | 39 | ISrsMessageHandler::ISrsMessageHandler() |
| 37 | { | 40 | { |
| 38 | } | 41 | } |
| @@ -390,8 +393,8 @@ void SrsPublishRecvThread::update_buffer(bool mr_enabled, int sleep_ms) | @@ -390,8 +393,8 @@ void SrsPublishRecvThread::update_buffer(bool mr_enabled, int sleep_ms) | ||
| 390 | // TODO: FIXME: refine it. | 393 | // TODO: FIXME: refine it. |
| 391 | 394 | ||
| 392 | #ifdef SRS_PERF_MERGED_READ | 395 | #ifdef SRS_PERF_MERGED_READ |
| 393 | - // previous enabled mr, update the buffer. | ||
| 394 | - if (mr && mr_sleep != sleep_ms) { | 396 | + // update the buffer. |
| 397 | + if (true) { | ||
| 395 | // the underlayer api will set to SRS_MR_SOCKET_BUFFER bytes. | 398 | // the underlayer api will set to SRS_MR_SOCKET_BUFFER bytes. |
| 396 | // 4KB=4096, 8KB=8192, 16KB=16384, 32KB=32768, 64KB=65536, | 399 | // 4KB=4096, 8KB=8192, 16KB=16384, 32KB=32768, 64KB=65536, |
| 397 | // 128KB=131072, 256KB=262144, 512KB=524288 | 400 | // 128KB=131072, 256KB=262144, 512KB=524288 |
| @@ -56,9 +56,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -56,9 +56,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 56 | * That is, the latency is 120ms(the sleep time). | 56 | * That is, the latency is 120ms(the sleep time). |
| 57 | */ | 57 | */ |
| 58 | // to enable merged read. | 58 | // to enable merged read. |
| 59 | -#undef SRS_PERF_MERGED_READ | ||
| 60 | -// the max sleep time in ms | ||
| 61 | -#define SRS_MR_MAX_SLEEP_MS 800 | 59 | +#define SRS_PERF_MERGED_READ |
| 62 | 60 | ||
| 63 | /** | 61 | /** |
| 64 | * the send cache time in ms. | 62 | * the send cache time in ms. |
| @@ -28,10 +28,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -28,10 +28,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 28 | #include <srs_kernel_utility.hpp> | 28 | #include <srs_kernel_utility.hpp> |
| 29 | #include <srs_core_performance.hpp> | 29 | #include <srs_core_performance.hpp> |
| 30 | 30 | ||
| 31 | -// the max small bytes to group | ||
| 32 | -#define SRS_MR_SMALL_BYTES 4096 | ||
| 33 | // the default recv buffer size | 31 | // the default recv buffer size |
| 34 | -#define SRS_DEFAULT_RECV_BUFFER_SIZE 8192 | 32 | +#define SRS_DEFAULT_RECV_BUFFER_SIZE 32768 |
| 35 | 33 | ||
| 36 | // the max header size, | 34 | // the max header size, |
| 37 | // @see SrsProtocol::read_message_header(). | 35 | // @see SrsProtocol::read_message_header(). |
| @@ -111,7 +109,9 @@ void SrsFastBuffer::set_buffer(int buffer_size) | @@ -111,7 +109,9 @@ void SrsFastBuffer::set_buffer(int buffer_size) | ||
| 111 | int cap = end - p; | 109 | int cap = end - p; |
| 112 | 110 | ||
| 113 | char* buf = new char[buffer_size]; | 111 | char* buf = new char[buffer_size]; |
| 114 | - memcpy(buf, buffer, nb_buffer); | 112 | + if (cap > 0) { |
| 113 | + memcpy(buf, buffer, nb_buffer); | ||
| 114 | + } | ||
| 115 | srs_freep(buffer); | 115 | srs_freep(buffer); |
| 116 | 116 | ||
| 117 | buffer = buf; | 117 | buffer = buf; |
-
请 注册 或 登录 后发表评论