git-svn-id: svn://db.shs.com.ru/pip@416 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-04-19 17:11:09 +00:00
parent d8b8487dd7
commit fda6fcab79
4 changed files with 15 additions and 6 deletions

View File

@@ -79,6 +79,7 @@ bool PIFileTransfer::sendFiles(const PIVector<PFTFileInfo> &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<PFTFileInfo> &files) {
pftheader.step = pft_Description;
buildSession(PIVector<Part>() << 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<Part> pts;
for (int i=0; i<files_.size_s(); i++) {
pts << Part(i+1, files_[i].size);
}
buildSession(pts);
step_mutex.unlock();
bool ok = send_process();
sendFilesFinished(ok);
started_ = false;
@@ -222,6 +226,7 @@ void PIFileTransfer::receivePart(PIBaseTransfer::Part fi, PIByteArray ba, PIByte
// piCout << pheader.size() << sizeof(PFTHeader);
pheader >> 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);