aboutsummaryrefslogtreecommitdiff
path: root/zenserver/upstream/zen.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-08-19 03:30:54 -0700
committerGitHub <[email protected]>2022-08-19 03:30:54 -0700
commit606274a83d71928f8621c1d23648a26e8f79fa7d (patch)
treed951d51e1a7919463aeec398612e97b47f99f788 /zenserver/upstream/zen.cpp
parentbump vcpkg version to 2022.08.15 (#146) (diff)
downloadzen-606274a83d71928f8621c1d23648a26e8f79fa7d.tar.xz
zen-606274a83d71928f8621c1d23648a26e8f79fa7d.zip
De/fix crash on non responding upstream (#145)
* Fix ZenStructuredCacheClient lifetime issues
Diffstat (limited to 'zenserver/upstream/zen.cpp')
-rw-r--r--zenserver/upstream/zen.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/zenserver/upstream/zen.cpp b/zenserver/upstream/zen.cpp
index cd6a531ca..b837f767c 100644
--- a/zenserver/upstream/zen.cpp
+++ b/zenserver/upstream/zen.cpp
@@ -377,23 +377,23 @@ ZenStructuredCacheClient::FreeSessionState(detail::ZenCacheSessionState* State)
using namespace std::literals;
-ZenStructuredCacheSession::ZenStructuredCacheSession(ZenStructuredCacheClient& OuterClient)
-: m_Log(OuterClient.Log())
-, m_Client(OuterClient)
+ZenStructuredCacheSession::ZenStructuredCacheSession(Ref<ZenStructuredCacheClient>&& OuterClient)
+: m_Log(OuterClient->Log())
+, m_Client(std::move(OuterClient))
{
- m_SessionState = m_Client.AllocSessionState();
+ m_SessionState = m_Client->AllocSessionState();
}
ZenStructuredCacheSession::~ZenStructuredCacheSession()
{
- m_Client.FreeSessionState(m_SessionState);
+ m_Client->FreeSessionState(m_SessionState);
}
ZenCacheResult
ZenStructuredCacheSession::CheckHealth()
{
ExtendableStringBuilder<256> Uri;
- Uri << m_Client.ServiceUrl() << "/health/check";
+ Uri << m_Client->ServiceUrl() << "/health/check";
cpr::Session& Session = m_SessionState->GetSession();
Session.SetOption(cpr::Url{Uri.c_str()});
@@ -411,7 +411,7 @@ ZenCacheResult
ZenStructuredCacheSession::GetCacheRecord(std::string_view Namespace, std::string_view BucketId, const IoHash& Key, ZenContentType Type)
{
ExtendableStringBuilder<256> Uri;
- Uri << m_Client.ServiceUrl() << "/z$/";
+ Uri << m_Client->ServiceUrl() << "/z$/";
if (Namespace != ZenCacheStore::DefaultNamespace)
{
Uri << Namespace << "/";
@@ -443,7 +443,7 @@ ZenStructuredCacheSession::GetCacheValue(std::string_view Namespace,
const IoHash& ValueContentId)
{
ExtendableStringBuilder<256> Uri;
- Uri << m_Client.ServiceUrl() << "/z$/";
+ Uri << m_Client->ServiceUrl() << "/z$/";
if (Namespace != ZenCacheStore::DefaultNamespace)
{
Uri << Namespace << "/";
@@ -481,7 +481,7 @@ ZenStructuredCacheSession::PutCacheRecord(std::string_view Namespace,
ZenContentType Type)
{
ExtendableStringBuilder<256> Uri;
- Uri << m_Client.ServiceUrl() << "/z$/";
+ Uri << m_Client->ServiceUrl() << "/z$/";
if (Namespace != ZenCacheStore::DefaultNamespace)
{
Uri << Namespace << "/";
@@ -517,7 +517,7 @@ ZenStructuredCacheSession::PutCacheValue(std::string_view Namespace,
IoBuffer Payload)
{
ExtendableStringBuilder<256> Uri;
- Uri << m_Client.ServiceUrl() << "/z$/";
+ Uri << m_Client->ServiceUrl() << "/z$/";
if (Namespace != ZenCacheStore::DefaultNamespace)
{
Uri << Namespace << "/";
@@ -546,7 +546,7 @@ ZenCacheResult
ZenStructuredCacheSession::InvokeRpc(const CbObjectView& Request)
{
ExtendableStringBuilder<256> Uri;
- Uri << m_Client.ServiceUrl() << "/z$/$rpc";
+ Uri << m_Client->ServiceUrl() << "/z$/$rpc";
BinaryWriter Body;
Request.CopyTo(Body);
@@ -579,7 +579,7 @@ ZenCacheResult
ZenStructuredCacheSession::InvokeRpc(const CbPackage& Request)
{
ExtendableStringBuilder<256> Uri;
- Uri << m_Client.ServiceUrl() << "/z$/$rpc";
+ Uri << m_Client->ServiceUrl() << "/z$/$rpc";
SharedBuffer Message = FormatPackageMessageBuffer(Request).Flatten();