for bug #249, simplify the macro, 0 to disable chunk stream cache.
正在显示
2 个修改的文件
包含
8 行增加
和
1 行删除
| @@ -75,6 +75,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -75,6 +75,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 75 | * how many chunk stream to cache, [0, N]. | 75 | * how many chunk stream to cache, [0, N]. |
| 76 | * to imporove about 10% performance when chunk size small, and 5% for large chunk. | 76 | * to imporove about 10% performance when chunk size small, and 5% for large chunk. |
| 77 | * @see https://github.com/winlinvip/simple-rtmp-server/issues/249 | 77 | * @see https://github.com/winlinvip/simple-rtmp-server/issues/249 |
| 78 | +* @remark 0 to disable the chunk stream cache. | ||
| 78 | */ | 79 | */ |
| 79 | #define SRS_PERF_CHUNK_STREAM_CACHE 16 | 80 | #define SRS_PERF_CHUNK_STREAM_CACHE 16 |
| 80 | 81 |
| @@ -418,7 +418,10 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | @@ -418,7 +418,10 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | ||
| 418 | warned_c0c3_cache_dry = false; | 418 | warned_c0c3_cache_dry = false; |
| 419 | auto_response_when_recv = true; | 419 | auto_response_when_recv = true; |
| 420 | 420 | ||
| 421 | - cs_cache = new SrsChunkStream*[SRS_PERF_CHUNK_STREAM_CACHE]; | 421 | + cs_cache = NULL; |
| 422 | + if (SRS_PERF_CHUNK_STREAM_CACHE > 0) { | ||
| 423 | + cs_cache = new SrsChunkStream*[SRS_PERF_CHUNK_STREAM_CACHE]; | ||
| 424 | + } | ||
| 422 | for (int cid = 0; cid < SRS_PERF_CHUNK_STREAM_CACHE; cid++) { | 425 | for (int cid = 0; cid < SRS_PERF_CHUNK_STREAM_CACHE; cid++) { |
| 423 | SrsChunkStream* cs = new SrsChunkStream(cid); | 426 | SrsChunkStream* cs = new SrsChunkStream(cid); |
| 424 | // set the perfer cid of chunk, | 427 | // set the perfer cid of chunk, |
| @@ -1102,6 +1105,9 @@ int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg) | @@ -1102,6 +1105,9 @@ int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg) | ||
| 1102 | } | 1105 | } |
| 1103 | srs_verbose("read basic header success. fmt=%d, cid=%d", fmt, cid); | 1106 | srs_verbose("read basic header success. fmt=%d, cid=%d", fmt, cid); |
| 1104 | 1107 | ||
| 1108 | + // the cid must not negative. | ||
| 1109 | + srs_assert(cid >= 0); | ||
| 1110 | + | ||
| 1105 | // once we got the chunk message header, | 1111 | // once we got the chunk message header, |
| 1106 | // that is there is a real message in cache, | 1112 | // that is there is a real message in cache, |
| 1107 | // increase the timeout to got it. | 1113 | // increase the timeout to got it. |
-
请 注册 或 登录 后发表评论