Add timeout of 5s to Okapi connections

sql-rework
Tomasz Golinski 2020-03-21 04:00:19 +01:00
rodzic 120f083749
commit f13f9782a1
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -58,10 +58,11 @@ std::string Okapi::curl_post(const std::string& url, const std::string& post) co
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)&output);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5);
res = curl_easy_perform(curl);
if (res != CURLE_OK) {
Debug(1) << "curl_easy_perform() failed: " << curl_easy_strerror(res) << '\n';
Debug(1) << "Connection failed: " << curl_easy_strerror(res) << '\n';
curl_easy_cleanup(curl);
std::exit(EXIT_FAILURE);
}