diff --git a/src_main/io/pibasetransfer.cpp b/src_main/io/pibasetransfer.cpp index 97992f41..9cd1cc84 100644 --- a/src_main/io/pibasetransfer.cpp +++ b/src_main/io/pibasetransfer.cpp @@ -541,8 +541,8 @@ bool PIBaseTransfer::finish_send(bool ok) { if (!ok) sendBreak(header.session_id); else sendReply(pt_ReplySuccess); mutex_header.unlock(); - sendFinished(ok); piCoutObj << state_string << PIString::readableSize(bytes_all); + sendFinished(ok); // diag.stop(); bytes_all = bytes_cur = 0; return ok; @@ -558,8 +558,8 @@ void PIBaseTransfer::finish_receive(bool ok, bool quet) { sendBreak(header.session_id); mutex_header.unlock(); } - receiveFinished(ok); piCoutObj << state_string << PIString::readableSize(bytes_all); + receiveFinished(ok); // diag.stop(); bytes_all = bytes_cur = 0; } diff --git a/src_main/io/pifiletransfer.cpp b/src_main/io/pifiletransfer.cpp index cfc1af66..8928ffa4 100644 --- a/src_main/io/pifiletransfer.cpp +++ b/src_main/io/pifiletransfer.cpp @@ -79,6 +79,7 @@ bool PIFileTransfer::sendFiles(const PIVector &files) { // piCout << "prepare" << i << files_[i].path << files_[i].dest_path << files_[i].name(); } randomize(); + step_mutex.lock(); pftheader.session_id = randomi(); sendFilesStarted(); cur_file_string = "build session"; @@ -87,17 +88,20 @@ bool PIFileTransfer::sendFiles(const PIVector &files) { pftheader.step = pft_Description; buildSession(PIVector() << Part(0, desc.size())); cur_file_string = ""; + step_mutex.unlock(); if (!send_process()) { sendFilesFinished(false); started_ = false; return false; } + step_mutex.lock(); pftheader.step = pft_Data; PIVector pts; for (int i=0; i> h; // piCout << h.session_id; + PIMutexLocker ml(step_mutex); StepType st = (StepType)h.step; pftheader.step = st; if (!h.check_sig()) { @@ -275,7 +280,10 @@ void PIFileTransfer::receive_started() { void PIFileTransfer::receive_finished(bool ok) { - if (pftheader.step == pft_Description) { + step_mutex.lock(); + StepType st = (StepType)pftheader.step; + step_mutex.unlock(); + if (st == pft_Description) { bool user_ok = true; if (ok) { // piCoutObj << desc.size() << PICoutManipulators::Hex << desc; @@ -293,7 +301,7 @@ void PIFileTransfer::receive_finished(bool ok) { started_ = false; } else resume(); } - if (pftheader.step == pft_Data) { + if (st == pft_Data) { //piCoutObj << "file close"; work_file.close(); receiveFilesFinished(ok); diff --git a/src_main/io/pifiletransfer.h b/src_main/io/pifiletransfer.h index d2c5e26d..058de183 100644 --- a/src_main/io/pifiletransfer.h +++ b/src_main/io/pifiletransfer.h @@ -95,6 +95,7 @@ private: PIByteArray desc; PIDir scan_dir; bool started_, scanning; + PIMutex step_mutex; bool sendFiles(const PIVector &files); void processFile(int id, ullong start, PIByteArray &data); diff --git a/utils/system_daemon/daemon.cpp b/utils/system_daemon/daemon.cpp index 44de3e03..4ad116a0 100644 --- a/utils/system_daemon/daemon.cpp +++ b/utils/system_daemon/daemon.cpp @@ -650,7 +650,7 @@ void Daemon::peerDisconnected(const PIString & p_name) { void Daemon::filesReceived(const PIString & p_name, bool ok) { - piCoutObj << "filesReceived"; + piCout << "filesReceived"; closeFileDialog(p_name, ok); PIMutexLocker ml(remote_mutex); Remote * r = remotes.value(p_name, 0); @@ -660,7 +660,7 @@ void Daemon::filesReceived(const PIString & p_name, bool ok) { void Daemon::filesSended(const PIString & p_name, bool ok) { - piCoutObj << "filesSended"; + piCout << "filesSended"; closeFileDialog(p_name, ok); }