From 57f844b6364a9920901f198d52dfc9cc5b81d4bd Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 4 Dec 2014 15:49:24 +0800 Subject: [PATCH] for bug #249, simplify the macro, 0 to disable chunk stream cache. --- trunk/src/core/srs_core_performance.hpp | 1 + trunk/src/rtmp/srs_protocol_stack.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/trunk/src/core/srs_core_performance.hpp b/trunk/src/core/srs_core_performance.hpp index bc82fd1099..855693feab 100644 --- a/trunk/src/core/srs_core_performance.hpp +++ b/trunk/src/core/srs_core_performance.hpp @@ -75,6 +75,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * how many chunk stream to cache, [0, N]. * to imporove about 10% performance when chunk size small, and 5% for large chunk. * @see https://github.com/winlinvip/simple-rtmp-server/issues/249 +* @remark 0 to disable the chunk stream cache. */ #define SRS_PERF_CHUNK_STREAM_CACHE 16 diff --git a/trunk/src/rtmp/srs_protocol_stack.cpp b/trunk/src/rtmp/srs_protocol_stack.cpp index a154d8131b..98502f7b75 100644 --- a/trunk/src/rtmp/srs_protocol_stack.cpp +++ b/trunk/src/rtmp/srs_protocol_stack.cpp @@ -418,7 +418,10 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) warned_c0c3_cache_dry = false; auto_response_when_recv = true; - cs_cache = new SrsChunkStream*[SRS_PERF_CHUNK_STREAM_CACHE]; + cs_cache = NULL; + if (SRS_PERF_CHUNK_STREAM_CACHE > 0) { + cs_cache = new SrsChunkStream*[SRS_PERF_CHUNK_STREAM_CACHE]; + } for (int cid = 0; cid < SRS_PERF_CHUNK_STREAM_CACHE; cid++) { SrsChunkStream* cs = new SrsChunkStream(cid); // set the perfer cid of chunk, @@ -1102,6 +1105,9 @@ int SrsProtocol::recv_interlaced_message(SrsMessage** pmsg) } srs_verbose("read basic header success. fmt=%d, cid=%d", fmt, cid); + // the cid must not negative. + srs_assert(cid >= 0); + // once we got the chunk message header, // that is there is a real message in cache, // increase the timeout to got it.