Scope LOCKGUARD(m_httpCallbacksMts) in HttpClientManager more closely around the thing it's guarding
@@ -71,9 +71,11 @@ namespace ARIASDK_NS_BEGIN {
void HttpClientManager::handleSendRequest(EventsUploadContextPtr const& ctx)
{
- LOCKGUARD(m_httpCallbacksMtx);
HttpCallback *callback = new HttpCallback(*this, ctx);
+ {
+ LOCKGUARD(m_httpCallbacksMtx);
m_httpCallbacks.push_back(callback);
+ }
LOG_INFO("Uploading %u event(s) of priority %d (%s) for %u tenant(s) in HTTP request %s (approx. %u bytes)...",
static_cast<unsigned>(ctx->recordIdsAndTenantIds.size()), ctx->latency, latencyToStr(ctx->latency), static_cast<unsigned>(ctx->packageIds.size()),
@@ -89,10 +91,10 @@ namespace ARIASDK_NS_BEGIN {
void HttpClientManager::onHttpResponse(HttpCallback* callback)
{
- LOCKGUARD(m_httpCallbacksMtx);
-
EventsUploadContextPtr &ctx = callback->m_ctx;
+ {
+ LOCKGUARD(m_httpCallbacksMtx);
assert(std::find(m_httpCallbacks.cbegin(), m_httpCallbacks.cend(), callback) != m_httpCallbacks.end());
#if !defined(NDEBUG) && defined(HAVE_MAT_LOGGING)
@@ -110,6 +112,7 @@ namespace ARIASDK_NS_BEGIN {
LOG_TRACE("HTTP remove callback=%p", callback);
m_httpCallbacks.remove(callback);
+ }
delete callback;
}
