Fix compile issues with older versions of libcurl.

Older versions of libcurl do not offer *_MS timeout constants, which causes the
build to fail. For sub-second timeout specification, we now fall back to
hard-coded timeouts in older libcurl version.
This commit is contained in:
Matthias Vallentin 2012-09-27 12:18:25 -07:00
parent bf62a6e673
commit b73809d54f

View file

@ -48,7 +48,7 @@ ElasticSearch::ElasticSearch(WriterFrontend* frontend) : WriterBackend(frontend)
last_send = current_time();
failing = false;
transfer_timeout = BifConst::LogElasticSearch::transfer_timeout * 1000;
transfer_timeout = static_cast<uint64>(BifConst::LogElasticSearch::transfer_timeout) * 1000;
curl_handle = HTTPSetup();
}
@ -373,8 +373,21 @@ bool ElasticSearch::HTTPSend(CURL *handle)
// Some timeout options. These will need more attention later.
curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1);
#if LIBCURL_VERSION_NUM > 0x071002
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT_MS, transfer_timeout);
curl_easy_setopt(handle, CURLOPT_TIMEOUT_MS, transfer_timeout*2);
#else
if ( transfer_timeout > 1000 )
{
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, transfer_timeout/1000);
curl_easy_setopt(handle, CURLOPT_TIMEOUT, transfer_timeout/2000);
}
else
{
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_easy_setopt(handle, CURLOPT_TIMEOUT, 1);
}
#endif
curl_easy_setopt(handle, CURLOPT_DNS_CACHE_TIMEOUT, 60*60);
CURLcode return_code = curl_easy_perform(handle);