From b73809d54f960c9e50dd7651ec512f4a16b498eb Mon Sep 17 00:00:00 2001 From: Matthias Vallentin Date: Thu, 27 Sep 2012 12:18:25 -0700 Subject: [PATCH] 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. --- src/logging/writers/ElasticSearch.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/logging/writers/ElasticSearch.cc b/src/logging/writers/ElasticSearch.cc index cb3248a044..24489314ec 100644 --- a/src/logging/writers/ElasticSearch.cc +++ b/src/logging/writers/ElasticSearch.cc @@ -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(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);