Re: lftp and locked file on STOR
"Alexander V. Lukyanov" <[email protected]> Thu, 2 Aug 2007 10:48:40 +0400
| Newsgroups | gmane.network.lftp.devel |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 01, 2007 at 06:31:19PM +0200, Thomas Zaech wrote: > thanks for the patch. > With the patch applied, lftp now will retry as long as the server indicates the 4xx-status. Can the number of retries get limited in this situation (I didn't found net:max-tries really working for that)? Please try this additional patch. -- Alexander.
diff
(text/plain, 4.1 KB)
Index: NetAccess.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/NetAccess.cc,v
retrieving revision 1.94
diff -u -p -r1.94 NetAccess.cc
--- NetAccess.cc 8 Jun 2007 14:17:59 -0000 1.94
+++ NetAccess.cc 2 Aug 2007 05:51:03 -0000
@@ -645,11 +645,8 @@ const char *NetAccess::DelayingMessage()
bool NetAccess::NextTry()
{
- if(max_retries>0 && retries>=max_retries)
- {
- Fatal(_("max-retries exceeded"));
+ if(!CheckRetries())
return false;
- }
if(retries==0)
reconnect_interval_current=reconnect_interval;
else if(reconnect_interval_multiplier>1)
@@ -658,8 +655,17 @@ bool NetAccess::NextTry()
if(reconnect_interval_current>reconnect_interval_max)
reconnect_interval_current=reconnect_interval_max;
}
- try_time=now;
retries++;
+ return CheckRetries();
+}
+bool NetAccess::CheckRetries()
+{
+ if(max_retries>0 && retries>max_retries)
+ {
+ Fatal(_("max-retries exceeded"));
+ return false;
+ }
+ try_time=now;
return true;
}
void NetAccess::TrySuccess()
Index: NetAccess.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/NetAccess.h,v
retrieving revision 1.44
diff -u -p -r1.44 NetAccess.h
--- NetAccess.h 16 May 2007 08:07:31 -0000 1.44
+++ NetAccess.h 2 Aug 2007 04:50:39 -0000
@@ -95,7 +95,8 @@ protected:
const char *DelayingMessage();
bool ReconnectAllowed();
- bool NextTry(); // returns false if max-retries exceeded.
+ bool CheckRetries(); // returns false if max-retries exceeded.
+ bool NextTry(); // increments retries; does CheckRetries().
void TrySuccess(); // reset retry counters.
virtual void HandleTimeout();
Index: ftpclass.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/ftpclass.cc,v
retrieving revision 1.409
diff -u -p -r1.409 ftpclass.cc
--- ftpclass.cc 1 Aug 2007 09:56:03 -0000 1.409
+++ ftpclass.cc 2 Aug 2007 05:50:04 -0000
@@ -295,7 +295,8 @@ void Ftp::NoFileCheck(int act)
eof=false;
if(mode==STORE && (flags&IO_FLAG))
SetError(STORE_FAILED,0);
- retry_timer.Set(2); // retry after 2 seconds
+ else if(NextTry())
+ retry_timer.Set(2); // retry after 2 seconds
}
/* 5xx that aren't errors at all */
@@ -327,8 +328,6 @@ bool Ftp::Transient5XX(int act)
// 226 Transfer complete.
void Ftp::TransferCheck(int act)
{
- if(conn->data_sock==-1)
- eof=true;
if(act==225 || act==226) // data connection is still open or ABOR worked.
{
copy_done=true;
@@ -396,6 +395,8 @@ void Ftp::TransferCheck(int act)
if(conn->data_sock==-1 && strstr(line,"Broken pipe"))
return;
}
+ if(is2XX(act) && conn->data_sock==-1)
+ eof=true;
NoFileCheck(act);
}
@@ -1494,6 +1495,9 @@ int Ftp::Do()
ExpandTildeInCWD();
+ if(!CheckRetries())
+ return MOVED;
+
if(mode!=CHANGE_DIR)
{
Expect *last_cwd=expect->FindLastCWD();
@@ -2221,6 +2225,8 @@ int Ftp::Do()
state=EOF_STATE;
if(mode==STORE && (flags&IO_FLAG))
SetError(STORE_FAILED,0);
+ else if(NextTry())
+ retry_timer.Set(2); // retry after 2 seconds
}
return MOVED;
}
@@ -3680,7 +3686,8 @@ void Ftp::CheckResp(int act)
long long size_ll;
if(1==sscanf(s+1,"%lld",&size_ll))
{
- *opt_size=size_ll;
+ entity_size=size_ll;
+ *opt_size=entity_size;
DebugPrint("---- ",_("saw file size in response"),7);
}
}
Index: FileCopy.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileCopy.cc,v
retrieving revision 1.136
diff -u -p -r1.136 FileCopy.cc
--- FileCopy.cc 26 Jul 2007 06:14:34 -0000 1.136
+++ FileCopy.cc 2 Aug 2007 04:52:40 -0000
@@ -916,7 +916,7 @@ void FileCopyPeerFA::OpenSession()
if(try_time!=0)
session->SetTryTime(try_time);
if(retries!=0)
- session->SetRetries(retries);
+ session->SetRetries(retries+1);
if(e_size!=NO_SIZE && e_size!=NO_SIZE_YET)
session->SetSize(e_size);
if(date!=NO_DATE && date!=NO_DATE_YET)