Add configurable curl timeout
authorsapier <Sapier at GMX dot net>
Mon, 15 Jul 2013 21:36:44 +0000 (23:36 +0200)
committerPilzAdam <pilzadam@minetest.net>
Mon, 22 Jul 2013 16:09:59 +0000 (18:09 +0200)
src/convert_json.cpp
src/defaultsettings.cpp

index 71cba06954e47fbca5fc2c1bfc4b99dc58e6a1a5..58eefd9015b9c9a6980203e21a01824920fa5da7 100644 (file)
@@ -25,6 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "mods.h"
 #include "config.h"
 #include "log.h"
+#include "main.h" // for g_settings
+#include "settings.h"
 
 #if USE_CURL
 #include <curl/curl.h>
@@ -52,7 +54,7 @@ Json::Value                 fetchJsonValue(const std::string url,
                curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
                curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
                curl_easy_setopt(curl, CURLOPT_WRITEDATA, &liststring);
-
+               curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, g_settings->getS32("curl_timeout"));
                if (chunk != 0)
                        curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
 
index b6ee5e71cc1f0a3b6611a8ed80dcc0be96d08fbf..ab9b6dbce7f15bf94c7f0e1e8b354345af4fc74f 100644 (file)
@@ -257,6 +257,8 @@ void set_default_settings(Settings *settings)
 
        settings->setDefault("mgmath_generator", "mandelbox");
 
+       settings->setDefault("curl_timeout", "5000");
+
        // IPv6
        settings->setDefault("enable_ipv6", "true");
        settings->setDefault("ipv6_server", "false");