Merge forked changes (#4714)

* Add hackfix for older Curl version

* Fix Debian 9 build failures

* Fix Linux build break

* Fix Linux build break properly

* Fix more Debian 9 build breaks

* Hack workaround to deadlock

* Revert "Fix more Debian 9 build breaks"

This reverts commit ee4c4efbc3025913ab42c04ba0fdd68be9cfa666.

* Revert "Fix Linux build break properly"

This reverts commit 071dbeb5ce63aa2e36e980bc2449217146257e28.

* Revert "Fix Linux build break"

This reverts commit 626abaf88b050589ae1542ee3dfb72b4675de09f.

* Revert "Fix Debian 9 build failures"

This reverts commit 78cad761f35f46d1794e793880ed62093ee4a709.

* Fix Curl version check

* Fix test failure

* Fix Clang format issues
This commit is contained in:
Ralph 2023-06-16 15:41:17 -07:00 committed by GitHub
parent 7c52924288
commit 75aee7df58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 8 deletions

View File

@ -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

View File

@ -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<void*>(reinterpret_cast<const void*>(
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)

View File

@ -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<std::mutex> lock(m_transportMutex);
std::unique_lock<std::mutex> 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<uint8_t> const& sendFrame,
Azure::Core::Context const& context)
{
std::unique_lock<std::mutex> transportLock(m_transportMutex);
std::unique_lock<std::mutex> transportLock(m_transportWriteMutex);
m_receiveStatistics.BytesSent += static_cast<uint32_t>(sendFrame.size());
m_receiveStatistics.FramesSent += 1;
m_transport->SendBuffer(sendFrame.data(), sendFrame.size(), context);

View File

@ -5,6 +5,8 @@
#include "azure/core/internal/diagnostics/log.hpp"
#include "azure/core/internal/http/pipeline.hpp"
#include <array>
#include <atomic>
#include <condition_variable>
#include <queue>
#include <random>
#include <shared_mutex>
@ -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<uint8_t> 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<uint8_t> const& pongData, Azure::Core::Context const& context);
void SendTransportBuffer(
std::vector<uint8_t> 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<Azure::Core::IO::BodyStream> 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<bool> m_eof{false};
};
}}}}} // namespace Azure::Core::Http::WebSockets::_detail