Commit f0f50467 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch feature/jorgen.lind/disable_init_aws_sdk with refs/heads/master...

Merge branch feature/jorgen.lind/disable_init_aws_sdk with refs/heads/master into refs/merge-requests/432/train
parents 0fcf8300 590d36f1
Pipeline #48508 passed with stages
in 18 minutes and 48 seconds
......@@ -97,7 +97,7 @@ if (WIN32)
if (MSVC_TOOLSET_VERSION_LOCAL LESS_EQUAL "140")
set(DEFAULT_DISABLE_AZURESDKFORCPP ON)
else()
set(DEFAULT_DISABLE_AZURESDKFORCPP OFF)
set(DEFAULT_DISABLE_AZURESDKFORCPP ON)
endif()
else()
set(DEFAULT_BUILD_ZLIB OFF)
......@@ -109,7 +109,7 @@ else()
if (CURL_VERSION_STRING VERSION_LESS_EQUAL "7.44")
set(DEFAULT_DISABLE_AZURESDKFORCPP ON)
else()
set(DEFAULT_DISABLE_AZURESDKFORCPP OFF)
set(DEFAULT_DISABLE_AZURESDKFORCPP ON)
endif()
endif()
......
......@@ -40,6 +40,7 @@ The recognised keys for ``s3`` connection string are
- LogLevel (Note: this is to control the AWS specific logs. Possible values: Off, Fatal, Error, Warn, Info, Debug, Trace)
- ConnectionTimoutMs
- RequestTimeoutMs
- DisableInitApi (This will disable init/deinit of AWS sdk. Possible values: 1, On, True, Yes (case insensitive), all other values are false.)
``azure`` has two modes. The connection string mode or the bearer token mode.
If the connection string contains a key with name BearerToken it will parse the
......
......@@ -326,6 +326,7 @@ namespace OpenVDS
, m_region(openOptions.region)
, m_bucket(openOptions.bucket)
, m_objectId(openOptions.key)
, m_disableInitializeSdk(openOptions.disableInitApi)
{
if (m_bucket.empty())
{
......@@ -336,7 +337,9 @@ namespace OpenVDS
if (m_objectId.size() && m_objectId[m_objectId.size() -1] == '/')
m_objectId.resize(m_objectId.size() - 1);
initializeAWSSDK(openOptions.logFilenamePrefix, openOptions.loglevel);
if (!m_disableInitializeSdk)
initializeAWSSDK(openOptions.logFilenamePrefix, openOptions.loglevel);
Aws::String profileName = "";
......@@ -455,7 +458,9 @@ namespace OpenVDS
IOManagerAWS::~IOManagerAWS()
{
m_s3Client.reset();
deinitializeAWSSDK();
if (!m_disableInitializeSdk)
deinitializeAWSSDK();
}
std::shared_ptr<Request> IOManagerAWS::ReadObjectInfo(const std::string &objectName, std::shared_ptr<TransferDownloadHandler> handler)
......
......@@ -100,6 +100,7 @@ namespace OpenVDS
std::string m_bucket;
std::string m_objectId;
std::unique_ptr<Aws::S3::S3Client> m_s3Client;
bool m_disableInitializeSdk;
};
}
#endif //IOMANAGERAWS_H
......@@ -823,6 +823,8 @@ CurlHandler::CurlHandler(Error& error)
curl_multi_setopt(m_eventLoopData.curlMulti, CURLMOPT_SOCKETDATA, &m_eventLoopData);
curl_multi_setopt(m_eventLoopData.curlMulti, CURLMOPT_TIMERFUNCTION, curlTimerCallback);
curl_multi_setopt(m_eventLoopData.curlMulti, CURLMOPT_TIMERDATA, &m_eventLoopData);
curl_multi_setopt(m_eventLoopData.curlMulti, CURLMOPT_PIPELINING, CURLPIPE_HTTP1 | CURLPIPE_MULTIPLEX);
curl_multi_setopt(m_eventLoopData.curlMulti, CURLMOPT_MAX_HOST_CONNECTIONS, 128L);
uv_prepare_init(m_eventLoopData.loop, &m_eventLoopData.beforeBlock);
m_eventLoopData.beforeBlock.data = &m_eventLoopData;
......
......@@ -172,6 +172,21 @@ static std::unique_ptr<OpenOptions> createS3OpenOptions(const StringWrapper &url
return nullptr;
}
}
else if (connectionPair.first == "disableinitapi")
{
auto value = connectionPair.second;
std::transform(value.begin(), value.end(), value.begin(), asciitolower);
static const std::string trueValues[] = { "1", "on", "true", "yes" };
openOptions->disableInitApi = false;
for (auto& trueValue : trueValues)
{
if (value == trueValue)
{
openOptions->disableInitApi = true;
break;
}
}
}
else
{
error.code = -1;
......
......@@ -93,8 +93,9 @@ struct AWSOpenOptions : OpenOptions
std::string loglevel;
int connectionTimeoutMs;
int requestTimeoutMs;
bool disableInitApi;
AWSOpenOptions() : OpenOptions(AWS), connectionTimeoutMs(3000), requestTimeoutMs(6000) {}
AWSOpenOptions() : OpenOptions(AWS), connectionTimeoutMs(3000), requestTimeoutMs(6000), disableInitApi(false) {}
/// <summary>
/// AWSOpenOptions constructor
/// </summary>
......@@ -116,7 +117,7 @@ struct AWSOpenOptions : OpenOptions
/// <param name="requestTimeoutMs">
/// This paramter allows to override the time a request can take
/// </param>
AWSOpenOptions(std::string const & bucket, std::string const & key, std::string const & region = std::string(), std::string const & endpointOverride = std::string(), int connectionTimeoutMs = 3000, int requestTimeoutMs = 6000) : OpenOptions(AWS), bucket(bucket), key(key), region(region), endpointOverride(endpointOverride), connectionTimeoutMs(connectionTimeoutMs), requestTimeoutMs(requestTimeoutMs) {}
AWSOpenOptions(std::string const & bucket, std::string const & key, std::string const & region = std::string(), std::string const & endpointOverride = std::string(), int connectionTimeoutMs = 3000, int requestTimeoutMs = 6000, bool disableInitApi = false) : OpenOptions(AWS), bucket(bucket), key(key), region(region), endpointOverride(endpointOverride), connectionTimeoutMs(connectionTimeoutMs), requestTimeoutMs(requestTimeoutMs), disableInitApi(disableInitApi) {}
};
/// <summary>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment