New zypp.conf option 'download.transfer_timeout = 180'
authorMichael Andres <ma@suse.de>
Fri, 19 Apr 2013 11:58:24 +0000 (13:58 +0200)
committerMichael Andres <ma@suse.de>
Fri, 19 Apr 2013 11:58:24 +0000 (13:58 +0200)
Maximum time in seconds that you allow a transfer operation to take. Now
configurable in case the 180 seconds default tends to be too short.

zypp.conf
zypp/ZConfig.cc
zypp/ZConfig.h
zypp/media/MediaCurl.cc

index 27431b1..e975d93 100644 (file)
--- a/zypp.conf
+++ b/zypp.conf
 # download.max_silent_tries = 5
 
 ##
+## Maximum time in seconds that you allow a transfer operation to take.
+##
+## This is useful for preventing your batch jobs from hanging for hours due
+## to slow networks or links going down. Limiting operations to less than a
+## few minutes risk aborting perfectly normal operations.
+##
+## Valid values:  [0,3600]
+## Default value: 180
+##
+# download.transfer_timeout = 180
+
+##
 ## Whether to consider using a .delta.rpm when downloading a package
 ##
 ## Valid values: boolean
index 5c98209..c935f50 100644 (file)
@@ -284,6 +284,7 @@ namespace zypp
         , download_min_download_speed  ( 0 )
         , download_max_download_speed  ( 0 )
         , download_max_silent_tries    ( 5 )
+        , download_transfer_timeout    ( 180 )
         , commit_downloadMode          ( DownloadDefault )
         , solver_onlyRequires          ( false )
         , solver_allowVendorChange     ( false )
@@ -410,6 +411,12 @@ namespace zypp
                 {
                   str::strtonum(value, download_max_silent_tries);
                 }
+                else if ( entry == "download.transfer_timeout" )
+                {
+                  str::strtonum(value, download_transfer_timeout);
+                 if ( download_transfer_timeout < 0 )          download_transfer_timeout = 0;
+                 else if ( download_transfer_timeout > 3600 )  download_transfer_timeout = 3600;
+                }
                 else if ( entry == "commit.downloadMode" )
                 {
                   commit_downloadMode.set( deserializeDownloadMode( value ) );
@@ -555,6 +562,7 @@ namespace zypp
     int download_min_download_speed;
     int download_max_download_speed;
     int download_max_silent_tries;
+    int download_transfer_timeout;
 
     Option<DownloadMode> commit_downloadMode;
 
@@ -833,6 +841,9 @@ namespace zypp
   long ZConfig::download_max_silent_tries() const
   { return _pimpl->download_max_silent_tries; }
 
+  long ZConfig::download_transfer_timeout() const
+  { return _pimpl->download_transfer_timeout; }
+
   DownloadMode ZConfig::commit_downloadMode() const
   { return _pimpl->commit_downloadMode; }
 
index c8b9793..6c76c3a 100644 (file)
@@ -223,6 +223,11 @@ namespace zypp
        */
       long download_max_silent_tries() const;
 
+      /**
+       * Maximum time in seconds that you allow a transfer operation to take.
+       */
+      long download_transfer_timeout() const;
+
 
       /** Whether to consider using a deltarpm when downloading a package.
        * Config option <tt>download.use_deltarpm (true)</tt>
index 6257fe2..605f4fc 100644 (file)
@@ -28,6 +28,7 @@
 #include "zypp/thread/Once.h"
 #include "zypp/Target.h"
 #include "zypp/ZYppFactory.h"
+#include "zypp/ZConfig.h"
 
 #include <cstdlib>
 #include <sys/types.h>
@@ -40,7 +41,6 @@
 
 #define  DETECT_DIR_INDEX       0
 #define  CONNECT_TIMEOUT        60
-#define  TRANSFER_TIMEOUT       60 * 3
 #define  TRANSFER_TIMEOUT_MAX   60 * 60
 
 #define EXPLICITLY_NO_PROXY "_none_"
@@ -563,7 +563,7 @@ void MediaCurl::setupEasy()
   vol_settings.addHeader(distributionFlavorHeader());
   vol_settings.addHeader("Pragma:");
 
-  _settings.setTimeout(TRANSFER_TIMEOUT);
+  _settings.setTimeout(ZConfig::instance().download_transfer_timeout());
   _settings.setConnectTimeout(CONNECT_TIMEOUT);
 
   _settings.setUserAgentString(agentString());