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;