Enlage plugin communication timeouts, also make them configurable via environment.
authorMichael Andres <ma@suse.de>
Tue, 9 Nov 2010 12:02:05 +0000 (13:02 +0100)
committerMichael Andres <ma@suse.de>
Tue, 9 Nov 2010 12:02:05 +0000 (13:02 +0100)
- default (send and receive 30 sec.
- ZYPP_PLUGIN_TIMEOUT
- ZYPP_PLUGIN_SEND_TIMEOUT
- ZYPP_PLUGIN_RECEIVE_TIMEOUT []

zypp/PluginScript.cc
zypp/PluginScript.h

index d175da2..d1459bb 100644 (file)
@@ -34,7 +34,12 @@ namespace zypp
 
   namespace
   {
-    static const char * PLUGIN_DEBUG = getenv( "ZYPP_PLUGIN_DEBUG" );
+    const char * PLUGIN_DEBUG = getenv( "ZYPP_PLUGIN_DEBUG" );
+    const long PLUGIN_TIMEOUT = str::strtonum<long>( getenv( "ZYPP_PLUGIN_TIMEOUT" ) );
+    const long PLUGIN_SEND_TIMEOUT = str::strtonum<long>( getenv( "ZYPP_PLUGIN_SEND_TIMEOUT" ) );
+    const long PLUGIN_RECEIVE_TIMEOUT = str::strtonum<long>( getenv( "ZYPP_PLUGIN_RECEIVE_TIMEOUT" ) );
+
+    const long PLUGIN_TIMEOUT = ( getenv( "ZYPP_PLUGIN_DEBUG" )
 
     /** Dump buffer string if PLUGIN_DEBUG is on.
      * \ingroup g_RAII
@@ -170,8 +175,10 @@ namespace zypp
 
   ///////////////////////////////////////////////////////////////////
 
-  const long PluginScript::Impl::send_timeout = 3;
-  const long PluginScript::Impl::receive_timeout = 5;
+  const long PluginScript::Impl::send_timeout = ( PLUGIN_SEND_TIMEOUT > 0 ? PLUGIN_SEND_TIMEOUT
+                                                                         : ( PLUGIN_TIMEOUT > 0 ? PLUGIN_TIMEOUT : 30 ) );
+  const long PluginScript::Impl::receive_timeout = ( PLUGIN_RECEIVE_TIMEOUT > 0 ? PLUGIN_RECEIVE_TIMEOUT
+                                                                                : ( PLUGIN_TIMEOUT > 0 ? PLUGIN_TIMEOUT : 30 ) );
 
   ///////////////////////////////////////////////////////////////////
 
index 93e5baa..588b7da 100644 (file)
@@ -33,6 +33,10 @@ namespace zypp
    * among multiple copies. It gets automatically closed if the last copy goes out of
    * scope.
    *
+   * Timeout when sending/receiving data to/from a plugin default to 30 sec. The value
+   * (in seconds) my be changed via the environment variables \c ZYPP_PLUGIN_SEND_TIMEOUT,
+   * \c ZYPP_PLUGIN_RECEIVE_TIMEOUT or \c ZYPP_PLUGIN_TIMEOUT (both: send and receive).
+   *
    * \code
    *  // Setup comnnection to plugin script
    *  PluginScript scr;