From 80160eff00e7a02584bf2d84d46a7a4eb6d49c81 Mon Sep 17 00:00:00 2001 From: sherlock-zhouyh <15151851377@163.com> Date: Fri, 29 Oct 2021 22:14:07 +0800 Subject: [PATCH] Quit while src file increased during transfer because it will make transfer process stuck in dead loop. --- src/FileCopy.cc | 8 ++++++++ src/FileCopy.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/FileCopy.cc b/src/FileCopy.cc index ead65a2e0..31d4e0664 100644 --- a/src/FileCopy.cc +++ b/src/FileCopy.cc @@ -1137,6 +1137,7 @@ void FileCopyPeerFA::OpenSession() debug((10,"copy dst: seek past eof (seek_pos=%lld, size=%lld)\n", (long long)seek_pos,(long long)e_size)); eof=true; + fileincreased=true; if(date==NO_DATE || date==NO_DATE_YET) return; } @@ -1284,6 +1285,12 @@ int FileCopyPeerFA::Put_LL(const char *buf,int len) if(session->IsClosed()) OpenSession(); + if(fileincreased) + { + SetError(_("file size increased during transfer")); + return -1; + } + off_t io_at=pos; // GetRealPos can alter pos, save it. if(GetRealPos()!=io_at) return 0; @@ -1352,6 +1359,7 @@ void FileCopyPeerFA::Init() { get_delay=0; fxp=false; + fileincreased=false; redirections=0; can_seek=true; can_seek0=true; diff --git a/src/FileCopy.h b/src/FileCopy.h index af978809b..5a9e4cf59 100644 --- a/src/FileCopy.h +++ b/src/FileCopy.h @@ -335,6 +335,7 @@ class FileCopyPeerFA : public FileCopyPeer FileSet info; bool fxp; // FXP (ftp<=>ftp copy) active + bool fileincreased; UploadState upload_state; int redirections;