From c176a2b182c1c0a466e99302263059ec64df1939 Mon Sep 17 00:00:00 2001 From: taynpg Date: Thu, 19 Dec 2024 07:59:59 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=B7=BB=E5=8A=A0=E5=9C=A8?= =?UTF-8?q?=E4=B8=8A=E8=BD=BD=E6=97=B6=E4=B8=8D=E8=83=BD=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=92=8C=E9=87=8D=E6=96=B0=E4=B8=8A=E8=BD=BD?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=99=90=E5=88=B6=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E5=9C=A8Down=E6=97=B6=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E7=BB=A7=E7=BB=ADDown=E7=9A=84=E9=99=90=E5=88=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/client.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/client/client.cpp b/client/client.cpp index 78211d7..d1c86e6 100644 --- a/client/client.cpp +++ b/client/client.cpp @@ -130,6 +130,17 @@ bool CClient::down_task(const std::string& param) bool CClient::up_task(const std::string& cmd) { + + { + std::lock_guard lock(mutex_); + for (const auto& item : up_) { + if (item.second->trans_state_ == TRANS_REDAY || item.second->trans_state_ == TRANS_ING) { + logger_->warn("Have Task Upping, Please wait!"); + return false; + } + } + } + auto list = CFileOpr::get_file_list(cmd); std::string msg; for (const auto& item : list) { @@ -164,6 +175,15 @@ bool CClient::up_task(const std::string& cmd) bool CClient::cancel_task() { + { + std::lock_guard lock(mutex_); + for (const auto& item : up_) { + if (item.second->trans_state_ == TRANS_REDAY || item.second->trans_state_ == TRANS_ING) { + logger_->warn("Have Task Upping, Please wait!"); + return false; + } + } + } std::shared_ptr buf = std::make_shared(); buf->type_ = TYPE_CANCEL_LIST; return send_frame(buf.get()); @@ -403,7 +423,7 @@ void CClient::send_file_data_th(const char* keys) logger_->error("Stop Trans {} To {} failed.", t->cur_file_, str_key); return; } - //std::this_thread::sleep_for(std::chrono::milliseconds(10)); + // std::this_thread::sleep_for(std::chrono::milliseconds(10)); } buf->type_ = TYPE_TRANS_DONE;