From 3312ebd0fe8e997a5e660943f38c45ebb83b5c6a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 1 Aug 2016 23:55:49 +0200 Subject: [PATCH] Correctly increase the reference count on PerformanceManager --- ext/ghoul | 2 +- src/performance/performancemanager.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index c8b3c9a18c..3b3a4c86b1 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit c8b3c9a18cfc19bc7c6fef456601bee1928d4d7e +Subproject commit 3b3a4c86b16631c0f27774baf033269be4db5537 diff --git a/src/performance/performancemanager.cpp b/src/performance/performancemanager.cpp index e5ae4aa50a..caecf15b9a 100644 --- a/src/performance/performancemanager.cpp +++ b/src/performance/performancemanager.cpp @@ -78,6 +78,10 @@ void PerformanceManager::createGlobalSharedMemory() { sharedMemory.acquireLock(); GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); ++(m->referenceCount); + LINFO( + "Using global shared memory block for performance measurements. " + "Reference count: " << int(m->referenceCount) + ); sharedMemory.releaseLock(); } else { @@ -107,7 +111,9 @@ void PerformanceManager::destroyGlobalSharedMemory() { sharedMemory.acquireLock(); GlobalMemory* m = reinterpret_cast(sharedMemory.memory()); --(m->referenceCount); + LINFO("Global shared performance memory reference count: " << m->referenceCount); if (m->referenceCount == 0) { + LINFO("Removing global shared performance memory"); SharedMemory::remove(GlobalSharedMemoryName); } sharedMemory.releaseLock(); @@ -126,14 +132,17 @@ PerformanceManager::PerformanceManager() // The the first free block (which also coincides with the number of blocks uint8_t blockIndex = m->number; + ++(m->number); std::string localName = LocalSharedMemoryNameBase + std::to_string(blockIndex); // Compute the total size const int totalSize = sizeof(PerformanceLayout); - LINFO("Create shared memory of " << totalSize << " bytes"); + LINFO("Create shared memory '" + localName + "' of " << totalSize << " bytes"); if (SharedMemory::exists(localName)) { - throw ghoul::RuntimeError("Shared Memory block already existed"); + throw ghoul::RuntimeError( + "Shared Memory '" + localName + "' block already existed" + ); } ghoul::SharedMemory::create(localName, totalSize);