applying some changes for the server list and connection timeout.

master
David Carlier 2022-06-25 11:20:43 +01:00
parent 798bf661bd
commit add7c5c60a
2 changed files with 9 additions and 2 deletions

View File

@ -155,10 +155,16 @@ namespace spades {
curl_easy_setopt(cHandle.get(), CURLOPT_URL, cl_serverListUrl.CString());
curl_easy_setopt(cHandle.get(), CURLOPT_WRITEFUNCTION, curlWriteCallback);
curl_easy_setopt(cHandle.get(), CURLOPT_WRITEDATA, this);
if (0 == curl_easy_perform(cHandle.get())) {
curl_easy_setopt(cHandle.get(), CURLOPT_LOW_SPEED_TIME, 30l);
curl_easy_setopt(cHandle.get(), CURLOPT_LOW_SPEED_LIMIT, 15l);
curl_easy_setopt(cHandle.get(), CURLOPT_CONNECTTIMEOUT, 30l);
auto reqret = curl_easy_perform(cHandle.get());
if (CURLE_OK == reqret) {
ProcessResponse();
} else {
SPRaise("HTTP request error.");
char buf[256];
snprintf(buf, sizeof(buf), "HTTP request error (%s).", curl_easy_strerror(reqret));
SPRaise(buf);
}
} else {
SPRaise("Failed to create cURL object.");

View File

@ -143,6 +143,7 @@ namespace spades {
curl_easy_setopt(curl.get(), CURLOPT_NOPROGRESS, 0);
curl_easy_setopt(curl.get(), CURLOPT_LOW_SPEED_TIME, 30l);
curl_easy_setopt(curl.get(), CURLOPT_LOW_SPEED_LIMIT, 15l);
curl_easy_setopt(curl.get(), CURLOPT_CONNECTTIMEOUT, 30l);
curl_easy_setopt(
curl.get(), CURLOPT_XFERINFOFUNCTION,
static_cast<int (*)(void *, curl_off_t, curl_off_t, curl_off_t, curl_off_t)>(