From ea7e2c28491ae61cc1b7aaa207ce38a74fa36487 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Fri, 21 Jun 2024 15:59:15 +0800 Subject: [PATCH 1/5] Fix security scan problems. v6.0.131 (#4100) 1. fix redundant null check, there is no potential risks by the way, just redundant null check. 2. Potential use pointer after free, that's not true. So we can ignore this one, or find a way to make stupid security tool happy. --------- Co-authored-by: winlin --- trunk/doc/CHANGELOG.md | 1 + trunk/src/app/srs_app_http_stream.cpp | 8 +++----- trunk/src/app/srs_app_source.cpp | 8 ++++---- trunk/src/core/srs_core_version6.hpp | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 8e5f2d4e7b..044c8221b7 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2024-06-21, Merge [#4100](https://github.com/ossrs/srs/pull/4100): Fix security scan problems. v6.0.131 (#4100) * v6.0, 2024-06-21, Merge [#4097](https://github.com/ossrs/srs/pull/4097): SmartPtr: Support load test for source by srs-bench. v6.0.130 (#4097) * v6.0, 2024-06-15, Merge [#4089](https://github.com/ossrs/srs/pull/4089): SmartPtr: Support shared ptr for live source. v6.0.129 (#4089) * v6.0, 2024-06-14, Merge [#4085](https://github.com/ossrs/srs/pull/4085): SmartPtr: Support shared ptr for RTC source. v6.0.128 (#4085) diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 03e8064c7f..20fbec3d37 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -1204,11 +1204,9 @@ srs_error_t SrsHttpStreamServer::hijack(ISrsHttpMessage* request, ISrsHttpHandle } // use the handler if exists. - if (ph) { - if (streamHandlers.find(sid) != streamHandlers.end()) { - entry = streamHandlers[sid]; - *ph = entry->stream; - } + if (streamHandlers.find(sid) != streamHandlers.end()) { + entry = streamHandlers[sid]; + *ph = entry->stream; } // trigger edge to fetch from origin. diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 03fc657f62..603296bf6f 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -199,15 +199,15 @@ void SrsFastVector::push_back(SrsSharedPtrMessage* msg) // increase vector. if (count >= nb_msgs) { int size = srs_max(SRS_PERF_MW_MSGS * 8, nb_msgs * 2); - SrsSharedPtrMessage** buf = new SrsSharedPtrMessage*[size]; + SrsSharedPtrMessage** buf = msgs; + msgs = new SrsSharedPtrMessage*[size]; for (int i = 0; i < nb_msgs; i++) { - buf[i] = msgs[i]; + msgs[i] = buf[i]; } srs_info("fast vector incrase %d=>%d", nb_msgs, size); // use new array. - srs_freepa(msgs); - msgs = buf; + srs_freepa(buf); nb_msgs = size; } diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index 3ff7d6edd4..ac4d68f7fa 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 130 +#define VERSION_REVISION 131 #endif From 7ab012c60f40934baf32e5c0fb5428b2feac543c Mon Sep 17 00:00:00 2001 From: Winlin Date: Sat, 29 Jun 2024 11:16:32 +0800 Subject: [PATCH 2/5] SmartPtr: Support detect memory leak by valgrind. v6.0.132 (#4102) 1. Support detect memory leak by valgrind. 2. Free the http handler entry. 3. Free the stack of ST. --- Co-authored-by: Jacob Su --- trunk/3rdparty/st-srs/Makefile | 3 + trunk/3rdparty/st-srs/stk.c | 31 +++- trunk/doc/CHANGELOG.md | 1 + trunk/research/st/.gitignore | 1 + trunk/research/st/thread-join.cpp | 36 +++++ trunk/src/app/srs_app_conn.cpp | 2 +- trunk/src/app/srs_app_hourglass.cpp | 2 +- trunk/src/app/srs_app_http_stream.cpp | 7 +- trunk/src/app/srs_app_hybrid.cpp | 86 +++++----- trunk/src/app/srs_app_ingest.cpp | 9 +- trunk/src/app/srs_app_ingest.hpp | 2 +- trunk/src/app/srs_app_server.cpp | 8 +- trunk/src/app/srs_app_threads.cpp | 148 ++++++++++++++++++ trunk/src/app/srs_app_threads.hpp | 1 + trunk/src/core/srs_core_version6.hpp | 2 +- trunk/src/kernel/srs_kernel_error.hpp | 2 +- trunk/src/main/srs_main_server.cpp | 7 + .../src/protocol/srs_protocol_http_stack.cpp | 7 +- 18 files changed, 286 insertions(+), 69 deletions(-) create mode 100644 trunk/research/st/thread-join.cpp diff --git a/trunk/3rdparty/st-srs/Makefile b/trunk/3rdparty/st-srs/Makefile index cc3fedf6de..14d4658bca 100644 --- a/trunk/3rdparty/st-srs/Makefile +++ b/trunk/3rdparty/st-srs/Makefile @@ -191,6 +191,9 @@ endif # # make EXTRA_CFLAGS=-DDEBUG_STATS # +# or cache the stack and reuse it: +# make EXTRA_CFLAGS=-DMD_CACHE_STACK +# # or enable the coverage for utest: # make UTEST_FLAGS="-fprofile-arcs -ftest-coverage" # diff --git a/trunk/3rdparty/st-srs/stk.c b/trunk/3rdparty/st-srs/stk.c index a81bee019b..ed5a932fbb 100644 --- a/trunk/3rdparty/st-srs/stk.c +++ b/trunk/3rdparty/st-srs/stk.c @@ -57,13 +57,15 @@ __thread int _st_num_free_stacks = 0; __thread int _st_randomize_stacks = 0; static char *_st_new_stk_segment(int size); +static void _st_delete_stk_segment(char *vaddr, int size); _st_stack_t *_st_stack_new(int stack_size) { _st_clist_t *qp; _st_stack_t *ts; int extra; - + +#ifdef MD_CACHE_STACK for (qp = _st_free_stacks.next; qp != &_st_free_stacks; qp = qp->next) { ts = _ST_THREAD_STACK_PTR(qp); if (ts->stk_size >= stack_size) { @@ -75,11 +77,31 @@ _st_stack_t *_st_stack_new(int stack_size) return ts; } } +#endif + + extra = _st_randomize_stacks ? _ST_PAGE_SIZE : 0; +#ifndef MD_CACHE_STACK + for (qp = _st_free_stacks.next; qp != &_st_free_stacks;) { + ts = _ST_THREAD_STACK_PTR(qp); + // Before qp is freed, move to next one, because the qp will be freed when free the ts. + qp = qp->next; + + ST_REMOVE_LINK(&ts->links); + _st_num_free_stacks--; + +#if defined(DEBUG) && !defined(MD_NO_PROTECT) + mprotect(ts->vaddr, REDZONE, PROT_READ | PROT_WRITE); + mprotect(ts->stk_top + extra, REDZONE, PROT_READ | PROT_WRITE); +#endif + + _st_delete_stk_segment(ts->vaddr, ts->vaddr_size); + free(ts); + } +#endif /* Make a new thread stack object. */ if ((ts = (_st_stack_t *)calloc(1, sizeof(_st_stack_t))) == NULL) return NULL; - extra = _st_randomize_stacks ? _ST_PAGE_SIZE : 0; ts->vaddr_size = stack_size + 2*REDZONE + extra; ts->vaddr = _st_new_stk_segment(ts->vaddr_size); if (!ts->vaddr) { @@ -114,7 +136,7 @@ void _st_stack_free(_st_stack_t *ts) { if (!ts) return; - + /* Put the stack on the free list */ ST_APPEND_LINK(&ts->links, _st_free_stacks.prev); _st_num_free_stacks++; @@ -152,8 +174,6 @@ static char *_st_new_stk_segment(int size) } -/* Not used */ -#if 0 void _st_delete_stk_segment(char *vaddr, int size) { #ifdef MALLOC_STACK @@ -162,7 +182,6 @@ void _st_delete_stk_segment(char *vaddr, int size) (void) munmap(vaddr, size); #endif } -#endif int st_randomize_stacks(int on) { diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 044c8221b7..b6e8d232fa 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2024-06-29, Merge [#4102](https://github.com/ossrs/srs/pull/4102): SmartPtr: Support detect memory leak by valgrind. v6.0.132 (#4102) * v6.0, 2024-06-21, Merge [#4100](https://github.com/ossrs/srs/pull/4100): Fix security scan problems. v6.0.131 (#4100) * v6.0, 2024-06-21, Merge [#4097](https://github.com/ossrs/srs/pull/4097): SmartPtr: Support load test for source by srs-bench. v6.0.130 (#4097) * v6.0, 2024-06-15, Merge [#4089](https://github.com/ossrs/srs/pull/4089): SmartPtr: Support shared ptr for live source. v6.0.129 (#4089) diff --git a/trunk/research/st/.gitignore b/trunk/research/st/.gitignore index 95683a3be1..e91642a02a 100644 --- a/trunk/research/st/.gitignore +++ b/trunk/research/st/.gitignore @@ -2,3 +2,4 @@ udp-server udp-client cost cost.log +thread-join diff --git a/trunk/research/st/thread-join.cpp b/trunk/research/st/thread-join.cpp new file mode 100644 index 0000000000..f3c7a88d62 --- /dev/null +++ b/trunk/research/st/thread-join.cpp @@ -0,0 +1,36 @@ +/* +g++ thread-join.cpp ../../objs/st/libst.a -g -O0 -o thread-join && ./thread-join +*/ +#include +#include +#include "../../objs/st/st.h" + +void* pfn(void* arg) { + printf("pid=%d, coroutine is ok\n", ::getpid()); + return NULL; +} + +int main(int argc, char** argv) { + st_init(); + + printf("pid=%d, create coroutine #1\n", ::getpid()); + st_thread_t thread = st_thread_create(pfn, NULL, 1, 0); + st_thread_join(thread, NULL); + + st_usleep(100 * 1000); + + printf("pid=%d, create coroutine #2\n", ::getpid()); + thread = st_thread_create(pfn, NULL, 1, 0); + st_thread_join(thread, NULL); + + st_usleep(100 * 1000); + + printf("pid=%d, create coroutine #3\n", ::getpid()); + thread = st_thread_create(pfn, NULL, 1, 0); + st_thread_join(thread, NULL); + + printf("done\n"); + st_thread_exit(NULL); + return 0; +} + diff --git a/trunk/src/app/srs_app_conn.cpp b/trunk/src/app/srs_app_conn.cpp index 90d818ece0..17033411ce 100644 --- a/trunk/src/app/srs_app_conn.cpp +++ b/trunk/src/app/srs_app_conn.cpp @@ -54,8 +54,8 @@ SrsResourceManager::~SrsResourceManager() trd->stop(); srs_freep(trd); - srs_cond_destroy(cond); } + srs_cond_destroy(cond); clear(); diff --git a/trunk/src/app/srs_app_hourglass.cpp b/trunk/src/app/srs_app_hourglass.cpp index 56593602f6..f7fdd37634 100644 --- a/trunk/src/app/srs_app_hourglass.cpp +++ b/trunk/src/app/srs_app_hourglass.cpp @@ -166,7 +166,7 @@ void SrsFastTimer::unsubscribe(ISrsFastTimer* timer) { vector::iterator it = std::find(handlers_.begin(), handlers_.end(), timer); if (it != handlers_.end()) { - it = handlers_.erase(it); + handlers_.erase(it); } } diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 20fbec3d37..2cb9f91343 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -1073,9 +1073,6 @@ void SrsHttpStreamServer::http_unmount(SrsRequest* r) SrsBufferCache* cache = entry->cache; SrsAutoFree(SrsBufferCache, cache); - // Unmount the HTTP handler. - mux.unhandle(entry->mount, stream); - // Notify cache and stream to stop. if (stream->entry) stream->entry->enabled = false; cache->stop(); @@ -1089,6 +1086,10 @@ void SrsHttpStreamServer::http_unmount(SrsRequest* r) srs_usleep(100 * SRS_UTIME_MILLISECONDS); } + // Unmount the HTTP handler, which will free the entry. Note that we must free it after cache and + // stream stopped for it uses it. + mux.unhandle(entry->mount, stream); + srs_trace("http: unmount flv stream for sid=%s, i=%d", sid.c_str(), i); } diff --git a/trunk/src/app/srs_app_hybrid.cpp b/trunk/src/app/srs_app_hybrid.cpp index c623782953..53f721afd0 100644 --- a/trunk/src/app/srs_app_hybrid.cpp +++ b/trunk/src/app/srs_app_hybrid.cpp @@ -25,21 +25,21 @@ extern SrsPps* _srs_pps_conn; extern SrsPps* _srs_pps_dispose; #if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS) -extern unsigned long long _st_stat_recvfrom; -extern unsigned long long _st_stat_recvfrom_eagain; -extern unsigned long long _st_stat_sendto; -extern unsigned long long _st_stat_sendto_eagain; +extern __thread unsigned long long _st_stat_recvfrom; +extern __thread unsigned long long _st_stat_recvfrom_eagain; +extern __thread unsigned long long _st_stat_sendto; +extern __thread unsigned long long _st_stat_sendto_eagain; SrsPps* _srs_pps_recvfrom = NULL; SrsPps* _srs_pps_recvfrom_eagain = NULL; SrsPps* _srs_pps_sendto = NULL; SrsPps* _srs_pps_sendto_eagain = NULL; -extern unsigned long long _st_stat_read; -extern unsigned long long _st_stat_read_eagain; -extern unsigned long long _st_stat_readv; -extern unsigned long long _st_stat_readv_eagain; -extern unsigned long long _st_stat_writev; -extern unsigned long long _st_stat_writev_eagain; +extern __thread unsigned long long _st_stat_read; +extern __thread unsigned long long _st_stat_read_eagain; +extern __thread unsigned long long _st_stat_readv; +extern __thread unsigned long long _st_stat_readv_eagain; +extern __thread unsigned long long _st_stat_writev; +extern __thread unsigned long long _st_stat_writev_eagain; SrsPps* _srs_pps_read = NULL; SrsPps* _srs_pps_read_eagain = NULL; SrsPps* _srs_pps_readv = NULL; @@ -47,33 +47,33 @@ SrsPps* _srs_pps_readv_eagain = NULL; SrsPps* _srs_pps_writev = NULL; SrsPps* _srs_pps_writev_eagain = NULL; -extern unsigned long long _st_stat_recvmsg; -extern unsigned long long _st_stat_recvmsg_eagain; -extern unsigned long long _st_stat_sendmsg; -extern unsigned long long _st_stat_sendmsg_eagain; +extern __thread unsigned long long _st_stat_recvmsg; +extern __thread unsigned long long _st_stat_recvmsg_eagain; +extern __thread unsigned long long _st_stat_sendmsg; +extern __thread unsigned long long _st_stat_sendmsg_eagain; SrsPps* _srs_pps_recvmsg = NULL; SrsPps* _srs_pps_recvmsg_eagain = NULL; SrsPps* _srs_pps_sendmsg = NULL; SrsPps* _srs_pps_sendmsg_eagain = NULL; -extern unsigned long long _st_stat_epoll; -extern unsigned long long _st_stat_epoll_zero; -extern unsigned long long _st_stat_epoll_shake; -extern unsigned long long _st_stat_epoll_spin; +extern __thread unsigned long long _st_stat_epoll; +extern __thread unsigned long long _st_stat_epoll_zero; +extern __thread unsigned long long _st_stat_epoll_shake; +extern __thread unsigned long long _st_stat_epoll_spin; SrsPps* _srs_pps_epoll = NULL; SrsPps* _srs_pps_epoll_zero = NULL; SrsPps* _srs_pps_epoll_shake = NULL; SrsPps* _srs_pps_epoll_spin = NULL; -extern unsigned long long _st_stat_sched_15ms; -extern unsigned long long _st_stat_sched_20ms; -extern unsigned long long _st_stat_sched_25ms; -extern unsigned long long _st_stat_sched_30ms; -extern unsigned long long _st_stat_sched_35ms; -extern unsigned long long _st_stat_sched_40ms; -extern unsigned long long _st_stat_sched_80ms; -extern unsigned long long _st_stat_sched_160ms; -extern unsigned long long _st_stat_sched_s; +extern __thread unsigned long long _st_stat_sched_15ms; +extern __thread unsigned long long _st_stat_sched_20ms; +extern __thread unsigned long long _st_stat_sched_25ms; +extern __thread unsigned long long _st_stat_sched_30ms; +extern __thread unsigned long long _st_stat_sched_35ms; +extern __thread unsigned long long _st_stat_sched_40ms; +extern __thread unsigned long long _st_stat_sched_80ms; +extern __thread unsigned long long _st_stat_sched_160ms; +extern __thread unsigned long long _st_stat_sched_s; SrsPps* _srs_pps_sched_15ms = NULL; SrsPps* _srs_pps_sched_20ms = NULL; SrsPps* _srs_pps_sched_25ms = NULL; @@ -96,11 +96,12 @@ SrsPps* _srs_pps_clock_160ms = NULL; SrsPps* _srs_pps_timer_s = NULL; #if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS) -extern int _st_active_count; -extern unsigned long long _st_stat_thread_run; -extern unsigned long long _st_stat_thread_idle; -extern unsigned long long _st_stat_thread_yield; -extern unsigned long long _st_stat_thread_yield2; +extern __thread int _st_active_count; +extern __thread int _st_num_free_stacks; +extern __thread unsigned long long _st_stat_thread_run; +extern __thread unsigned long long _st_stat_thread_idle; +extern __thread unsigned long long _st_stat_thread_yield; +extern __thread unsigned long long _st_stat_thread_yield2; SrsPps* _srs_pps_thread_run = NULL; SrsPps* _srs_pps_thread_idle = NULL; SrsPps* _srs_pps_thread_yield = NULL; @@ -135,19 +136,20 @@ SrsHybridServer::SrsHybridServer() SrsHybridServer::~SrsHybridServer() { - srs_freep(clock_monitor_); - - srs_freep(timer20ms_); - srs_freep(timer100ms_); - srs_freep(timer1s_); - srs_freep(timer5s_); - + // We must free servers first, because it may depend on the timers of hybrid server. vector::iterator it; for (it = servers.begin(); it != servers.end(); ++it) { ISrsHybridServer* server = *it; srs_freep(server); } servers.clear(); + + srs_freep(clock_monitor_); + + srs_freep(timer20ms_); + srs_freep(timer100ms_); + srs_freep(timer1s_); + srs_freep(timer5s_); } void SrsHybridServer::register_server(ISrsHybridServer* svr) @@ -237,8 +239,6 @@ void SrsHybridServer::stop() ISrsHybridServer* server = *it; server->stop(); } - - srs_st_destroy(); } SrsServerAdapter* SrsHybridServer::srs() @@ -372,8 +372,8 @@ srs_error_t SrsHybridServer::on_timer(srs_utime_t interval) #if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS) _srs_pps_thread_run->update(_st_stat_thread_run); _srs_pps_thread_idle->update(_st_stat_thread_idle); _srs_pps_thread_yield->update(_st_stat_thread_yield); _srs_pps_thread_yield2->update(_st_stat_thread_yield2); - if (_st_active_count > 0 || _srs_pps_thread_run->r10s() || _srs_pps_thread_idle->r10s() || _srs_pps_thread_yield->r10s() || _srs_pps_thread_yield2->r10s()) { - snprintf(buf, sizeof(buf), ", co=%d,%d,%d, yield=%d,%d", _st_active_count, _srs_pps_thread_run->r10s(), _srs_pps_thread_idle->r10s(), _srs_pps_thread_yield->r10s(), _srs_pps_thread_yield2->r10s()); + if (_st_active_count > 0 || _st_num_free_stacks > 0 || _srs_pps_thread_run->r10s() || _srs_pps_thread_idle->r10s() || _srs_pps_thread_yield->r10s() || _srs_pps_thread_yield2->r10s()) { + snprintf(buf, sizeof(buf), ", co=%d,%d,%d, stk=%d, yield=%d,%d", _st_active_count, _srs_pps_thread_run->r10s(), _srs_pps_thread_idle->r10s(), _st_num_free_stacks, _srs_pps_thread_yield->r10s(), _srs_pps_thread_yield2->r10s()); thread_desc = buf; } #endif diff --git a/trunk/src/app/srs_app_ingest.cpp b/trunk/src/app/srs_app_ingest.cpp index 707aa730d1..399de60f02 100644 --- a/trunk/src/app/srs_app_ingest.cpp +++ b/trunk/src/app/srs_app_ingest.cpp @@ -94,7 +94,7 @@ SrsIngester::SrsIngester() disposed = false; trd = new SrsDummyCoroutine(); - pprint = SrsPithyPrint::create_ingester(); + pprint_ = SrsPithyPrint::create_ingester(); } SrsIngester::~SrsIngester() @@ -103,6 +103,7 @@ SrsIngester::~SrsIngester() srs_freep(trd); clear_engines(); + srs_freep(pprint_); } void SrsIngester::dispose() @@ -466,7 +467,7 @@ srs_error_t SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* void SrsIngester::show_ingest_log_message() { - pprint->elapse(); + pprint_->elapse(); if ((int)ingesters.size() <= 0) { return; @@ -477,9 +478,9 @@ void SrsIngester::show_ingest_log_message() SrsIngesterFFMPEG* ingester = ingesters.at(index); // reportable - if (pprint->can_print()) { + if (pprint_->can_print()) { srs_trace("-> " SRS_CONSTS_LOG_INGESTER " time=%dms, ingesters=%d, #%d(alive=%dms, %s)", - srsu2msi(pprint->age()), (int)ingesters.size(), index, srsu2msi(ingester->alive()), ingester->uri().c_str()); + srsu2msi(pprint_->age()), (int)ingesters.size(), index, srsu2msi(ingester->alive()), ingester->uri().c_str()); } } diff --git a/trunk/src/app/srs_app_ingest.hpp b/trunk/src/app/srs_app_ingest.hpp index db4a2ed45c..cd32c2659a 100644 --- a/trunk/src/app/srs_app_ingest.hpp +++ b/trunk/src/app/srs_app_ingest.hpp @@ -55,7 +55,7 @@ class SrsIngester : public ISrsCoroutineHandler, public ISrsReloadHandler std::vector ingesters; private: SrsCoroutine* trd; - SrsPithyPrint* pprint; + SrsPithyPrint* pprint_; // Whether the ingesters are expired, for example, the listen port changed, // all ingesters must be restart. bool expired; diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 472b7114b3..21b50323cd 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -370,8 +370,6 @@ SrsServer::~SrsServer() void SrsServer::destroy() { - srs_warn("start destroy server"); - srs_freep(trd_); srs_freep(timer_); @@ -869,11 +867,8 @@ void SrsServer::stop() srs_trace("srs gracefully quit"); } + // This is the last line log of SRS. srs_trace("srs terminated"); - - // for valgrind to detect. - srs_freep(_srs_config); - srs_freep(_srs_log); } srs_error_t SrsServer::cycle() @@ -1406,6 +1401,7 @@ srs_error_t SrsServerAdapter::run(SrsWaitGroup* wg) void SrsServerAdapter::stop() { + srs->stop(); } SrsServer* SrsServerAdapter::instance() diff --git a/trunk/src/app/srs_app_threads.cpp b/trunk/src/app/srs_app_threads.cpp index 3aa39d124d..4ce4da4109 100644 --- a/trunk/src/app/srs_app_threads.cpp +++ b/trunk/src/app/srs_app_threads.cpp @@ -455,6 +455,154 @@ srs_error_t srs_global_initialize() return err; } +void srs_global_dispose() +{ + // Note that hybrid depends on sources. + srs_freep(_srs_hybrid); + srs_freep(_srs_sources); + + srs_freep(_srs_clock); + + srs_freep(_srs_stages); + srs_freep(_srs_circuit_breaker); + +#ifdef SRS_SRT + srs_freep(_srs_srt_sources); +#endif + +#ifdef SRS_RTC + srs_freep(_srs_rtc_sources); + srs_freep(_srs_blackhole); + srs_freep(_srs_rtc_manager); + srs_freep(_srs_rtc_dtls_certificate); +#endif +#ifdef SRS_GB28181 + srs_freep(_srs_gb_manager); +#endif + + srs_freep(_srs_pps_ids); + srs_freep(_srs_pps_fids); + srs_freep(_srs_pps_fids_level0); + srs_freep(_srs_pps_dispose); + + srs_freep(_srs_pps_timer); + srs_freep(_srs_pps_conn); + srs_freep(_srs_pps_pub); + +#ifdef SRS_RTC + srs_freep(_srs_pps_snack); + srs_freep(_srs_pps_snack2); + srs_freep(_srs_pps_snack3); + srs_freep(_srs_pps_snack4); + srs_freep(_srs_pps_sanack); + srs_freep(_srs_pps_svnack); + + srs_freep(_srs_pps_rnack); + srs_freep(_srs_pps_rnack2); + srs_freep(_srs_pps_rhnack); + srs_freep(_srs_pps_rmnack); +#endif + +#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS) + srs_freep(_srs_pps_recvfrom); + srs_freep(_srs_pps_recvfrom_eagain); + srs_freep(_srs_pps_sendto); + srs_freep(_srs_pps_sendto_eagain); + + srs_freep(_srs_pps_read); + srs_freep(_srs_pps_read_eagain); + srs_freep(_srs_pps_readv); + srs_freep(_srs_pps_readv_eagain); + srs_freep(_srs_pps_writev); + srs_freep(_srs_pps_writev_eagain); + + srs_freep(_srs_pps_recvmsg); + srs_freep(_srs_pps_recvmsg_eagain); + srs_freep(_srs_pps_sendmsg); + srs_freep(_srs_pps_sendmsg_eagain); + + srs_freep(_srs_pps_epoll); + srs_freep(_srs_pps_epoll_zero); + srs_freep(_srs_pps_epoll_shake); + srs_freep(_srs_pps_epoll_spin); + + srs_freep(_srs_pps_sched_15ms); + srs_freep(_srs_pps_sched_20ms); + srs_freep(_srs_pps_sched_25ms); + srs_freep(_srs_pps_sched_30ms); + srs_freep(_srs_pps_sched_35ms); + srs_freep(_srs_pps_sched_40ms); + srs_freep(_srs_pps_sched_80ms); + srs_freep(_srs_pps_sched_160ms); + srs_freep(_srs_pps_sched_s); +#endif + + srs_freep(_srs_pps_clock_15ms); + srs_freep(_srs_pps_clock_20ms); + srs_freep(_srs_pps_clock_25ms); + srs_freep(_srs_pps_clock_30ms); + srs_freep(_srs_pps_clock_35ms); + srs_freep(_srs_pps_clock_40ms); + srs_freep(_srs_pps_clock_80ms); + srs_freep(_srs_pps_clock_160ms); + srs_freep(_srs_pps_timer_s); + +#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS) + srs_freep(_srs_pps_thread_run); + srs_freep(_srs_pps_thread_idle); + srs_freep(_srs_pps_thread_yield); + srs_freep(_srs_pps_thread_yield2); +#endif + + srs_freep(_srs_pps_rpkts); + srs_freep(_srs_pps_addrs); + srs_freep(_srs_pps_fast_addrs); + + srs_freep(_srs_pps_spkts); + srs_freep(_srs_pps_objs_msgs); + +#ifdef SRS_RTC + srs_freep(_srs_pps_sstuns); + srs_freep(_srs_pps_srtcps); + srs_freep(_srs_pps_srtps); + + srs_freep(_srs_pps_rstuns); + srs_freep(_srs_pps_rrtps); + srs_freep(_srs_pps_rrtcps); + + srs_freep(_srs_pps_aloss2); + + srs_freep(_srs_pps_pli); + srs_freep(_srs_pps_twcc); + srs_freep(_srs_pps_rr); + + srs_freep(_srs_pps_objs_rtps); + srs_freep(_srs_pps_objs_rraw); + srs_freep(_srs_pps_objs_rfua); + srs_freep(_srs_pps_objs_rbuf); + srs_freep(_srs_pps_objs_rothers); +#endif + + srs_freep(_srs_dvr_async); + +#ifdef SRS_APM + srs_freep(_srs_cls); + srs_freep(_srs_apm); +#endif + + srs_freep(_srs_reload_err); + + // Note that we never free the logging, because it's used after thread terminated. + //srs_freep(_srs_log); + //srs_freep(_srs_config); + //srs_freep(_srs_context); + //srs_freep(_srs_pps_cids_get); + //srs_freep(_srs_pps_cids_set); + + // Dispose ST finally, which may be used by other global objects. + srs_st_destroy(); +} + SrsThreadMutex::SrsThreadMutex() { // https://man7.org/linux/man-pages/man3/pthread_mutexattr_init.3.html diff --git a/trunk/src/app/srs_app_threads.hpp b/trunk/src/app/srs_app_threads.hpp index 3192f500c4..419dd2bf0f 100644 --- a/trunk/src/app/srs_app_threads.hpp +++ b/trunk/src/app/srs_app_threads.hpp @@ -53,6 +53,7 @@ extern SrsCircuitBreaker* _srs_circuit_breaker; // Initialize global shared variables cross all threads. extern srs_error_t srs_global_initialize(); +extern void srs_global_dispose(); // The thread mutex wrapper, without error. class SrsThreadMutex diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index ac4d68f7fa..29249711b6 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 131 +#define VERSION_REVISION 132 #endif diff --git a/trunk/src/kernel/srs_kernel_error.hpp b/trunk/src/kernel/srs_kernel_error.hpp index 2b1fa01c1d..af9acf12de 100644 --- a/trunk/src/kernel/srs_kernel_error.hpp +++ b/trunk/src/kernel/srs_kernel_error.hpp @@ -468,7 +468,7 @@ class SrsCplxError }; // Error helpers, should use these functions to new or wrap an error. -#define srs_success 0 // SrsCplxError::success() +#define srs_success NULL // SrsCplxError::success() #define srs_error_new(ret, fmt, ...) SrsCplxError::create(__FUNCTION__, __FILE__, __LINE__, ret, fmt, ##__VA_ARGS__) #define srs_error_wrap(err, fmt, ...) SrsCplxError::wrap(__FUNCTION__, __FILE__, __LINE__, err, fmt, ##__VA_ARGS__) #define srs_error_copy(err) SrsCplxError::copy(err) diff --git a/trunk/src/main/srs_main_server.cpp b/trunk/src/main/srs_main_server.cpp index c101d1a9df..c34214759d 100644 --- a/trunk/src/main/srs_main_server.cpp +++ b/trunk/src/main/srs_main_server.cpp @@ -88,6 +88,9 @@ extern void srs_free_global_system_ips(); extern void asan_report_callback(const char* str); #endif +extern SrsPps* _srs_pps_cids_get; +extern SrsPps* _srs_pps_cids_set; + /** * main entrance. */ @@ -522,6 +525,10 @@ srs_error_t run_hybrid_server(void* /*arg*/) // After all done, stop and cleanup. _srs_hybrid->stop(); + // Dispose all global objects, note that we should do this in the hybrid thread, because it may + // depend on the ST when disposing. + srs_global_dispose(); + return err; } diff --git a/trunk/src/protocol/srs_protocol_http_stack.cpp b/trunk/src/protocol/srs_protocol_http_stack.cpp index 375ab3d860..198b755b68 100644 --- a/trunk/src/protocol/srs_protocol_http_stack.cpp +++ b/trunk/src/protocol/srs_protocol_http_stack.cpp @@ -761,9 +761,12 @@ void SrsHttpServeMux::unhandle(std::string pattern, ISrsHttpHandler* handler) entries.erase(it); // We don't free the handler, because user should free it. - if (entry->handler != handler) { - srs_freep(entry); + if (entry->handler == handler) { + entry->handler = NULL; } + + // Should always free the entry. + srs_freep(entry); } } From 75ddd8f5b6c293b1b98bd027e0c3de9500a7d0c3 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Sat, 29 Jun 2024 11:18:26 +0800 Subject: [PATCH 3/5] Fix misspelling error in app config. v6.0.133 (#4077) 1. misspelling fix; 2. remove finished TODO; --------- Co-authored-by: Haibo Chen <495810242@qq.com> --- trunk/doc/CHANGELOG.md | 1 + trunk/src/app/srs_app_config.cpp | 214 +++++++++--------- trunk/src/app/srs_app_rtc_source.cpp | 2 +- trunk/src/app/srs_app_source.cpp | 2 +- trunk/src/core/srs_core_version6.hpp | 2 +- trunk/src/kernel/srs_kernel_flv.cpp | 22 +- trunk/src/kernel/srs_kernel_flv.hpp | 10 +- trunk/src/kernel/srs_kernel_utility.cpp | 10 +- trunk/src/kernel/srs_kernel_utility.hpp | 4 +- .../src/protocol/srs_protocol_rtmp_stack.cpp | 12 +- .../src/protocol/srs_protocol_rtmp_stack.hpp | 4 +- trunk/src/utest/srs_utest_kernel.cpp | 2 +- trunk/src/utest/srs_utest_protocol.cpp | 24 +- trunk/src/utest/srs_utest_protocol2.cpp | 2 +- 14 files changed, 156 insertions(+), 155 deletions(-) diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index b6e8d232fa..6f24371357 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2024-06-29, Merge [#4077](https://github.com/ossrs/srs/pull/4077): Fix misspelling error in app config. v6.0.133 (#4077) * v6.0, 2024-06-29, Merge [#4102](https://github.com/ossrs/srs/pull/4102): SmartPtr: Support detect memory leak by valgrind. v6.0.132 (#4102) * v6.0, 2024-06-21, Merge [#4100](https://github.com/ossrs/srs/pull/4100): Fix security scan problems. v6.0.131 (#4100) * v6.0, 2024-06-21, Merge [#4097](https://github.com/ossrs/srs/pull/4097): SmartPtr: Support load test for source by srs-bench. v6.0.130 (#4097) diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 36a9007ed5..07146a6790 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -45,9 +45,9 @@ using namespace srs_internal; // @global the version to identify the core. const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER; -// when user config an invalid value, macros to perfer true or false. -#define SRS_CONF_PERFER_FALSE(conf_arg) conf_arg == "on" -#define SRS_CONF_PERFER_TRUE(conf_arg) conf_arg != "off" +// when user config an invalid value, macros to prefer true or false. +#define SRS_CONF_PREFER_FALSE(conf_arg) conf_arg == "on" +#define SRS_CONF_PREFER_TRUE(conf_arg) conf_arg != "off" // default config file. #define SRS_CONF_DEFAULT_COFNIG_FILE SRS_DEFAULT_CONFIG @@ -60,8 +60,8 @@ const char* _srs_version = "XCORE-" RTMP_SIG_SRS_SERVER; // Overwrite the config by env. #define SRS_OVERWRITE_BY_ENV_STRING(key) if (!srs_getenv(key).empty()) return srs_getenv(key) -#define SRS_OVERWRITE_BY_ENV_BOOL(key) if (!srs_getenv(key).empty()) return SRS_CONF_PERFER_FALSE(srs_getenv(key)) -#define SRS_OVERWRITE_BY_ENV_BOOL2(key) if (!srs_getenv(key).empty()) return SRS_CONF_PERFER_TRUE(srs_getenv(key)) +#define SRS_OVERWRITE_BY_ENV_BOOL(key) if (!srs_getenv(key).empty()) return SRS_CONF_PREFER_FALSE(srs_getenv(key)) +#define SRS_OVERWRITE_BY_ENV_BOOL2(key) if (!srs_getenv(key).empty()) return SRS_CONF_PREFER_TRUE(srs_getenv(key)) #define SRS_OVERWRITE_BY_ENV_INT(key) if (!srs_getenv(key).empty()) return ::atoi(srs_getenv(key).c_str()) #define SRS_OVERWRITE_BY_ENV_FLOAT(key) if (!srs_getenv(key).empty()) return ::atof(srs_getenv(key).c_str()) #define SRS_OVERWRITE_BY_ENV_SECONDS(key) if (!srs_getenv(key).empty()) return srs_utime_t(::atoi(srs_getenv(key).c_str()) * SRS_UTIME_SECONDS) @@ -2908,7 +2908,7 @@ bool SrsConfig::get_daemon() return true; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_in_docker() @@ -2922,7 +2922,7 @@ bool SrsConfig::get_in_docker() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::is_full_config() @@ -2934,7 +2934,7 @@ bool SrsConfig::is_full_config() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } SrsConfDirective* SrsConfig::get_root() @@ -3098,7 +3098,7 @@ bool SrsConfig::get_utc_time() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_work_dir() @@ -3126,7 +3126,7 @@ bool SrsConfig::get_asprocess() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::whether_query_latest_version() @@ -3140,7 +3140,7 @@ bool SrsConfig::whether_query_latest_version() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } srs_utime_t SrsConfig::first_wait_for_qlv() @@ -3168,7 +3168,7 @@ bool SrsConfig::empty_ip_ok() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } srs_utime_t SrsConfig::get_grace_start_wait() @@ -3210,7 +3210,7 @@ bool SrsConfig::is_force_grace_quit() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::disable_daemon_for_docker() @@ -3224,7 +3224,7 @@ bool SrsConfig::disable_daemon_for_docker() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::inotify_auto_reload() @@ -3238,7 +3238,7 @@ bool SrsConfig::inotify_auto_reload() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::auto_reload_for_docker() @@ -3252,7 +3252,7 @@ bool SrsConfig::auto_reload_for_docker() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } // TODO: FIXME: Support reload. @@ -3318,7 +3318,7 @@ bool SrsConfig::get_circuit_breaker() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_high_threshold() @@ -3451,7 +3451,7 @@ bool SrsConfig::get_tencentcloud_cls_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_tencentcloud_cls_stat_heartbeat() @@ -3470,7 +3470,7 @@ bool SrsConfig::get_tencentcloud_cls_stat_heartbeat() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_tencentcloud_cls_stat_streams() @@ -3489,7 +3489,7 @@ bool SrsConfig::get_tencentcloud_cls_stat_streams() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_tencentcloud_cls_debug_logging() @@ -3508,7 +3508,7 @@ bool SrsConfig::get_tencentcloud_cls_debug_logging() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } int SrsConfig::get_tencentcloud_cls_heartbeat_ratio() @@ -3679,7 +3679,7 @@ bool SrsConfig::get_tencentcloud_apm_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_tencentcloud_apm_team() @@ -3774,7 +3774,7 @@ bool SrsConfig::get_tencentcloud_apm_debug_logging() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_exporter_enabled() @@ -3793,7 +3793,7 @@ bool SrsConfig::get_exporter_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_exporter_listen() @@ -3885,7 +3885,7 @@ bool SrsConfig::get_stream_caster_enabled(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_stream_caster_engine(SrsConfDirective* conf) @@ -3954,7 +3954,7 @@ bool SrsConfig::get_stream_caster_sip_enable(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_stream_caster_sip_listen(SrsConfDirective* conf) @@ -4072,7 +4072,7 @@ bool SrsConfig::get_rtc_server_enabled(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } int SrsConfig::get_rtc_server_listen() @@ -4144,7 +4144,7 @@ bool SrsConfig::get_api_as_candidates() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_resolve_api_domain() @@ -4163,7 +4163,7 @@ bool SrsConfig::get_resolve_api_domain() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_keep_api_domain() @@ -4182,7 +4182,7 @@ bool SrsConfig::get_keep_api_domain() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_use_auto_detect_network_ip() @@ -4201,7 +4201,7 @@ bool SrsConfig::get_use_auto_detect_network_ip() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_rtc_server_tcp_enabled() @@ -4225,7 +4225,7 @@ bool SrsConfig::get_rtc_server_tcp_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } int SrsConfig::get_rtc_server_tcp_listen() @@ -4306,7 +4306,7 @@ bool SrsConfig::get_rtc_server_ecdsa() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_rtc_server_encrypt() @@ -4325,7 +4325,7 @@ bool SrsConfig::get_rtc_server_encrypt() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_rtc_server_reuseport() @@ -4377,7 +4377,7 @@ bool SrsConfig::get_rtc_server_merge_nalus() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_rtc_server_black_hole() @@ -4401,7 +4401,7 @@ bool SrsConfig::get_rtc_server_black_hole() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } std::string SrsConfig::get_rtc_server_black_hole_addr() @@ -4451,7 +4451,7 @@ bool SrsConfig::get_rtc_enabled(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_rtc_keep_bframe(string vhost) @@ -4471,7 +4471,7 @@ bool SrsConfig::get_rtc_keep_bframe(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_rtc_keep_avc_nalu_sei(std::string vhost) @@ -4491,7 +4491,7 @@ bool SrsConfig::get_rtc_keep_avc_nalu_sei(std::string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_rtc_from_rtmp(string vhost) @@ -4511,7 +4511,7 @@ bool SrsConfig::get_rtc_from_rtmp(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_rtc_stun_timeout(string vhost) @@ -4551,7 +4551,7 @@ bool SrsConfig::get_rtc_stun_strict_check(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } std::string SrsConfig::get_rtc_dtls_role(string vhost) @@ -4629,7 +4629,7 @@ bool SrsConfig::get_rtc_to_rtmp(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_rtc_pli_for_rtmp(string vhost) @@ -4677,7 +4677,7 @@ bool SrsConfig::get_rtc_nack_enabled(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_rtc_nack_no_copy(string vhost) @@ -4696,7 +4696,7 @@ bool SrsConfig::get_rtc_nack_no_copy(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_rtc_twcc_enabled(string vhost) @@ -4715,7 +4715,7 @@ bool SrsConfig::get_rtc_twcc_enabled(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_rtc_opus_bitrate(string vhost) @@ -4840,13 +4840,13 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* conf) return false; } - // perfer true for exists one. + // prefer true for exists one. conf = conf->get("enabled"); if (!conf || conf->arg0().empty()) { return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_gop_cache(string vhost) @@ -4868,7 +4868,7 @@ bool SrsConfig::get_gop_cache(string vhost) return SRS_PERF_GOP_CACHE; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } @@ -4916,7 +4916,7 @@ bool SrsConfig::get_debug_srs_upnode(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_atc(string vhost) @@ -4940,7 +4940,7 @@ bool SrsConfig::get_atc(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_atc_auto(string vhost) @@ -4964,7 +4964,7 @@ bool SrsConfig::get_atc_auto(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } int SrsConfig::get_time_jitter(string vhost) @@ -5014,7 +5014,7 @@ bool SrsConfig::get_mix_correct(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_queue_length(string vhost) @@ -5060,7 +5060,7 @@ bool SrsConfig::get_refer_enabled(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } SrsConfDirective* SrsConfig::get_refer_all(string vhost) @@ -5199,7 +5199,7 @@ bool SrsConfig::get_parse_sps(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::try_annexb_first(string vhost) @@ -5224,7 +5224,7 @@ bool SrsConfig::try_annexb_first(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_mr_enabled(string vhost) @@ -5246,7 +5246,7 @@ bool SrsConfig::get_mr_enabled(string vhost) return SRS_PERF_MR_ENABLED; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_mr_sleep(string vhost) @@ -5382,9 +5382,9 @@ bool SrsConfig::get_realtime_enabled(string vhost, bool is_rtc) } if (is_rtc) { - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } else { - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } } @@ -5404,7 +5404,7 @@ bool SrsConfig::get_tcp_nodelay(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_send_min_interval(string vhost) @@ -5452,7 +5452,7 @@ bool SrsConfig::get_reduce_sequence_header(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_publish_1stpkt_timeout(string vhost) @@ -5573,7 +5573,7 @@ bool SrsConfig::get_forward_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } SrsConfDirective* SrsConfig::get_forwards(string vhost) @@ -5646,7 +5646,7 @@ bool SrsConfig::get_vhost_http_hooks_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost) @@ -5841,7 +5841,7 @@ bool SrsConfig::get_vhost_edge_follow_client(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_vhost_edge_token_traverse(string vhost) @@ -5863,7 +5863,7 @@ bool SrsConfig::get_vhost_edge_token_traverse(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_vhost_edge_transform_vhost(string vhost) @@ -5913,7 +5913,7 @@ bool SrsConfig::get_vhost_origin_cluster(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } vector SrsConfig::get_vhost_coworkers(string vhost) @@ -5967,7 +5967,7 @@ bool SrsConfig::get_security_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } SrsConfDirective* SrsConfig::get_security_rules(string vhost) @@ -6008,7 +6008,7 @@ bool SrsConfig::get_transcode_enabled(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* conf) @@ -6059,7 +6059,7 @@ bool SrsConfig::get_engine_enabled(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string srs_prefix_underscores_ifno(string name) @@ -6459,7 +6459,7 @@ bool SrsConfig::get_exec_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } vector SrsConfig::get_exec_publishs(string vhost) @@ -6524,7 +6524,7 @@ bool SrsConfig::get_ingest_enabled(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_ingest_ffmpeg(SrsConfDirective* conf) @@ -6723,7 +6723,7 @@ bool SrsConfig::get_dash_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_dash_fragment(string vhost) @@ -6856,7 +6856,7 @@ bool SrsConfig::get_dash_cleanup(std::string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } srs_utime_t SrsConfig::get_dash_dispose(std::string vhost) @@ -6915,7 +6915,7 @@ bool SrsConfig::get_hls_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_hls_entry_prefix(string vhost) @@ -7010,7 +7010,7 @@ bool SrsConfig::get_hls_ts_floor(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_hls_fragment(string vhost) @@ -7182,7 +7182,7 @@ bool SrsConfig::get_vhost_hls_dts_directly(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_hls_ctx_enabled(std::string vhost) @@ -7201,7 +7201,7 @@ bool SrsConfig::get_hls_ctx_enabled(std::string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_hls_ts_ctx_enabled(std::string vhost) @@ -7220,7 +7220,7 @@ bool SrsConfig::get_hls_ts_ctx_enabled(std::string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_hls_cleanup(string vhost) @@ -7239,7 +7239,7 @@ bool SrsConfig::get_hls_cleanup(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } srs_utime_t SrsConfig::get_hls_dispose(string vhost) @@ -7277,7 +7277,7 @@ bool SrsConfig::get_hls_wait_keyframe(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_hls_keys(string vhost) @@ -7296,7 +7296,7 @@ bool SrsConfig::get_hls_keys(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_hls_fragments_per_key(string vhost) @@ -7418,7 +7418,7 @@ bool SrsConfig::get_hds_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_hds_path(const string &vhost) @@ -7518,7 +7518,7 @@ bool SrsConfig::get_dvr_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } SrsConfDirective* SrsConfig::get_dvr_apply(string vhost) @@ -7609,7 +7609,7 @@ bool SrsConfig::get_dvr_wait_keyframe(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_dvr_time_jitter(string vhost) @@ -7655,7 +7655,7 @@ bool SrsConfig::get_http_api_enabled(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_http_api_listen() @@ -7694,7 +7694,7 @@ bool SrsConfig::get_http_api_crossdomain() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_raw_api() @@ -7718,7 +7718,7 @@ bool SrsConfig::get_raw_api() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_raw_api_allow_reload() @@ -7742,7 +7742,7 @@ bool SrsConfig::get_raw_api_allow_reload() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_raw_api_allow_query() @@ -7778,7 +7778,7 @@ bool SrsConfig::get_http_api_auth_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } std::string SrsConfig::get_http_api_auth_username() @@ -7855,7 +7855,7 @@ bool SrsConfig::get_https_api_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_https_api_listen() @@ -7936,7 +7936,7 @@ bool SrsConfig::get_srt_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } unsigned short SrsConfig::get_srt_listen_port() @@ -8004,7 +8004,7 @@ bool SrsConfig::get_srto_tsbpdmode() if (!conf || conf->arg0().empty()) { return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_srto_latency() @@ -8072,7 +8072,7 @@ bool SrsConfig::get_srt_sei_filter() if (!conf || conf->arg0().empty()) { return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_srto_tlpktdrop() @@ -8089,7 +8089,7 @@ bool SrsConfig::get_srto_tlpktdrop() if (!conf || conf->arg0().empty()) { return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } srs_utime_t SrsConfig::get_srto_conntimeout() @@ -8251,7 +8251,7 @@ bool SrsConfig::get_srt_enabled(std::string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_srt_to_rtmp(std::string vhost) @@ -8271,7 +8271,7 @@ bool SrsConfig::get_srt_to_rtmp(std::string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } bool SrsConfig::get_http_stream_enabled() @@ -8295,7 +8295,7 @@ bool SrsConfig::get_http_stream_enabled(SrsConfDirective* conf) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_http_stream_listen() @@ -8352,7 +8352,7 @@ bool SrsConfig::get_http_stream_crossdomain() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } SrsConfDirective* SrsConfig::get_https_stream() @@ -8381,7 +8381,7 @@ bool SrsConfig::get_https_stream_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_https_stream_listen() @@ -8462,7 +8462,7 @@ bool SrsConfig::get_vhost_http_enabled(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } string SrsConfig::get_vhost_http_mount(string vhost) @@ -8543,7 +8543,7 @@ bool SrsConfig::get_vhost_http_remux_enabled(SrsConfDirective* vhost) return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_vhost_http_remux_fast_cache(string vhost) @@ -8591,7 +8591,7 @@ bool SrsConfig::get_vhost_http_remux_drop_if_not_match(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_vhost_http_remux_has_audio(string vhost) @@ -8615,7 +8615,7 @@ bool SrsConfig::get_vhost_http_remux_has_audio(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_vhost_http_remux_has_video(string vhost) @@ -8639,7 +8639,7 @@ bool SrsConfig::get_vhost_http_remux_has_video(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } bool SrsConfig::get_vhost_http_remux_guess_has_av(string vhost) @@ -8663,7 +8663,7 @@ bool SrsConfig::get_vhost_http_remux_guess_has_av(string vhost) return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } string SrsConfig::get_vhost_http_remux_mount(string vhost) @@ -8711,7 +8711,7 @@ bool SrsConfig::get_heartbeat_enabled() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } srs_utime_t SrsConfig::get_heartbeat_interval() @@ -8787,7 +8787,7 @@ bool SrsConfig::get_heartbeat_summaries() return DEFAULT; } - return SRS_CONF_PERFER_FALSE(conf->arg0()); + return SRS_CONF_PREFER_FALSE(conf->arg0()); } SrsConfDirective* SrsConfig::get_stats() @@ -8809,7 +8809,7 @@ bool SrsConfig::get_stats_enabled() return DEFAULT; } - return SRS_CONF_PERFER_TRUE(conf->arg0()); + return SRS_CONF_PREFER_TRUE(conf->arg0()); } int SrsConfig::get_stats_network() diff --git a/trunk/src/app/srs_app_rtc_source.cpp b/trunk/src/app/srs_app_rtc_source.cpp index 21e53c1751..c3b8ddfe4e 100644 --- a/trunk/src/app/srs_app_rtc_source.cpp +++ b/trunk/src/app/srs_app_rtc_source.cpp @@ -1140,7 +1140,7 @@ srs_error_t SrsRtcRtpBuilder::filter(SrsSharedPtrMessage* msg, SrsFormat* format if (!keep_avc_nalu_sei && format->vcodec->id == SrsVideoCodecIdAVC) { SrsAvcNaluType avc_nalu_type; - // TODO: FIXME use static method to parse avc nalu type. + if ((err = SrsVideoFrame::parse_avc_nalu_type(sample, avc_nalu_type)) != srs_success) { return srs_error_wrap(err, "parse avc nalu_type"); } diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 603296bf6f..3a47ebdf33 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -2533,7 +2533,7 @@ srs_error_t SrsLiveSource::on_aggregate(SrsCommonMessage* msg) o.header.timestamp_delta = timestamp; o.header.timestamp = timestamp; o.header.stream_id = stream_id; - o.header.perfer_cid = msg->header.perfer_cid; + o.header.prefer_cid = msg->header.prefer_cid; if (data_size > 0) { o.size = data_size; diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index 29249711b6..775c9d3592 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 132 +#define VERSION_REVISION 133 #endif diff --git a/trunk/src/kernel/srs_kernel_flv.cpp b/trunk/src/kernel/srs_kernel_flv.cpp index 20111e8396..86ef2b3c38 100644 --- a/trunk/src/kernel/srs_kernel_flv.cpp +++ b/trunk/src/kernel/srs_kernel_flv.cpp @@ -37,7 +37,7 @@ SrsMessageHeader::SrsMessageHeader() timestamp = 0; // we always use the connection chunk-id - perfer_cid = RTMP_CID_OverConnection; + prefer_cid = RTMP_CID_OverConnection; } SrsMessageHeader::~SrsMessageHeader() @@ -113,7 +113,7 @@ void SrsMessageHeader::initialize_amf0_script(int size, int stream) stream_id = (int32_t)stream; // amf0 script use connection2 chunk-id - perfer_cid = RTMP_CID_OverConnection2; + prefer_cid = RTMP_CID_OverConnection2; } void SrsMessageHeader::initialize_audio(int size, uint32_t time, int stream) @@ -125,7 +125,7 @@ void SrsMessageHeader::initialize_audio(int size, uint32_t time, int stream) stream_id = (int32_t)stream; // audio chunk-id - perfer_cid = RTMP_CID_Audio; + prefer_cid = RTMP_CID_Audio; } void SrsMessageHeader::initialize_video(int size, uint32_t time, int stream) @@ -137,7 +137,7 @@ void SrsMessageHeader::initialize_video(int size, uint32_t time, int stream) stream_id = (int32_t)stream; // video chunk-id - perfer_cid = RTMP_CID_Video; + prefer_cid = RTMP_CID_Video; } SrsCommonMessage::SrsCommonMessage() @@ -175,7 +175,7 @@ SrsSharedMessageHeader::SrsSharedMessageHeader() { payload_length = 0; message_type = 0; - perfer_cid = 0; + prefer_cid = 0; } SrsSharedMessageHeader::~SrsSharedMessageHeader() @@ -244,7 +244,7 @@ srs_error_t SrsSharedPtrMessage::create(SrsMessageHeader* pheader, char* payload if (pheader) { ptr->header.message_type = pheader->message_type; ptr->header.payload_length = size; - ptr->header.perfer_cid = pheader->perfer_cid; + ptr->header.prefer_cid = pheader->prefer_cid; this->timestamp = pheader->timestamp; this->stream_id = pheader->stream_id; } @@ -284,9 +284,9 @@ bool SrsSharedPtrMessage::check(int stream_id) // we donot use the complex basic header, // ensure the basic header is 1bytes. - if (ptr->header.perfer_cid < 2 || ptr->header.perfer_cid > 63) { - srs_info("change the chunk_id=%d to default=%d", ptr->header.perfer_cid, RTMP_CID_ProtocolControl); - ptr->header.perfer_cid = RTMP_CID_ProtocolControl; + if (ptr->header.prefer_cid < 2 || ptr->header.prefer_cid > 63) { + srs_info("change the chunk_id=%d to default=%d", ptr->header.prefer_cid, RTMP_CID_ProtocolControl); + ptr->header.prefer_cid = RTMP_CID_ProtocolControl; } // we assume that the stream_id in a group must be the same. @@ -317,10 +317,10 @@ bool SrsSharedPtrMessage::is_video() int SrsSharedPtrMessage::chunk_header(char* cache, int nb_cache, bool c0) { if (c0) { - return srs_chunk_header_c0(ptr->header.perfer_cid, (uint32_t)timestamp, + return srs_chunk_header_c0(ptr->header.prefer_cid, (uint32_t)timestamp, ptr->header.payload_length, ptr->header.message_type, stream_id, cache, nb_cache); } else { - return srs_chunk_header_c3(ptr->header.perfer_cid, (uint32_t)timestamp, + return srs_chunk_header_c3(ptr->header.prefer_cid, (uint32_t)timestamp, cache, nb_cache); } } diff --git a/trunk/src/kernel/srs_kernel_flv.hpp b/trunk/src/kernel/srs_kernel_flv.hpp index 349c4c5795..72347d817e 100644 --- a/trunk/src/kernel/srs_kernel_flv.hpp +++ b/trunk/src/kernel/srs_kernel_flv.hpp @@ -153,10 +153,10 @@ class SrsMessageHeader // @remark, we use 64bits for large time for jitter detect and hls. int64_t timestamp; public: - // Get the perfered cid(chunk stream id) which sendout over. + // Get the prefered cid(chunk stream id) which sendout over. // set at decoding, and canbe used for directly send message, // For example, dispatch to all connections. - int perfer_cid; + int prefer_cid; public: SrsMessageHeader(); virtual ~SrsMessageHeader(); @@ -230,10 +230,10 @@ class SrsSharedMessageHeader // (1-7) are reserved for protocol control messages. // For example, RTMP_MSG_AudioMessage or RTMP_MSG_VideoMessage. int8_t message_type; - // Get the perfered cid(chunk stream id) which sendout over. + // Get the prefered cid(chunk stream id) which sendout over. // set at decoding, and canbe used for directly send message, // For example, dispatch to all connections. - int perfer_cid; + int prefer_cid; public: SrsSharedMessageHeader(); virtual ~SrsSharedMessageHeader(); @@ -313,7 +313,7 @@ class SrsSharedPtrMessage // if this or copy deleted, free payload when count is 0, or count--. // @remark, assert object is created. virtual int count(); - // check perfer cid and stream id. + // check prefer cid and stream id. // @return whether stream id already set. virtual bool check(int stream_id); public: diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 204b8f1459..356515bdd8 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -1180,7 +1180,7 @@ int srs_hex_to_data(uint8_t* data, const char* p, int size) return size / 2; } -int srs_chunk_header_c0(int perfer_cid, uint32_t timestamp, int32_t payload_length, int8_t message_type, int32_t stream_id, char* cache, int nb_cache) +int srs_chunk_header_c0(int prefer_cid, uint32_t timestamp, int32_t payload_length, int8_t message_type, int32_t stream_id, char* cache, int nb_cache) { // to directly set the field. char* pp = NULL; @@ -1194,7 +1194,7 @@ int srs_chunk_header_c0(int perfer_cid, uint32_t timestamp, int32_t payload_leng } // write new chunk stream header, fmt is 0 - *p++ = 0x00 | (perfer_cid & 0x3F); + *p++ = 0x00 | (prefer_cid & 0x3F); // chunk message header, 11 bytes // timestamp, 3bytes, big-endian @@ -1255,7 +1255,7 @@ int srs_chunk_header_c0(int perfer_cid, uint32_t timestamp, int32_t payload_leng return (int)(p - cache); } -int srs_chunk_header_c3(int perfer_cid, uint32_t timestamp, char* cache, int nb_cache) +int srs_chunk_header_c3(int prefer_cid, uint32_t timestamp, char* cache, int nb_cache) { // to directly set the field. char* pp = NULL; @@ -1269,9 +1269,9 @@ int srs_chunk_header_c3(int perfer_cid, uint32_t timestamp, char* cache, int nb_ } // write no message header chunk stream, fmt is 3 - // @remark, if perfer_cid > 0x3F, that is, use 2B/3B chunk header, + // @remark, if prefer_cid > 0x3F, that is, use 2B/3B chunk header, // SRS will rollback to 1B chunk header. - *p++ = 0xC0 | (perfer_cid & 0x3F); + *p++ = 0xC0 | (prefer_cid & 0x3F); // for c0 // chunk extended timestamp header, 0 or 4 bytes, big-endian diff --git a/trunk/src/kernel/srs_kernel_utility.hpp b/trunk/src/kernel/srs_kernel_utility.hpp index 603f4d2f69..400ca6122e 100644 --- a/trunk/src/kernel/srs_kernel_utility.hpp +++ b/trunk/src/kernel/srs_kernel_utility.hpp @@ -151,13 +151,13 @@ extern char* srs_data_to_hex_lowercase(char* des, const uint8_t* src, int len); // @param cache, the cache to write header. // @param nb_cache, the size of cache. // @return The size of header. 0 if cache not enough. -extern int srs_chunk_header_c0(int perfer_cid, uint32_t timestamp, int32_t payload_length, int8_t message_type, int32_t stream_id, char* cache, int nb_cache); +extern int srs_chunk_header_c0(int prefer_cid, uint32_t timestamp, int32_t payload_length, int8_t message_type, int32_t stream_id, char* cache, int nb_cache); // Generate the c3 chunk header for msg. // @param cache, the cache to write header. // @param nb_cache, the size of cache. // @return the size of header. 0 if cache not enough. -extern int srs_chunk_header_c3(int perfer_cid, uint32_t timestamp, char* cache, int nb_cache); +extern int srs_chunk_header_c3(int prefer_cid, uint32_t timestamp, char* cache, int nb_cache); // For utest to mock it. #include diff --git a/trunk/src/protocol/srs_protocol_rtmp_stack.cpp b/trunk/src/protocol/srs_protocol_rtmp_stack.cpp index 98ba57566a..4a250114a5 100644 --- a/trunk/src/protocol/srs_protocol_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_protocol_rtmp_stack.cpp @@ -110,7 +110,7 @@ srs_error_t SrsPacket::to_msg(SrsCommonMessage* msg, int stream_id) header.payload_length = size; header.message_type = get_message_type(); header.stream_id = stream_id; - header.perfer_cid = get_prefer_cid(); + header.prefer_cid = get_prefer_cid(); if ((err = msg->create(&header, payload, size)) != srs_success) { return srs_error_wrap(err, "create %dB message", size); @@ -200,9 +200,9 @@ SrsProtocol::SrsProtocol(ISrsProtocolReadWriter* io) } for (int cid = 0; cid < SRS_PERF_CHUNK_STREAM_CACHE; cid++) { SrsChunkStream* cs = new SrsChunkStream(cid); - // set the perfer cid of chunk, + // set the prefer cid of chunk, // which will copy to the message received. - cs->header.perfer_cid = cid; + cs->header.prefer_cid = cid; cs_cache[cid] = cs; } @@ -740,7 +740,7 @@ srs_error_t SrsProtocol::send_and_free_messages(SrsSharedPtrMessage** msgs, int continue; } - // check perfer cid and stream, + // check prefer cid and stream, // when one msg stream id is ok, ignore left. if (msg->check(stream_id)) { break; @@ -812,9 +812,9 @@ srs_error_t SrsProtocol::recv_interlaced_message(SrsCommonMessage** pmsg) // chunk stream cache miss, use map. if (chunk_streams.find(cid) == chunk_streams.end()) { chunk = chunk_streams[cid] = new SrsChunkStream(cid); - // set the perfer cid of chunk, + // set the prefer cid of chunk, // which will copy to the message received. - chunk->header.perfer_cid = cid; + chunk->header.prefer_cid = cid; } else { chunk = chunk_streams[cid]; } diff --git a/trunk/src/protocol/srs_protocol_rtmp_stack.hpp b/trunk/src/protocol/srs_protocol_rtmp_stack.hpp index 6364e3b63c..f76136ed3f 100644 --- a/trunk/src/protocol/srs_protocol_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_protocol_rtmp_stack.hpp @@ -114,8 +114,8 @@ class SrsPacket // Encode functions for concrete packet to override. public: // The cid(chunk id) specifies the chunk to send data over. - // Generally, each message perfer some cid, for example, - // all protocol control messages perfer RTMP_CID_ProtocolControl, + // Generally, each message prefer some cid, for example, + // all protocol control messages prefer RTMP_CID_ProtocolControl, // SrsSetWindowAckSizePacket is protocol control message. virtual int get_prefer_cid(); // The subpacket must override to provide the right message type. diff --git a/trunk/src/utest/srs_utest_kernel.cpp b/trunk/src/utest/srs_utest_kernel.cpp index 9be30ef11f..7525963bcb 100644 --- a/trunk/src/utest/srs_utest_kernel.cpp +++ b/trunk/src/utest/srs_utest_kernel.cpp @@ -4867,7 +4867,7 @@ VOID TEST(KernelFLVTest, CoverSharedPtrMessage) if (true) { SrsMessageHeader h; - h.perfer_cid = 1; + h.prefer_cid = 1; SrsSharedPtrMessage m; HELPER_EXPECT_SUCCESS(m.create(&h, NULL, 0)); diff --git a/trunk/src/utest/srs_utest_protocol.cpp b/trunk/src/utest/srs_utest_protocol.cpp index 8ac6a79d42..09590c697f 100644 --- a/trunk/src/utest/srs_utest_protocol.cpp +++ b/trunk/src/utest/srs_utest_protocol.cpp @@ -2097,7 +2097,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid1BNormal) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 1B cid(6bits), cid in 2-63 - EXPECT_EQ(0x09, msg->header.perfer_cid); + EXPECT_EQ(0x09, msg->header.prefer_cid); } /** @@ -2150,7 +2150,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid1BMax) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 1B cid(6bits), max is 63 - EXPECT_EQ(0x3F, msg->header.perfer_cid); + EXPECT_EQ(0x3F, msg->header.prefer_cid); } /** @@ -2203,7 +2203,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid2BMin) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 2B cid(8bits), min is 64 - EXPECT_EQ(64, msg->header.perfer_cid); + EXPECT_EQ(64, msg->header.prefer_cid); } /** @@ -2256,7 +2256,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid2BNormal) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 2B cid(8bits), cid in 64-319 - EXPECT_EQ(0x10+64, msg->header.perfer_cid); + EXPECT_EQ(0x10+64, msg->header.prefer_cid); } /** @@ -2309,7 +2309,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid2BNormal2) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 2B cid(8bits), cid in 64-319 - EXPECT_EQ(0x11+64, msg->header.perfer_cid); + EXPECT_EQ(0x11+64, msg->header.prefer_cid); } /** @@ -2362,7 +2362,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid2BMax) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 2B cid(68bits), max is 319 - EXPECT_EQ(319, msg->header.perfer_cid); + EXPECT_EQ(319, msg->header.prefer_cid); } /** @@ -2415,7 +2415,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid3BMin) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 3B cid(16bits), min is 64 - EXPECT_EQ(64, msg->header.perfer_cid); + EXPECT_EQ(64, msg->header.prefer_cid); } /** @@ -2468,7 +2468,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid3BNormal) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 3B cid(16bits), cid in 64-65599 - EXPECT_EQ(0x10*256+64, msg->header.perfer_cid); + EXPECT_EQ(0x10*256+64, msg->header.prefer_cid); } /** @@ -2521,7 +2521,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid3BNormal2) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 3B cid(16bits), cid in 64-65599 - EXPECT_EQ(0x01 + (0x10*256) + 64, msg->header.perfer_cid); + EXPECT_EQ(0x01 + (0x10*256) + 64, msg->header.prefer_cid); } /** @@ -2574,7 +2574,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid3BNormal3) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 3B cid(16bits), cid in 64-65599 - EXPECT_EQ(0xFF + (0x10*256) + 64, msg->header.perfer_cid); + EXPECT_EQ(0xFF + (0x10*256) + 64, msg->header.prefer_cid); } /** @@ -2627,7 +2627,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid3BNormal4) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 3B cid(16bits), cid in 64-65599 - EXPECT_EQ(0x02 + (0x10*256) + 64, msg->header.perfer_cid); + EXPECT_EQ(0x02 + (0x10*256) + 64, msg->header.prefer_cid); } /** @@ -2680,7 +2680,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid3BMax) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 2B cid(16bits), max is 65599 - EXPECT_EQ(65599, msg->header.perfer_cid); + EXPECT_EQ(65599, msg->header.prefer_cid); } /** diff --git a/trunk/src/utest/srs_utest_protocol2.cpp b/trunk/src/utest/srs_utest_protocol2.cpp index e3444727e5..b24529db9b 100644 --- a/trunk/src/utest/srs_utest_protocol2.cpp +++ b/trunk/src/utest/srs_utest_protocol2.cpp @@ -1228,7 +1228,7 @@ VOID TEST(ProtocolStackTest, ProtocolRecvVCid1BMin) SrsAutoFree(SrsCommonMessage, msg); EXPECT_TRUE(msg->header.is_video()); // 1B cid(6bits), min is 2 - EXPECT_EQ(0x02, msg->header.perfer_cid); + EXPECT_EQ(0x02, msg->header.prefer_cid); } VOID TEST(ProtocolKbpsTest, Connections) From 20c8e6423b8cc3d6798a0bcffc6303b0bcb1da73 Mon Sep 17 00:00:00 2001 From: Winlin Date: Thu, 4 Jul 2024 16:08:42 +0800 Subject: [PATCH 4/5] SmartPtr: Fix SRT source memory leaking. v6.0.134 (#4106) --------- Co-authored-by: john --- trunk/3rdparty/srs-bench/README.md | 2 ++ trunk/doc/CHANGELOG.md | 1 + trunk/src/app/srs_app_srt_source.cpp | 3 +++ trunk/src/core/srs_core_version6.hpp | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/trunk/3rdparty/srs-bench/README.md b/trunk/3rdparty/srs-bench/README.md index 8bda975415..21b8939b1a 100644 --- a/trunk/3rdparty/srs-bench/README.md +++ b/trunk/3rdparty/srs-bench/README.md @@ -33,6 +33,8 @@ cd srs/trunk && ./configure --h265=on --gb28181=on && make && ./objs/srs -c conf/console.conf ``` +> Note: Use valgrind to check memory leak, please use `valgrind --leak-check=full ./objs/srs -c conf/console.conf >/dev/null` to start SRS. + 具体场景,请按下面的操作启动测试。 ## Player for WHEP diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 6f24371357..7d49a8cf3a 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -7,6 +7,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v6.0, 2024-07-04, Merge [#4106](https://github.com/ossrs/srs/pull/4106): SmartPtr: Fix SRT source memory leaking. v6.0.134 (#4106) * v6.0, 2024-06-29, Merge [#4077](https://github.com/ossrs/srs/pull/4077): Fix misspelling error in app config. v6.0.133 (#4077) * v6.0, 2024-06-29, Merge [#4102](https://github.com/ossrs/srs/pull/4102): SmartPtr: Support detect memory leak by valgrind. v6.0.132 (#4102) * v6.0, 2024-06-21, Merge [#4100](https://github.com/ossrs/srs/pull/4100): Fix security scan problems. v6.0.131 (#4100) diff --git a/trunk/src/app/srs_app_srt_source.cpp b/trunk/src/app/srs_app_srt_source.cpp index 990cb2c133..b3383e6fa3 100644 --- a/trunk/src/app/srs_app_srt_source.cpp +++ b/trunk/src/app/srs_app_srt_source.cpp @@ -1083,6 +1083,9 @@ void SrsSrtSource::on_unpublish() can_publish_ = true; + SrsStatistic* stat = SrsStatistic::instance(); + stat->on_stream_close(req); + if (bridge_) { frame_builder_->on_unpublish(); srs_freep(frame_builder_); diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index 775c9d3592..db87015415 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 133 +#define VERSION_REVISION 134 #endif From 6bbd461ec960652c65deaaa9356d79fac691dd6d Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 4 Jul 2024 16:13:13 +0800 Subject: [PATCH 5/5] Release v6.0-d6, 6.0 dev6, v6.0.134, 168904 lines. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e493995a8f..970d8824f6 100755 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ distributed under their [licenses](https://ossrs.io/lts/en-us/license). ## Releases +* 2024-07-04, [Release v6.0-d6](https://github.com/ossrs/srs/releases/tag/v6.0-d6), v6.0-d6, 6.0 dev6, v6.0.134, 168904 lines. * 2024-06-15, [Release v6.0-d5](https://github.com/ossrs/srs/releases/tag/v6.0-d5), v6.0-d5, 6.0 dev5, v6.0.129, 168454 lines. * 2024-02-15, [Release v6.0-d4](https://github.com/ossrs/srs/releases/tag/v6.0-d4), v6.0-d4, 6.0 dev4, v6.0.113, 167695 lines. * 2023-11-19, [Release v6.0-d3](https://github.com/ossrs/srs/releases/tag/v6.0-d3), v6.0-d3, 6.0 dev3, v6.0.101, 167560 lines.