diff --git a/src/macro-condition-file.cpp b/src/macro-condition-file.cpp index 42b61396..ec3505a8 100644 --- a/src/macro-condition-file.cpp +++ b/src/macro-condition-file.cpp @@ -32,6 +32,14 @@ static std::string getRemoteData(std::string &url) f_curl_setopt(switcher->curl, CURLOPT_WRITEFUNCTION, WriteCallback); f_curl_setopt(switcher->curl, CURLOPT_WRITEDATA, &readBuffer); + + // Set timeout to at least one second + int timeout = switcher->interval / 1000; + if (timeout == 0) { + timeout = 1; + } + f_curl_setopt(switcher->curl, CURLOPT_TIMEOUT, 1); + f_curl_perform(switcher->curl); } return readBuffer; diff --git a/src/switch-file.cpp b/src/switch-file.cpp index 6aa66181..03d75078 100644 --- a/src/switch-file.cpp +++ b/src/switch-file.cpp @@ -167,6 +167,14 @@ static std::string getRemoteData(std::string &url) f_curl_setopt(switcher->curl, CURLOPT_WRITEFUNCTION, WriteCallback); f_curl_setopt(switcher->curl, CURLOPT_WRITEDATA, &readBuffer); + + // Set timeout to at least one second + int timeout = switcher->interval / 1000; + if (timeout == 0) { + timeout = 1; + } + f_curl_setopt(switcher->curl, CURLOPT_TIMEOUT, 1); + f_curl_perform(switcher->curl); } return readBuffer;