From fe38804e6103fae76ce86ea28d31876fa30fa515 Mon Sep 17 00:00:00 2001 From: Loken Date: Wed, 9 Aug 2023 19:54:26 +0800 Subject: [PATCH] Incorrect use of two "int i" instances. (#3759) --- trunk/3rdparty/srs-bench/pcap/main.go | 8 +++++--- trunk/src/app/srs_app_threads.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/trunk/3rdparty/srs-bench/pcap/main.go b/trunk/3rdparty/srs-bench/pcap/main.go index 0e91b2245..9409578be 100644 --- a/trunk/3rdparty/srs-bench/pcap/main.go +++ b/trunk/3rdparty/srs-bench/pcap/main.go @@ -108,12 +108,14 @@ func doMain(ctx context.Context) error { } if doRE { - if previousTime != nil { - if diff := ci.Timestamp.Sub(*previousTime); diff > 0 { + if previousTime == nil { + previousTime = &ci.Timestamp + } else { + if diff := ci.Timestamp.Sub(*previousTime); diff > 100*time.Millisecond { time.Sleep(diff) + previousTime = &ci.Timestamp } } - previousTime = &ci.Timestamp } if doTrace { diff --git a/trunk/src/app/srs_app_threads.cpp b/trunk/src/app/srs_app_threads.cpp index d1d14bfce..eee081c12 100644 --- a/trunk/src/app/srs_app_threads.cpp +++ b/trunk/src/app/srs_app_threads.cpp @@ -693,8 +693,8 @@ srs_error_t SrsThreadPool::run() // Check the threads status fastly. int loops = (int)(interval_ / SRS_UTIME_SECONDS); for (int i = 0; i < loops; i++) { - for (int i = 0; i < (int)threads.size(); i++) { - SrsThreadEntry* entry = threads.at(i); + for (int j = 0; j < (int)threads.size(); j++) { + SrsThreadEntry* entry = threads.at(j); if (entry->err != srs_success) { // Quit with success. if (srs_error_code(entry->err) == ERROR_THREAD_FINISHED) {