add ref counting for cassandra callbacks

This commit is contained in:
CJ Cobb
2021-01-21 10:28:46 -05:00
parent 176f91e15c
commit eca85b3538
3 changed files with 10 additions and 3 deletions

View File

@@ -474,7 +474,7 @@ public:
if (next_->marker().size() == 0)
return "";
else
return std::string{next_->marker().data()[0]};
return ripple::strHex(std::string{next_->marker().data()[0]});
}
};

View File

@@ -33,6 +33,8 @@ flatMapWriteCallback(CassFuture* fut, void* cbData)
backend.throttleCv_.notify_all();
if (backend.numRequestsOutstanding_ == 0)
backend.syncCv_.notify_all();
int remaining = --requestParams.refs;
if (remaining == 0)
delete &requestParams;
}
}
@@ -71,6 +73,8 @@ flatMapWriteKeyCallback(CassFuture* fut, void* cbData)
backend.throttleCv_.notify_all();
if (backend.numRequestsOutstanding_ == 0)
backend.syncCv_.notify_all();
int remaining = --requestParams.refs;
if (remaining == 0)
delete &requestParams;
}
}

View File

@@ -1315,6 +1315,7 @@ public:
bool isDeleted;
uint32_t currentRetries = 0;
std::atomic<int> refs = 1;
WriteCallbackData(
CassandraFlatMapBackend const* f,
@@ -1330,6 +1331,8 @@ public:
, isCreated(isCreated)
, isDeleted(isDeleted)
{
if (isCreated or isDeleted)
refs = 2;
}
};