mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
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:
parent
bf62a6e673
commit
b73809d54f
1 changed files with 14 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue