diff --git a/proxyface/autoproxy.hxx b/proxyface/autoproxy.hxx index 97fb832..b8d474c 100644 --- a/proxyface/autoproxy.hxx +++ b/proxyface/autoproxy.hxx @@ -114,6 +114,9 @@ namespace proxy { #ifdef QT_NETWORK_LIB //! Reset, stop all outstanding checks void reset() { + if (_requests.size() || _timeout1.isActive() || _timeout2.isActive()) + // error when we need to abort + proxyError(QNetworkReply::TimeoutError); _timeout1.stop(); _timeout2.stop(); for (Requests::iterator it(_requests.begin()); @@ -122,7 +125,10 @@ namespace proxy { _requests.clear(); } //! Network Ping: Check access to a given address using default proxy. - void ping(const std::string& url, int timeout2=30000) { + void ping(const std::string& url, int timeout2=5000) { + if (_requests.size() || _timeout1.isActive() || _timeout2.isActive()) + // detection is already running, wait for that, don't restart + return; reset(); _timeout2.setSingleShot(true); _timeout2.setInterval(timeout2); @@ -132,10 +138,10 @@ namespace proxy { setupProxyCheck(defaultProxy, url); _timeout2.start(); } - void ping(const QUrl& url, int timeout2=30000) { + void ping(const QUrl& url, int timeout2=5000) { ping(url.toString().toStdString(), timeout2); } - void ping(const QString& url, int timeout2=30000) { + void ping(const QString& url, int timeout2=5000) { ping(url.toStdString(), timeout2); } //! If Qt Network is available you may check the proxies found @@ -150,7 +156,7 @@ namespace proxy { @param url the url to find a proxy for @param timeout [ms] time to give up search */ void proxy(const std::string& url, - int timeout1=5000, int timeout2=30000) { + int timeout1=5000, int timeout2=5000) { PROXYFACE_LOG; qDebug()<<"Search proxy for URL, direct and default" <<"url="<