From edad6ac93d4fdc6337b373764b4a0b006941a7a0 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 12 Apr 2020 08:25:57 +0800 Subject: [PATCH] Fix memory leak. Refine RTC SEND pithy print message --- trunk/src/app/srs_app_listener.cpp | 1 + trunk/src/app/srs_app_rtc_conn.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_listener.cpp b/trunk/src/app/srs_app_listener.cpp index 9f93b2cf8..b9d571d83 100755 --- a/trunk/src/app/srs_app_listener.cpp +++ b/trunk/src/app/srs_app_listener.cpp @@ -442,6 +442,7 @@ srs_error_t SrsUdpMuxListener::cycle() if ((err = handler->on_udp_packet(&skt)) != srs_success) { // remux udp never return srs_warn("udp packet handler error:%s", srs_error_desc(err).c_str()); + srs_error_reset(err); continue; } diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index c4fec589d..d391cfe8f 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -1660,6 +1660,8 @@ srs_error_t SrsRtcServer::cycle() srs_error_t err = srs_success; uint64_t nn_msgs = 0; + uint64_t nn_msgs_last = 0; + srs_utime_t time_last = srs_get_system_time(); SrsStatistic* stat = SrsStatistic::instance(); SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_send(); @@ -1699,7 +1701,17 @@ srs_error_t SrsRtcServer::cycle() pprint->elapse(); if (pprint->can_print()) { - srs_trace("-> RTC SEND %d by sendmmsg %d, total %" PRId64 " msgs", pos, max_sendmmsg, nn_msgs); + int pps_average = 0; int pps_last = 0; + if (true) { + if (srs_get_system_time() > srs_get_system_startup_time()) { + pps_average = (int)(nn_msgs * SRS_UTIME_SECONDS / (srs_get_system_time() - srs_get_system_startup_time())); + } + if (srs_get_system_time() > time_last) { + pps_last = (int)((nn_msgs - nn_msgs_last) * SRS_UTIME_SECONDS / (srs_get_system_time() - time_last)); + } + } + srs_trace("-> RTC SEND %d by sendmmsg %d, total %" PRId64 ", pps %d/%d", pos, max_sendmmsg, nn_msgs, pps_average, pps_last); + nn_msgs_last = nn_msgs; time_last = srs_get_system_time(); } }