diff --git a/README.md b/README.md index b1adda98b..ac1bb2d13 100644 --- a/README.md +++ b/README.md @@ -322,7 +322,7 @@ The following SDK library releases are available on [vcpkg](https://github.com/m * `azure-storage-files-shares-cpp` * `azure-storage-queues-cpp` -> NOTE: In case of getting linker errors when consuming the SDK on Windows, make sure that [vcpkg triplet](https://vcpkg.readthedocs.io/en/latest/users/triplets/) being consumed matches the [CRT link flags](https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-160) being set for your app or library build. See also `MSVC_USE_STATIC_CRT` build flag. +> NOTE: In case of getting linker errors when consuming the SDK on Windows, make sure that [vcpkg triplet](https://learn.microsoft.com/vcpkg/users/triplets) being consumed matches the [CRT link flags](https://docs.microsoft.com/cpp/build/reference/md-mt-ld-use-run-time-library?view=msvc-160) being set for your app or library build. See also `MSVC_USE_STATIC_CRT` build flag. ## OpenSSL Version diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index e7d1ccd19..6b9e940d9 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -2288,6 +2288,9 @@ CurlConnection::CurlConnection( if (!options.SslOptions.PemEncodedExpectedRootCertificates.empty()) { + // curl_blob is defined in Curl version 7.77 or newer. Since we prefer to use the OS version of + // Curl some may not be up to date enough (e.g. Ubuntu 18.04 uses Curl 7.58) +#if LIBCURL_VERSION_MAJOR > 7 || (LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR >= 77) curl_blob rootCertBlob = {const_cast(reinterpret_cast( options.SslOptions.PemEncodedExpectedRootCertificates.c_str())), @@ -2300,6 +2303,12 @@ CurlConnection::CurlConnection( + ". Failed to set CA cert to:" + options.CAInfo + ". " + std::string(curl_easy_strerror(result))); } +#else + throw Azure::Core::Http::TransportException( + _detail::DefaultFailedToGetNewConnectionTemplate + hostDisplayName + + ". Failed to set CA cert to:" + options.CAInfo + ". " + + "Not supported in your version of Curl"); +#endif } #if defined(AZ_PLATFORM_WINDOWS) diff --git a/sdk/core/azure-core/src/http/websockets/websockets_impl.cpp b/sdk/core/azure-core/src/http/websockets/websockets_impl.cpp index 7078c2ef8..9044a6e27 100644 --- a/sdk/core/azure-core/src/http/websockets/websockets_impl.cpp +++ b/sdk/core/azure-core/src/http/websockets/websockets_impl.cpp @@ -652,7 +652,7 @@ namespace Azure { namespace Core { namespace Http { namespace WebSockets { names WebSocketImplementation::DecodeFrame(Azure::Core::Context const& context) { // Ensure single threaded access to receive this frame. - std::unique_lock lock(m_transportMutex); + std::unique_lock lock(m_transportReadMutex); if (IsTransportEof()) { throw std::runtime_error("Frame buffer is too small."); @@ -726,7 +726,7 @@ namespace Azure { namespace Core { namespace Http { namespace WebSockets { names m_bufferPos = 0; if (m_bufferLen == 0) { - m_eof = true; + m_eof.store(true, std::memory_order_release); return 0; } } @@ -774,7 +774,7 @@ namespace Azure { namespace Core { namespace Http { namespace WebSockets { names std::vector const& sendFrame, Azure::Core::Context const& context) { - std::unique_lock transportLock(m_transportMutex); + std::unique_lock transportLock(m_transportWriteMutex); m_receiveStatistics.BytesSent += static_cast(sendFrame.size()); m_receiveStatistics.FramesSent += 1; m_transport->SendBuffer(sendFrame.data(), sendFrame.size(), context); diff --git a/sdk/core/azure-core/src/http/websockets/websockets_impl.hpp b/sdk/core/azure-core/src/http/websockets/websockets_impl.hpp index d62d82b56..62127d9ef 100644 --- a/sdk/core/azure-core/src/http/websockets/websockets_impl.hpp +++ b/sdk/core/azure-core/src/http/websockets/websockets_impl.hpp @@ -5,6 +5,8 @@ #include "azure/core/internal/diagnostics/log.hpp" #include "azure/core/internal/http/pipeline.hpp" #include +#include +#include #include #include #include @@ -335,7 +337,7 @@ namespace Azure { namespace Core { namespace Http { namespace WebSockets { names uint16_t ReadTransportShort(Azure::Core::Context const& context); uint64_t ReadTransportInt64(Azure::Core::Context const& context); std::vector ReadTransportBytes(size_t readLength, Azure::Core::Context const& context); - bool IsTransportEof() const { return m_eof; } + bool IsTransportEof() const { return m_eof.load(std::memory_order_acquire); } void SendPong(std::vector const& pongData, Azure::Core::Context const& context); void SendTransportBuffer( std::vector const& payload, @@ -358,17 +360,17 @@ namespace Azure { namespace Core { namespace Http { namespace WebSockets { names PingThread m_pingThread; SocketMessageType m_currentMessageType{SocketMessageType::Unknown}; std::mutex m_stateMutex; + std::mutex m_transportReadMutex; + std::mutex m_transportWriteMutex; std::thread::id m_stateOwner; ReceiveStatistics m_receiveStatistics{}; - std::mutex m_transportMutex; - std::unique_ptr m_initialBodyStream; constexpr static size_t m_bufferSize = 1024; uint8_t m_buffer[m_bufferSize]{}; size_t m_bufferPos = 0; size_t m_bufferLen = 0; - bool m_eof = false; + std::atomic m_eof{false}; }; }}}}} // namespace Azure::Core::Http::WebSockets::_detail