From f99c81c336826ef73c5dad9aee719672f711d7fe Mon Sep 17 00:00:00 2001 From: Arnold <40414978+PatriceJiang@users.noreply.github.com> Date: Fri, 31 Aug 2018 10:12:04 +0800 Subject: [PATCH] https downloader timeout on win/mac (#18935) --- cocos/network/CCDownloader-curl.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cocos/network/CCDownloader-curl.cpp b/cocos/network/CCDownloader-curl.cpp index 52d8301816..258165987b 100644 --- a/cocos/network/CCDownloader-curl.cpp +++ b/cocos/network/CCDownloader-curl.cpp @@ -39,6 +39,8 @@ // member function with suffix "Proc" designed called in DownloaderCURL::_threadProc // member function without suffix designed called in main thread +#define CC_CURL_POLL_TIMEOUT_MS 50 //wait until DNS query done + namespace cocos2d { namespace network { using namespace std; @@ -381,11 +383,14 @@ namespace cocos2d { namespace network { } static const long LOW_SPEED_LIMIT = 1; - static const long LOW_SPEED_TIME = 5; + static const long LOW_SPEED_TIME = 10; curl_easy_setopt(handle, CURLOPT_LOW_SPEED_LIMIT, LOW_SPEED_LIMIT); curl_easy_setopt(handle, CURLOPT_LOW_SPEED_TIME, LOW_SPEED_TIME); - static const int MAX_REDIRS = 2; + curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0); + curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0); + + static const int MAX_REDIRS = 5; if (MAX_REDIRS) { curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, true); @@ -508,7 +513,7 @@ namespace cocos2d { namespace network { // do wait action if(maxfd == -1) { - this_thread::sleep_for(chrono::milliseconds(timeoutMS)); + this_thread::sleep_for(chrono::milliseconds(CC_CURL_POLL_TIMEOUT_MS)); rc = 0; } else