From c1f788ac424c968a624e2aa12a02b7ea27b4a88b Mon Sep 17 00:00:00 2001 From: GetAway Date: Tue, 7 Feb 2017 22:19:57 +0100 Subject: [PATCH] change to CURLOPT_CONNECTTIMEOUT_MS and ... use a connect_timeout of 300ms for remote timer --- src/gui/timerlist.cpp | 2 +- src/system/httptool.cpp | 8 ++++---- src/system/httptool.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 929ab4bbe..f54d04c30 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -280,7 +280,7 @@ CTimerList::CTimerList() Timer = new CTimerdClient(); timerNew_message = ""; timerNew_pluginName = ""; - httpConnectTimeout = 3; + httpConnectTimeout = 300; // ms changed = false; /* most probable default */ diff --git a/src/system/httptool.cpp b/src/system/httptool.cpp index 2d023c124..c68c84527 100644 --- a/src/system/httptool.cpp +++ b/src/system/httptool.cpp @@ -66,7 +66,7 @@ int CHTTPTool::show_progress( void *clientp, double dltotal, double dlnow, doubl return 0; } //#define DEBUG -bool CHTTPTool::downloadFile(const std::string & URL, const char * const downloadTarget, int globalProgressEnd, int connecttimeout/*=10*/, int timeout/*=1800*/) +bool CHTTPTool::downloadFile(const std::string & URL, const char * const downloadTarget, int globalProgressEnd, int connecttimeout/*=10000*/, int timeout/*=1800*/) { CURL *curl; CURLcode res; @@ -98,7 +98,7 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, connecttimeout); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, connecttimeout); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); #ifdef DEBUG curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); @@ -136,7 +136,7 @@ printf("download code %d\n", res); return res==CURLE_OK; } -std::string CHTTPTool::downloadString(const std::string & URL, int globalProgressEnd, int connecttimeout/*=10*/, int timeout/*=1800*/) +std::string CHTTPTool::downloadString(const std::string & URL, int globalProgressEnd, int connecttimeout/*=10000*/, int timeout/*=1800*/) { CURL *curl; CURLcode res; @@ -162,7 +162,7 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, (long)1); curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout); - curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, connecttimeout); + curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, connecttimeout); curl_easy_setopt(curl, CURLOPT_FAILONERROR, true); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, false); #ifdef DEBUG diff --git a/src/system/httptool.h b/src/system/httptool.h index 919cf4dbb..845cc3bf6 100644 --- a/src/system/httptool.h +++ b/src/system/httptool.h @@ -52,8 +52,8 @@ class CHTTPTool CHTTPTool(); void setStatusViewer( CProgressWindow* statusview ); - bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1, int connecttimeout=10, int timeout=1800); - std::string downloadString(const std::string & URL, int globalProgressEnd=-1, int connecttimeout=10, int timeout=1800); + bool downloadFile( const std::string & URL, const char * const downloadTarget, int globalProgressEnd=-1, int connecttimeout=10000, int timeout=1800); + std::string downloadString(const std::string & URL, int globalProgressEnd=-1, int connecttimeout=10000, int timeout=1800); };