--------------Boundary-00=_CPT63JHUKVDBTU8WZFM3 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Hi, I added three methods to KProtocolManager to make it possible to change the connection and response timeout values for any interested io-slaves. I actually did this for HTTP, but I figure it might be useful for the other as well. The patch adds remoteConnectTimeout, proxyConnectTimeout and remoteResponseTimeout as static members of KProtocolManager. It also sets threshold values so that there is some limit. Currently the minimum is set for 3 minutes and the maximum values are 6 min for the remote and connection/response and 2 min for the proxy connection. The default vaules are those obtained from the HTTP io-slave which is 60, 20, 10 for remote server response timeout, remote server connect timeout and proxy connect timeout. Comments, suggestions, flames, etc are welcome... Regards, Dawit A. --------------Boundary-00=_CPT63JHUKVDBTU8WZFM3 Content-Type: text/x-c++; name="kproto.diff" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="kproto.diff" Index: kprotocolmanager.cpp =================================================================== RCS file: /home/kde/kdelibs/kio/kprotocolmanager.cpp,v retrieving revision 1.53 diff -u -r1.53 kprotocolmanager.cpp --- kprotocolmanager.cpp 2000/10/04 17:29:10 1.53 +++ kprotocolmanager.cpp 2000/10/29 10:37:11 @@ -33,6 +33,18 @@ #define DEFAULT_MAX_CACHE_SIZE 5000 #define DEFAULT_MAX_CACHE_AGE 60*60*24*14 +// MAXIMUM VALUE ALLOWED WHEN CONFIGURING +// REMOTE AND PROXY SERVERS CONNECTION AND +// RESPONSE TIMEOUTS. +#define MAX_RESPONSE_TIMEOUT_THRESHOLD 360 // 6 MIN +#define MAX_CONNECT_TIMEOUT_THRESHOLD 360 // 6 MIN +#define MAX_PROXY_CONNECT_TIMEOUT_THRESHOLD 120 // 2 MIN + +// MINIMUM TIMEOUT VALUES ALLOWED +#define MIN_TIMEOUT_THRESHOLD 3 // 3 SEC + + + KConfig *KProtocolManager::_config = 0; void KProtocolManager::reparseConfiguration() @@ -84,6 +96,42 @@ KConfig *cfg = config(); cfg->setGroup( QString::null ); return cfg->readBoolEntry( "PersistentConnections", true ); +} + +int KProtocolManager::remoteConnectTimeout() +{ + KConfig *cfg = config(); + cfg->setGroup( QString::null ); + int mrct = cfg->readNumEntry( "RemoteConnectTimeout", 20 ); // 20 seconds + if( mrct > MAX_CONNECT_TIMEOUT_THRESHOLD ) + return MAX_CONNECT_TIMEOUT_THRESHOLD; + if( mrct < MIN_TIMEOUT_THRESHOLD ) + return MIN_TIMEOUT_THRESHOLD; + return mrct; +} + +int KProtocolManager::proxyConnectTimeout() +{ + KConfig *cfg = config(); + cfg->setGroup( QString::null ); + int mpct = cfg->readNumEntry( "ProxyConnectTimeout", 10 ); // 10 seconds + if( mpct > MAX_PROXY_CONNECT_TIMEOUT_THRESHOLD ) + return MAX_PROXY_CONNECT_TIMEOUT_THRESHOLD; + if( mpct > MIN_TIMEOUT_THRESHOLD ) + return MIN_TIMEOUT_THRESHOLD; + return mpct; +} + +int KProtocolManager::remoteResponseTimeout() +{ + KConfig *cfg = config(); + cfg->setGroup( QString::null ); + int mrrt = cfg->readNumEntry( "RemoteResponseTimeout", 60 ); // 60 seconds default + if( mrrt > MAX_RESPONSE_TIMEOUT_THRESHOLD ) + return MAX_RESPONSE_TIMEOUT_THRESHOLD; + if( mrrt < MIN_TIMEOUT_THRESHOLD ) + return MIN_TIMEOUT_THRESHOLD; + return mrrt; } bool KProtocolManager::useProxy() Index: kprotocolmanager.h =================================================================== RCS file: /home/kde/kdelibs/kio/kprotocolmanager.h,v retrieving revision 1.28 diff -u -r1.28 kprotocolmanager.h --- kprotocolmanager.h 2000/10/04 17:29:10 1.28 +++ kprotocolmanager.h 2000/10/29 10:37:13 @@ -48,6 +48,45 @@ static bool autoResume(); static bool persistentConnections(); + /** + * Returns timeout value for remote connections in secs. + * + * The maximum value that can be set by the user is 6 + * minutes while the minimum is 3 seconds. If the value + * is set above or below these threshold values, the + * function will return the threshold values instead. + * + * @return timeout value for remote connection in secs. + */ + static int remoteConnectTimeout(); + + /** + * Returns timeout value for proxy connections in secs. + * + * The maximum value that can be set by the user is 2 + * minutes while the minimum is 3 seconds. If these values + * are set above or below these threshold limits, this + * function will return the threshold values themselves + * instead. + * + * @return timeout value for proxy connection in secs. + */ + static int proxyConnectTimeout(); + + /** + * Returns response timeout value for remote connections + * in secs. + * + * The maximum value that can be set by the user is 6 + * minutes while the minimum is 3 seconds. If these values + * are set above or below these threshold limits, this + * function will return the threshold values themselves + * instead. + * + * @return timeout value for remote connection in secs. + */ + static int remoteResponseTimeout(); + static bool useProxy(); /* --------------Boundary-00=_CPT63JHUKVDBTU8WZFM3--