Browse Source

Decreasing duration threshold for parallel transfer to 10 seconds and making it configurable

Source commit: 02741637185f2da246b265eec1054431c8446a21
Martin Prikryl 9 years ago
parent
commit
0ac6cc422f
4 changed files with 18 additions and 1 deletions
  1. 7 0
      source/core/Configuration.cpp
  2. 3 0
      source/core/Configuration.h
  3. 6 1
      source/core/Queue.cpp
  4. 2 0
      source/core/Queue.h

+ 7 - 0
source/core/Configuration.cpp

@@ -100,6 +100,7 @@ void __fastcall TConfiguration::Default()
   FShowFtpWelcomeMessage = false;
   FExternalIpAddress = L"";
   FTryFtpWhenSshFails = true;
+  FParallelDurationThreshold = 10;
   CollectUsage = FDefaultCollectUsage;
 
   FLogging = false;
@@ -217,6 +218,7 @@ UnicodeString __fastcall TConfiguration::PropertyToKey(const UnicodeString & Pro
     KEY(Bool,     ShowFtpWelcomeMessage); \
     KEY(String,   ExternalIpAddress); \
     KEY(Bool,     TryFtpWhenSshFails); \
+    KEY(Integer,  ParallelDurationThreshold); \
     KEY(Bool,     CollectUsage); \
   ); \
   BLOCK(L"Logging", CANCREATE, \
@@ -1297,6 +1299,11 @@ void __fastcall TConfiguration::SetTryFtpWhenSshFails(bool value)
   SET_CONFIG_PROPERTY(TryFtpWhenSshFails);
 }
 //---------------------------------------------------------------------
+void __fastcall TConfiguration::SetParallelDurationThreshold(int value)
+{
+  SET_CONFIG_PROPERTY(ParallelDurationThreshold);
+}
+//---------------------------------------------------------------------
 void __fastcall TConfiguration::SetPuttyRegistryStorageKey(UnicodeString value)
 {
   SET_CONFIG_PROPERTY(PuttyRegistryStorageKey);

+ 3 - 0
source/core/Configuration.h

@@ -69,6 +69,7 @@ private:
   UnicodeString FPuttyRegistryStorageKey;
   UnicodeString FExternalIpAddress;
   bool FTryFtpWhenSshFails;
+  int FParallelDurationThreshold;
   bool FScripting;
 
   bool FDisablePasswordStoring;
@@ -137,6 +138,7 @@ private:
   void __fastcall UpdateActualLogProtocol();
   void __fastcall SetExternalIpAddress(UnicodeString value);
   void __fastcall SetTryFtpWhenSshFails(bool value);
+  void __fastcall SetParallelDurationThreshold(int value);
   bool __fastcall GetCollectUsage();
   void __fastcall SetCollectUsage(bool value);
   bool __fastcall GetIsUnofficial();
@@ -284,6 +286,7 @@ public:
   __property bool ShowFtpWelcomeMessage = { read = FShowFtpWelcomeMessage, write = SetShowFtpWelcomeMessage };
   __property UnicodeString ExternalIpAddress = { read = FExternalIpAddress, write = SetExternalIpAddress };
   __property bool TryFtpWhenSshFails = { read = FTryFtpWhenSshFails, write = SetTryFtpWhenSshFails };
+  __property int ParallelDurationThreshold = { read = FParallelDurationThreshold, write = SetParallelDurationThreshold };
 
   __property UnicodeString TimeFormat = { read = GetTimeFormat };
   __property TStorage Storage  = { read=GetStorage, write=SetStorage };

+ 6 - 1
source/core/Queue.cpp

@@ -544,6 +544,11 @@ bool __fastcall TTerminalQueue::TerminalFree(TTerminalItem * TerminalItem)
   return Result;
 }
 //---------------------------------------------------------------------------
+int __fastcall TTerminalQueue::GetParallelDurationThreshold()
+{
+  return FConfiguration->ParallelDurationThreshold;
+}
+//---------------------------------------------------------------------------
 void __fastcall TTerminalQueue::AddItem(TQueueItem * Item)
 {
   DebugAssert(!FTerminated);
@@ -2118,7 +2123,7 @@ void __fastcall TTransferQueueItem::ProgressUpdated()
           DWORD Now = GetTickCount();
           Force =
             (Now - FLastParallelOperationAdded >= 5*1000) &&
-            (TimeToSeconds(FProgressData->TotalTimeLeft()) >= 20);
+            (TimeToSeconds(FProgressData->TotalTimeLeft()) >= FQueue->ParallelDurationThreshold);
           LastParallelOperationAddedPrev = FLastParallelOperationAdded;
           // update now already to prevent race condition, but we will have to rollback it back,
           // if we actually do not add the parallel operation

+ 2 - 0
source/core/Queue.h

@@ -80,6 +80,7 @@ public:
   __property bool IsEmpty = { read = GetIsEmpty };
   __property int TransfersLimit = { read = FTransfersLimit, write = SetTransfersLimit };
   __property int KeepDoneItemsFor = { read = FKeepDoneItemsFor, write = SetKeepDoneItemsFor };
+  __property int ParallelDurationThreshold = { read = GetParallelDurationThreshold };
   __property bool Enabled = { read = FEnabled, write = SetEnabled };
   __property TQueryUserEvent OnQueryUser = { read = FOnQueryUser, write = FOnQueryUser };
   __property TPromptUserEvent OnPromptUser = { read = FOnPromptUser, write = FOnPromptUser };
@@ -139,6 +140,7 @@ protected:
   virtual void __fastcall ProcessEvent();
   void __fastcall TerminalFinished(TTerminalItem * TerminalItem);
   bool __fastcall TerminalFree(TTerminalItem * TerminalItem);
+  int __fastcall GetParallelDurationThreshold();
 
   void __fastcall DoQueueItemUpdate(TQueueItem * Item);
   void __fastcall DoListUpdate();