From 85cd4a7d0234869faa4fc66c2129b5d54f71f413 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 19 Nov 2019 10:55:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=81=8D=E5=8E=86=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8F=AF=E8=83=BD=E5=B4=A9=E6=BA=83=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index f1263e70..9a23da09 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -452,6 +452,7 @@ void installWebApi() { //筛选命中个数 int count_hit = 0; int count_closed = 0; + list media_list; MediaSource::for_each_media([&](const string &schema, const string &vhost, const string &app, @@ -470,10 +471,15 @@ void installWebApi() { return; } ++count_hit; - if(media->close(allArgs["force"].as())){ + media_list.emplace_back(media); + }); + + bool force = allArgs["force"].as(); + for(auto &media : media_list){ + if(media->close(force)){ ++count_closed; } - }); + } val["count_hit"] = count_hit; val["count_closed"] = count_closed; }); @@ -526,6 +532,7 @@ void installWebApi() { string &peer_ip = allArgs["peer_ip"]; uint64_t count_hit = 0; + list session_list; SessionMap::Instance().for_each_session([&](const string &id,const TcpSession::Ptr &session){ if(local_port != 0 && local_port != session->get_local_port()){ return; @@ -533,9 +540,13 @@ void installWebApi() { if(!peer_ip.empty() && peer_ip != session->get_peer_ip()){ return; } - session->safeShutdown(); + session_list.emplace_back(session); ++count_hit; }); + + for(auto &session : session_list){ + session->safeShutdown(); + } val["count_hit"] = (Json::UInt64)count_hit; });